mirror of https://github.com/citusdata/citus.git
Fixes review comments
parent
2fd191a8eb
commit
2608d942a2
|
@ -14,12 +14,12 @@
|
||||||
#include "pg_version_compat.h"
|
#include "pg_version_compat.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "commands/defrem.h"
|
#include "commands/defrem.h"
|
||||||
|
#include "commands/defrem.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "nodes/parsenodes.h"
|
#include "nodes/parsenodes.h"
|
||||||
#include "parser/parse_type.h"
|
#include "parser/parse_type.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "commands/defrem.h"
|
|
||||||
#include "distributed/commands.h"
|
#include "distributed/commands.h"
|
||||||
#include "distributed/citus_ruleutils.h"
|
#include "distributed/citus_ruleutils.h"
|
||||||
#include "distributed/deparser.h"
|
#include "distributed/deparser.h"
|
||||||
|
@ -91,34 +91,6 @@ AppendAlterDatabaseOwnerStmt(StringInfo buf, AlterOwnerStmt *stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
DeparseGrantOnDatabaseStmt(Node *node)
|
|
||||||
{
|
|
||||||
GrantStmt *stmt = castNode(GrantStmt, node);
|
|
||||||
Assert(stmt->objtype == OBJECT_DATABASE);
|
|
||||||
|
|
||||||
StringInfoData str = { 0 };
|
|
||||||
initStringInfo(&str);
|
|
||||||
|
|
||||||
AppendGrantOnDatabaseStmt(&str, stmt);
|
|
||||||
|
|
||||||
return str.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt)
|
|
||||||
{
|
|
||||||
Assert(stmt->objtype == OBJECT_DATABASE);
|
|
||||||
|
|
||||||
AppendGrantSharedPrefix(buf, stmt);
|
|
||||||
|
|
||||||
AppendGrantDatabases(buf, stmt);
|
|
||||||
|
|
||||||
AppendGrantSharedSuffix(buf, stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AppendGrantDatabases(StringInfo buf, GrantStmt *stmt)
|
AppendGrantDatabases(StringInfo buf, GrantStmt *stmt)
|
||||||
{
|
{
|
||||||
|
@ -137,17 +109,16 @@ AppendGrantDatabases(StringInfo buf, GrantStmt *stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
static void
|
||||||
DeparseAlterDatabaseStmt(Node *node)
|
AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt)
|
||||||
{
|
{
|
||||||
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
|
Assert(stmt->objtype == OBJECT_DATABASE);
|
||||||
|
|
||||||
StringInfoData str = { 0 };
|
AppendGrantSharedPrefix(buf, stmt);
|
||||||
initStringInfo(&str);
|
|
||||||
|
|
||||||
AppendAlterDatabaseStmt(&str, stmt);
|
AppendGrantDatabases(buf, stmt);
|
||||||
|
|
||||||
return str.data;
|
AppendGrantSharedSuffix(buf, stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,6 +189,35 @@ AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool *
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
DeparseGrantOnDatabaseStmt(Node *node)
|
||||||
|
{
|
||||||
|
GrantStmt *stmt = castNode(GrantStmt, node);
|
||||||
|
Assert(stmt->objtype == OBJECT_DATABASE);
|
||||||
|
|
||||||
|
StringInfoData str = { 0 };
|
||||||
|
initStringInfo(&str);
|
||||||
|
|
||||||
|
AppendGrantOnDatabaseStmt(&str, stmt);
|
||||||
|
|
||||||
|
return str.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
DeparseAlterDatabaseStmt(Node *node)
|
||||||
|
{
|
||||||
|
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
|
||||||
|
|
||||||
|
StringInfoData str = { 0 };
|
||||||
|
initStringInfo(&str);
|
||||||
|
|
||||||
|
AppendAlterDatabaseStmt(&str, stmt);
|
||||||
|
|
||||||
|
return str.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_15
|
#if PG_VERSION_NUM >= PG_VERSION_15
|
||||||
char *
|
char *
|
||||||
DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
||||||
|
@ -237,21 +237,17 @@ DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* Deparses an ALTER DATABASE RENAME statement.
|
AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt)
|
||||||
*
|
{
|
||||||
* This function takes a Node pointer representing an ALTER DATABASE RENAME
|
appendStringInfo(buf, "ALTER DATABASE %s", quote_identifier(stmt->dbname));
|
||||||
* statement, and returns a string that is the SQL representation of that
|
|
||||||
* statement.
|
VariableSetStmt *varSetStmt = castNode(VariableSetStmt, stmt->setstmt);
|
||||||
*
|
|
||||||
* Parameters:
|
AppendVariableSet(buf, varSetStmt);
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
|
@ -282,33 +278,15 @@ DeparseAlterDatabaseSetStmt(Node *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, "ALTER DATABASE %s", quote_identifier(stmt->dbname));
|
|
||||||
|
|
||||||
VariableSetStmt *varSetStmt = castNode(VariableSetStmt, stmt->setstmt);
|
|
||||||
|
|
||||||
AppendVariableSet(buf, varSetStmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
DeparseCreateDatabaseStmt(Node *node)
|
|
||||||
{
|
|
||||||
CreatedbStmt *stmt = castNode(CreatedbStmt, node);
|
|
||||||
StringInfoData str = { 0 };
|
|
||||||
initStringInfo(&str);
|
|
||||||
|
|
||||||
AppendCreateDatabaseStmt(&str, stmt);
|
|
||||||
|
|
||||||
return str.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt)
|
AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Make sure that we don't try to deparse something that this
|
||||||
|
* function doesn't expect.
|
||||||
|
*/
|
||||||
|
EnsureSupportedCreateDatabaseCommand(stmt);
|
||||||
|
|
||||||
appendStringInfo(buf,
|
appendStringInfo(buf,
|
||||||
"CREATE DATABASE %s",
|
"CREATE DATABASE %s",
|
||||||
quote_identifier(stmt->dbname));
|
quote_identifier(stmt->dbname));
|
||||||
|
@ -323,13 +301,13 @@ AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt)
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
DeparseDropDatabaseStmt(Node *node)
|
DeparseCreateDatabaseStmt(Node *node)
|
||||||
{
|
{
|
||||||
DropdbStmt *stmt = castNode(DropdbStmt, node);
|
CreatedbStmt *stmt = castNode(CreatedbStmt, node);
|
||||||
StringInfoData str = { 0 };
|
StringInfoData str = { 0 };
|
||||||
initStringInfo(&str);
|
initStringInfo(&str);
|
||||||
|
|
||||||
AppendDropDatabaseStmt(&str, stmt);
|
AppendCreateDatabaseStmt(&str, stmt);
|
||||||
|
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
@ -369,3 +347,16 @@ AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
|
||||||
appendStringInfo(buf, " )");
|
appendStringInfo(buf, " )");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
DeparseDropDatabaseStmt(Node *node)
|
||||||
|
{
|
||||||
|
DropdbStmt *stmt = castNode(DropdbStmt, node);
|
||||||
|
StringInfoData str = { 0 };
|
||||||
|
initStringInfo(&str);
|
||||||
|
|
||||||
|
AppendDropDatabaseStmt(&str, stmt);
|
||||||
|
|
||||||
|
return str.data;
|
||||||
|
}
|
||||||
|
|
|
@ -135,8 +135,7 @@ typedef enum OptionFormatType
|
||||||
OPTION_FORMAT_STRING,
|
OPTION_FORMAT_STRING,
|
||||||
OPTION_FORMAT_LITERAL_CSTR,
|
OPTION_FORMAT_LITERAL_CSTR,
|
||||||
OPTION_FORMAT_BOOLEAN,
|
OPTION_FORMAT_BOOLEAN,
|
||||||
OPTION_FORMAT_INTEGER,
|
OPTION_FORMAT_INTEGER
|
||||||
OPTION_FORMAT_OBJECT_ID
|
|
||||||
} OptionFormatType;
|
} OptionFormatType;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue