Apply suggestions from code review

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
pull/7240/head
Gürkan İndibay 2023-11-10 17:34:09 +03:00 committed by GitHub
parent 7a6afb0beb
commit 3067d1ef08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 16 deletions

View File

@ -275,7 +275,7 @@ PreprocessAlterDatabaseSetStmt(Node *node, const char *queryString,
* postgres instance. * postgres instance.
* *
* In this stage, we can perform validations and prepare the commands that need to * 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 * List *
PreprocessCreateDatabaseStmt(Node *node, const char *queryString, 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 * 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 * 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 * List *

View File

@ -1,11 +1,15 @@
/* /*-------------------------------------------------------------------------
*
* citus_deparseutils.c * citus_deparseutils.c
* ---------------------
* *
* This file contains common functions used for deparsing PostgreSQL statements * This file contains common functions used for deparsing PostgreSQL
* to their equivalent SQL representation. * statements to their equivalent SQL representation.
* *
* Copyright (c) Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/ */
#include "pg_version_constants.h" #include "pg_version_constants.h"
#include "postgres.h" #include "postgres.h"
@ -31,9 +35,9 @@
* @param optionFormatsLen The number of option formats in the opt_formats array. * @param optionFormatsLen The number of option formats in the opt_formats array.
*/ */
void void
DefElemOptionToStatement(StringInfo buf, DefElem *option, const DefElemOptionToStatement(StringInfo buf, DefElem *option,
DefElemOptionFormat *optionFormats, int const DefElemOptionFormat *optionFormats,
optionFormatsLen) int optionFormatsLen)
{ {
const char *name = option->defname; const char *name = option->defname;
int i; int i;

View File

@ -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 * UnmarkNodeWideObjectsDistributed deletes pg_dist_object records
* and for all databases in `DROP DATABASE` statement * for all distributed objects in given Drop stmt node.
*
* Today we only expect DropRoleStmt and DropdbStmt to get here.
*/ */
void void
UnmarkNodeWideObjectsDistributed(Node *node) UnmarkNodeWideObjectsDistributed(Node *node)

View File

@ -3902,11 +3902,13 @@ Datum
citus_internal_database_command(PG_FUNCTION_ARGS) citus_internal_database_command(PG_FUNCTION_ARGS)
{ {
CheckCitusVersion(ERROR); CheckCitusVersion(ERROR);
if (!ShouldSkipMetadataChecks()) if (!ShouldSkipMetadataChecks())
{ {
EnsureCitusInitiatedOperation(); EnsureCitusInitiatedOperation();
} }
PG_ENSURE_ARGNOTNULL(0, "database command");
PG_ENSURE_ARGNOTNULL(0, "command");
text *commandText = PG_GETARG_TEXT_P(0); text *commandText = PG_GETARG_TEXT_P(0);
char *command = text_to_cstring(commandText); 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)))); 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); AtEOXact_GUC(true, saveNestLevel);
PG_RETURN_VOID(); PG_RETURN_VOID();

View File

@ -140,9 +140,9 @@ typedef enum OptionFormatType
} OptionFormatType; } OptionFormatType;
extern void DefElemOptionToStatement(StringInfo buf, DefElem *option, const extern void DefElemOptionToStatement(StringInfo buf, DefElem *option,
DefElemOptionFormat *opt_formats, int const DefElemOptionFormat *opt_formats,
opt_formats_len); int opt_formats_len);
/* forward declarations for deparse_statistics_stmts.c */ /* forward declarations for deparse_statistics_stmts.c */