mirror of https://github.com/citusdata/citus.git
Fixes review notes
parent
ed3ebf2296
commit
9d7e601e1d
|
@ -191,13 +191,25 @@ PreprocessGrantOnDatabaseStmt(Node *node, const char *queryString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if the provided ALTER DATABASE statement is a SET TABLESPACE statement.
|
||||||
|
*
|
||||||
|
* This function takes a Node pointer representing a AlterDatabaseStmt, and checks
|
||||||
|
* if it is a SET TABLESPACE statement, which is used to move a table to a new
|
||||||
|
* tablespace.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* stmt: A pointer to a Node representing AlterDatabaseStmt.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* true if the statement is a SET TABLESPACE statement, false otherwise.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
isSetTablespaceStatement(AlterDatabaseStmt *stmt)
|
isSetTablespaceStatement(AlterDatabaseStmt *stmt)
|
||||||
{
|
{
|
||||||
ListCell *lc = NULL;
|
DefElem *def = NULL;
|
||||||
foreach(lc, stmt->options)
|
foreach_ptr(def, stmt->options)
|
||||||
{
|
{
|
||||||
DefElem *def = (DefElem *) lfirst(lc);
|
|
||||||
if (strcmp(def->defname, "tablespace") == 0)
|
if (strcmp(def->defname, "tablespace") == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -290,8 +302,7 @@ PreprocessAlterDatabaseRefreshCollStmt(Node *node, const char *queryString,
|
||||||
* all workers.
|
* all workers.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString,
|
PostprocessAlterDatabaseRenameStmt(Node *node, const char *queryString)
|
||||||
ProcessUtilityContext processUtilityContext)
|
|
||||||
{
|
{
|
||||||
if (!ShouldPropagate())
|
if (!ShouldPropagate())
|
||||||
{
|
{
|
||||||
|
|
|
@ -524,8 +524,8 @@ static DistributeObjectOps Database_Set = {
|
||||||
static DistributeObjectOps Database_Rename = {
|
static DistributeObjectOps Database_Rename = {
|
||||||
.deparse = DeparseAlterDatabaseRenameStmt,
|
.deparse = DeparseAlterDatabaseRenameStmt,
|
||||||
.qualify = NULL,
|
.qualify = NULL,
|
||||||
.preprocess = PreprocessAlterDatabaseRenameStmt,
|
.preprocess = NULL,
|
||||||
.postprocess = NULL,
|
.postprocess = PostprocessAlterDatabaseRenameStmt,
|
||||||
.objectType = OBJECT_DATABASE,
|
.objectType = OBJECT_DATABASE,
|
||||||
.operationType = DIST_OPS_ALTER,
|
.operationType = DIST_OPS_ALTER,
|
||||||
.address = NULL,
|
.address = NULL,
|
||||||
|
|
|
@ -55,7 +55,7 @@ const DefElemOptionFormat create_database_option_formats[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const DefElemOptionFormat alter_database_option_formats[] = {
|
const DefElemOptionFormat alterDatabaseOptionFormats[] = {
|
||||||
{ "is_template", " IS_TEMPLATE %s", OPTION_FORMAT_BOOLEAN },
|
{ "is_template", " IS_TEMPLATE %s", OPTION_FORMAT_BOOLEAN },
|
||||||
{ "allow_connections", " ALLOW_CONNECTIONS %s", OPTION_FORMAT_BOOLEAN },
|
{ "allow_connections", " ALLOW_CONNECTIONS %s", OPTION_FORMAT_BOOLEAN },
|
||||||
{ "connection_limit", " CONNECTION LIMIT %d", OPTION_FORMAT_INTEGER },
|
{ "connection_limit", " CONNECTION LIMIT %d", OPTION_FORMAT_INTEGER },
|
||||||
|
@ -147,16 +147,16 @@ AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool
|
AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool
|
||||||
prefix_appended_for_basic_options, char *dbname)
|
prefixAppendedForBasicOptions, char *dbname)
|
||||||
{
|
{
|
||||||
if (!prefix_appended_for_basic_options)
|
if (!prefixAppendedForBasicOptions)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, "ALTER DATABASE %s WITH", quote_identifier(dbname));
|
appendStringInfo(buf, "ALTER DATABASE %s WITH", quote_identifier(dbname));
|
||||||
prefix_appended_for_basic_options = true;
|
prefixAppendedForBasicOptions = true;
|
||||||
}
|
}
|
||||||
DefElemOptionToStatement(buf, def, alter_database_option_formats, lengthof(
|
DefElemOptionToStatement(buf, def, alterDatabaseOptionFormats, lengthof(
|
||||||
alter_database_option_formats));
|
alterDatabaseOptionFormats));
|
||||||
return prefix_appended_for_basic_options;
|
return prefixAppendedForBasicOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||||
if (stmt->options)
|
if (stmt->options)
|
||||||
{
|
{
|
||||||
ListCell *cell = NULL;
|
ListCell *cell = NULL;
|
||||||
bool prefix_appended_for_basic_options = false;
|
bool prefixAppendedForBasicOptions = false;
|
||||||
foreach(cell, stmt->options)
|
foreach(cell, stmt->options)
|
||||||
{
|
{
|
||||||
DefElem *def = castNode(DefElem, lfirst(cell));
|
DefElem *def = castNode(DefElem, lfirst(cell));
|
||||||
|
@ -186,9 +186,9 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prefix_appended_for_basic_options = AppendBasicAlterDatabaseOptions(buf,
|
prefixAppendedForBasicOptions = AppendBasicAlterDatabaseOptions(buf,
|
||||||
def,
|
def,
|
||||||
prefix_appended_for_basic_options,
|
prefixAppendedForBasicOptions,
|
||||||
stmt->
|
stmt->
|
||||||
dbname);
|
dbname);
|
||||||
}
|
}
|
||||||
|
@ -247,6 +247,21 @@ DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deparses an ALTER DATABASE RENAME statement.
|
||||||
|
*
|
||||||
|
* This function takes a Node pointer representing an ALTER DATABASE RENAME
|
||||||
|
* statement, and returns a string that is the SQL representation of that
|
||||||
|
* statement.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* node: A pointer to a Node representing an ALTER DATABASE RENAME statement.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* A string representing the SQL command to rename a database. The string is
|
||||||
|
* in the format "ALTER DATABASE <oldname> RENAME TO <newname>", where
|
||||||
|
* <oldname> and <newname> are the old and new database names, respectively.
|
||||||
|
*/
|
||||||
char *
|
char *
|
||||||
DeparseAlterDatabaseRenameStmt(Node *node)
|
DeparseAlterDatabaseRenameStmt(Node *node)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,4 +3,3 @@
|
||||||
DROP FUNCTION pg_catalog.citus_internal_database_command(text);
|
DROP FUNCTION pg_catalog.citus_internal_database_command(text);
|
||||||
|
|
||||||
#include "../udfs/citus_add_rebalance_strategy/10.1-1.sql"
|
#include "../udfs/citus_add_rebalance_strategy/10.1-1.sql"
|
||||||
|
|
||||||
|
|
|
@ -246,9 +246,7 @@ extern List * CreateDatabaseStmtObjectAddress(Node *node, bool missingOk,
|
||||||
extern List * GenerateGrantDatabaseCommandList(void);
|
extern List * GenerateGrantDatabaseCommandList(void);
|
||||||
|
|
||||||
|
|
||||||
extern List * PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString,
|
extern List * PostprocessAlterDatabaseRenameStmt(Node *node, const char *queryString);
|
||||||
ProcessUtilityContext
|
|
||||||
processUtilityContext);
|
|
||||||
|
|
||||||
extern void EnsureSupportedCreateDatabaseCommand(CreatedbStmt *stmt);
|
extern void EnsureSupportedCreateDatabaseCommand(CreatedbStmt *stmt);
|
||||||
extern char * CreateDatabaseDDLCommand(Oid dbId);
|
extern char * CreateDatabaseDDLCommand(Oid dbId);
|
||||||
|
|
Loading…
Reference in New Issue