Don't throw error for DROP DATABASE IF EXISTS

pull/2450/head
Hadi Moshayedi 2018-10-22 23:51:39 -04:00
parent 28d307850c
commit 3e00bf1c0d
3 changed files with 18 additions and 2 deletions

View File

@ -549,12 +549,16 @@ multi_ProcessUtility(PlannedStmt *pstmt,
*/
if (IsA(parsetree, DropdbStmt))
{
const bool missingOK = true;
DropdbStmt *dropDbStatement = (DropdbStmt *) parsetree;
char *dbname = dropDbStatement->dbname;
Oid databaseOid = get_database_oid(dbname, false);
Oid databaseOid = get_database_oid(dbname, missingOK);
if (OidIsValid(databaseOid))
{
StopMaintenanceDaemon(databaseOid);
}
}
/* set user if needed and go ahead and run local utility using standard hook */
if (commandMustRunAsOwner)

View File

@ -268,3 +268,10 @@ FETCH BACKWARD noHoldCursor;
COMMIT;
FETCH ABSOLUTE 5 FROM noHoldCursor;
ERROR: cursor "noholdcursor" does not exist
-- Test we don't throw an error for DROP IF EXISTS
DROP DATABASE IF EXISTS not_existing_database;
NOTICE: database "not_existing_database" does not exist, skipping
DROP TABLE IF EXISTS not_existing_table;
NOTICE: table "not_existing_table" does not exist, skipping
DROP SCHEMA IF EXISTS not_existing_schema;
NOTICE: schema "not_existing_schema" does not exist, skipping

View File

@ -146,3 +146,8 @@ FETCH ABSOLUTE 5 FROM noHoldCursor;
FETCH BACKWARD noHoldCursor;
COMMIT;
FETCH ABSOLUTE 5 FROM noHoldCursor;
-- Test we don't throw an error for DROP IF EXISTS
DROP DATABASE IF EXISTS not_existing_database;
DROP TABLE IF EXISTS not_existing_table;
DROP SCHEMA IF EXISTS not_existing_schema;