-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Inaccurate drop database statement in Oracle #1807
Conversation
Failing test shows that the override for dropDatabase() in OracleDialect is wrong, so this has been replaced with the correct statement. Failing test would then require privileges to drop the pluggable database from the root container level, which are not accessible, so it has been excluded.
Change test names casing and exception name
@@ -318,7 +318,7 @@ open class OracleDialect : VendorDialect(dialectName, OracleDataTypeProvider, Or | |||
|
|||
override fun createDatabase(name: String): String = "CREATE DATABASE ${name.inProperCase()}" | |||
|
|||
override fun dropDatabase(name: String): String = "DROP DATABASE ${name.inProperCase()}" | |||
override fun dropDatabase(name: String): String = "DROP DATABASE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you tell me why don't we need the name in drop statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@e5l Documentation shows that syntax should not have the database name in the drop statement.
This can be confirmed in the test if SchemaUtils.dropDatabase(dbName)
is pulled out of the try block (or if the cause.cause
is logged in the catch block) as it fails with this exception:
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended.
Statement(s): DROP DATABASE JETBRAINS
Removing the name resolves this exception (but then leads to the next exception - ORA-65040: operation not allowed from within a pluggable database
)
* fix: Inaccurate drop database statement in Oracle Failing test shows that the override for dropDatabase() in OracleDialect is wrong, so this has been replaced with the correct statement. Failing test would then require privileges to drop the pluggable database from the root container level, which are not accessible, so it has been excluded.
The following test fails when run locally with Oracle:
CreateDatabaseTest/'create database test'()
The first failure
ORA-01501: CREATE DATABASE failed, ORA-01100: database already mounted
occurs because the create statement is executed while a database already exists. This occurs because thedropDatabase()
statement executed in the try block fails as the syntax is not correct.Once the syntax is fixed, the test still fails with error
ORA-65040: operation not allowed from within a pluggable database
because certain operations, including dropping the DB, need to be performed only at the root container level.Attempting to fix this with
exec("ALTER SESSION SET CONTAINER=CDB\$ROOT")
then fails with errorORA-01031: insufficient privileges
. This is in spite of the test container connection being setup usingsys as sysdba
and granting all privileges to user.The documentation confirms that dropping a database requires certain conditions:
Attempting to execute variants of the following statements doesn't work either (most likely because they are SQL*PLUS CLI commands):
Oracle has been excluded from this test.