diff --git a/src/backend/distributed/commands/database.c b/src/backend/distributed/commands/database.c index b9a459cf4..0f4705c21 100644 --- a/src/backend/distributed/commands/database.c +++ b/src/backend/distributed/commands/database.c @@ -275,7 +275,7 @@ PreprocessAlterDatabaseSetStmt(Node *node, const char *queryString, * postgres instance. * * In this stage, we can perform validations and prepare the commands that need to - * be run on all workers to grant. + * be run on all workers to create the database. */ List * PreprocessCreateDatabaseStmt(Node *node, const char *queryString, @@ -298,7 +298,9 @@ PreprocessCreateDatabaseStmt(Node *node, const char *queryString, /* * PostprocessCreatedbStmt is executed after the statement is applied to the local * postgres instance. In this stage we can prepare the commands that need to be run on - * all workers to create the database. + * all workers to create the database. Since the CREATE DATABASE statement gives error + * in a transaction block, we need to use NontransactionalNodeDDLTaskList to send the + * CREATE DATABASE statement to the workers. * */ List * diff --git a/src/backend/distributed/deparser/citus_deparseutils.c b/src/backend/distributed/deparser/citus_deparseutils.c index bdc591a01..1fae9407f 100644 --- a/src/backend/distributed/deparser/citus_deparseutils.c +++ b/src/backend/distributed/deparser/citus_deparseutils.c @@ -1,11 +1,15 @@ -/* +/*------------------------------------------------------------------------- + * * citus_deparseutils.c - * --------------------- * - * This file contains common functions used for deparsing PostgreSQL statements - * to their equivalent SQL representation. + * This file contains common functions used for deparsing PostgreSQL + * statements to their equivalent SQL representation. * + * Copyright (c) Citus Data, Inc. + * + *------------------------------------------------------------------------- */ + #include "pg_version_constants.h" #include "postgres.h" @@ -31,9 +35,9 @@ * @param optionFormatsLen The number of option formats in the opt_formats array. */ void -DefElemOptionToStatement(StringInfo buf, DefElem *option, const - DefElemOptionFormat *optionFormats, int - optionFormatsLen) +DefElemOptionToStatement(StringInfo buf, DefElem *option, + const DefElemOptionFormat *optionFormats, + int optionFormatsLen) { const char *name = option->defname; int i; diff --git a/src/backend/distributed/metadata/distobject.c b/src/backend/distributed/metadata/distobject.c index afdaf57c1..5350a08bc 100644 --- a/src/backend/distributed/metadata/distobject.c +++ b/src/backend/distributed/metadata/distobject.c @@ -360,8 +360,10 @@ ExecuteCommandAsSuperuser(char *query, int paramCount, Oid *paramTypes, /* - * Deletes all pg_dist_object records for distributed roles in `DROP ROLE` statement a - * and for all databases in `DROP DATABASE` statement + * UnmarkNodeWideObjectsDistributed deletes pg_dist_object records + * for all distributed objects in given Drop stmt node. + * + * Today we only expect DropRoleStmt and DropdbStmt to get here. */ void UnmarkNodeWideObjectsDistributed(Node *node) diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 6db3ce28e..dfcf243bf 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -3902,11 +3902,13 @@ Datum citus_internal_database_command(PG_FUNCTION_ARGS) { CheckCitusVersion(ERROR); + if (!ShouldSkipMetadataChecks()) { EnsureCitusInitiatedOperation(); } - PG_ENSURE_ARGNOTNULL(0, "database command"); + + PG_ENSURE_ARGNOTNULL(0, "command"); text *commandText = PG_GETARG_TEXT_P(0); char *command = text_to_cstring(commandText); @@ -3960,7 +3962,7 @@ citus_internal_database_command(PG_FUNCTION_ARGS) ereport(ERROR, (errmsg("unsupported command type %d", nodeTag(parseTree)))); } - /* Rollbacks GUCs to the state before this session */ + /* rollback GUCs to the state before this session */ AtEOXact_GUC(true, saveNestLevel); PG_RETURN_VOID(); diff --git a/src/include/distributed/deparser.h b/src/include/distributed/deparser.h index 59e6d40c6..5159f4c9d 100644 --- a/src/include/distributed/deparser.h +++ b/src/include/distributed/deparser.h @@ -140,9 +140,9 @@ typedef enum OptionFormatType } OptionFormatType; -extern void DefElemOptionToStatement(StringInfo buf, DefElem *option, const - DefElemOptionFormat *opt_formats, int - opt_formats_len); +extern void DefElemOptionToStatement(StringInfo buf, DefElem *option, + const DefElemOptionFormat *opt_formats, + int opt_formats_len); /* forward declarations for deparse_statistics_stmts.c */