Adds If exists statement for drop database

create_drop_db_gh
gindibay 2023-10-13 01:36:01 +03:00
parent 4087d1941d
commit e5a6b7880c
3 changed files with 7 additions and 5 deletions

View File

@ -259,8 +259,10 @@ DeparseCreateDatabaseStmt(Node *node)
static void
AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
{
char *if_exists_statement = stmt->missing_ok ? "IF EXISTS" : "";
appendStringInfo(buf,
"DROP DATABASE %s",
"DROP DATABASE %s %s",
if_exists_statement,
quote_identifier(stmt->dbname));
DefElem *option = NULL;

View File

@ -112,10 +112,10 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing SELECT pg_catalog.citus_internal_database_command('CREATE DATABASE "mydatabase#1''2"')
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
set citus.grep_remote_commands = '%DROP DATABASE%';
drop database "mydatabase#1'2";
NOTICE: issuing SELECT pg_catalog.citus_internal_database_command('DROP DATABASE "mydatabase#1''2"')
drop database if exists "mydatabase#1'2";
NOTICE: issuing SELECT pg_catalog.citus_internal_database_command('DROP DATABASE IF EXISTS "mydatabase#1''2"')
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing SELECT pg_catalog.citus_internal_database_command('DROP DATABASE "mydatabase#1''2"')
NOTICE: issuing SELECT pg_catalog.citus_internal_database_command('DROP DATABASE IF EXISTS "mydatabase#1''2"')
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
--clean up resources created by this test
drop tablespace create_drop_db_tablespace;

View File

@ -102,7 +102,7 @@ set citus.grep_remote_commands = '%CREATE DATABASE%';
create database "mydatabase#1'2";
set citus.grep_remote_commands = '%DROP DATABASE%';
drop database "mydatabase#1'2";
drop database if exists "mydatabase#1'2";
--clean up resources created by this test