mirror of https://github.com/citusdata/citus.git
Removes set codes
parent
458f820755
commit
6e370116d8
|
@ -179,66 +179,6 @@ PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* PreprocessAlterDatabaseSetStmt is executed before 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 grant
|
||||
* on databases.
|
||||
*/
|
||||
List *
|
||||
PreprocessAlterDatabaseSetStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext processUtilityContext)
|
||||
{
|
||||
if (!ShouldPropagate())
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
AlterDatabaseSetStmt *stmt = castNode(AlterDatabaseSetStmt, node);
|
||||
|
||||
EnsureCoordinator();
|
||||
|
||||
char *sql = DeparseTreeNode((Node *) stmt);
|
||||
|
||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||
(void *) sql,
|
||||
ENABLE_DDL_PROPAGATION);
|
||||
|
||||
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PreprocessAlterDatabaseSetStmt is executed before 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 grant
|
||||
* on databases.
|
||||
*/
|
||||
List *
|
||||
PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext processUtilityContext)
|
||||
{
|
||||
if (!ShouldPropagate())
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
RenameStmt *stmt = castNode(RenameStmt, node);
|
||||
|
||||
EnsureCoordinator();
|
||||
|
||||
char *sql = DeparseTreeNode((Node *) stmt);
|
||||
|
||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||
(void *) sql,
|
||||
ENABLE_DDL_PROPAGATION);
|
||||
|
||||
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PreprocessAlterDatabaseSetStmt is executed before the statement is applied to the local
|
||||
* postgres instance.
|
||||
|
|
|
@ -455,21 +455,11 @@ static DistributeObjectOps Database_Alter = {
|
|||
.markDistributed = false,
|
||||
};
|
||||
|
||||
static DistributeObjectOps Database_Rename = {
|
||||
.deparse = DeparseAlterDatabaseRenameStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = NULL,
|
||||
.postprocess = NULL,
|
||||
.objectType = OBJECT_DATABASE,
|
||||
.operationType = DIST_OPS_ALTER,
|
||||
.address = NULL, /* TODO: RenameDatabaseStmtObjectAddress, */
|
||||
.markDistributed = false,
|
||||
};
|
||||
|
||||
static DistributeObjectOps Database_RefreshColl = {
|
||||
.deparse = DeparseAlterDatabaseRefreshCollStmt,
|
||||
.qualify = NULL,
|
||||
.preprocess = NULL,/*TODO: Add PostprocessAfter adding addresses */
|
||||
.preprocess = PreprocessAlterDatabaseRefreshCollStmt,
|
||||
.postprocess = NULL,
|
||||
.objectType = OBJECT_DATABASE,
|
||||
.operationType = DIST_OPS_ALTER,
|
||||
|
@ -2017,11 +2007,6 @@ GetDistributeObjectOps(Node *node)
|
|||
return &Collation_Rename;
|
||||
}
|
||||
|
||||
case OBJECT_DATABASE:
|
||||
{
|
||||
return &Database_Rename;
|
||||
}
|
||||
|
||||
case OBJECT_DOMAIN:
|
||||
{
|
||||
return &Domain_Rename;
|
||||
|
|
|
@ -1,164 +0,0 @@
|
|||
#include "postgres.h"
|
||||
|
||||
#include "lib/stringinfo.h"
|
||||
#include "nodes/nodes.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
|
||||
static void AppendVarSetValue2(StringInfo buf, VariableSetStmt *setStmt);
|
||||
static void AppendVariableSet2(StringInfo buf, VariableSetStmt *setStmt);
|
||||
|
||||
|
||||
static void
|
||||
AppendVarSetValue2(StringInfo buf, VariableSetStmt *setStmt)
|
||||
{
|
||||
ListCell *varArgCell = NULL;
|
||||
ListCell *firstCell = list_head(setStmt->args);
|
||||
|
||||
Assert(setStmt->kind == VAR_SET_VALUE);
|
||||
|
||||
foreach(varArgCell, setStmt->args)
|
||||
{
|
||||
Node *varArgNode = lfirst(varArgCell);
|
||||
A_Const *varArgConst = NULL;
|
||||
TypeName *typeName = NULL;
|
||||
|
||||
if (IsA(varArgNode, A_Const))
|
||||
{
|
||||
varArgConst = (A_Const *) varArgNode;
|
||||
}
|
||||
else if (IsA(varArgNode, TypeCast))
|
||||
{
|
||||
TypeCast *varArgTypeCast = (TypeCast *) varArgNode;
|
||||
|
||||
varArgConst = castNode(A_Const, varArgTypeCast->arg);
|
||||
typeName = varArgTypeCast->typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "unrecognized node type: %d", varArgNode->type);
|
||||
}
|
||||
|
||||
/* don't know how to start SET until we inspect first arg */
|
||||
if (varArgCell != firstCell)
|
||||
{
|
||||
appendStringInfoChar(buf, ',');
|
||||
}
|
||||
else if (typeName != NULL)
|
||||
{
|
||||
appendStringInfoString(buf, " SET TIME ZONE");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfo(buf, " SET %s =", quote_identifier(setStmt->name));
|
||||
}
|
||||
|
||||
Node *value = (Node *) &varArgConst->val;
|
||||
switch (value->type)
|
||||
{
|
||||
case T_Integer:
|
||||
{
|
||||
appendStringInfo(buf, " %d", intVal(value));
|
||||
break;
|
||||
}
|
||||
|
||||
case T_Float:
|
||||
{
|
||||
appendStringInfo(buf, " %s", strVal(value));
|
||||
break;
|
||||
}
|
||||
|
||||
case T_String:
|
||||
{
|
||||
if (typeName != NULL)
|
||||
{
|
||||
/*
|
||||
* Must be a ConstInterval argument for TIME ZONE. Coerce
|
||||
* to interval and back to normalize the value and account
|
||||
* for any typmod.
|
||||
*/
|
||||
Oid typoid = InvalidOid;
|
||||
int32 typmod = -1;
|
||||
|
||||
typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
|
||||
Assert(typoid == INTERVALOID);
|
||||
|
||||
Datum interval =
|
||||
DirectFunctionCall3(interval_in,
|
||||
CStringGetDatum(strVal(value)),
|
||||
ObjectIdGetDatum(InvalidOid),
|
||||
Int32GetDatum(typmod));
|
||||
|
||||
char *intervalout =
|
||||
DatumGetCString(DirectFunctionCall1(interval_out,
|
||||
interval));
|
||||
appendStringInfo(buf, " INTERVAL '%s'", intervalout);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfo(buf, " %s", quote_literal_cstr(strVal(
|
||||
value)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
elog(ERROR, "Unexpected Value type in VAR_SET_VALUE arguments.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* AppendVariableSet appends a string representing the VariableSetStmt to a buffer
|
||||
*/
|
||||
static void
|
||||
AppendVariableSet2(StringInfo buf, VariableSetStmt *setStmt)
|
||||
{
|
||||
switch (setStmt->kind)
|
||||
{
|
||||
case VAR_SET_VALUE:
|
||||
{
|
||||
AppendVarSetValue2(buf, setStmt);
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_SET_CURRENT:
|
||||
{
|
||||
appendStringInfo(buf, " SET %s FROM CURRENT", quote_identifier(
|
||||
setStmt->name));
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_SET_DEFAULT:
|
||||
{
|
||||
appendStringInfo(buf, " SET %s TO DEFAULT", quote_identifier(setStmt->name));
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_RESET:
|
||||
{
|
||||
appendStringInfo(buf, " RESET %s", quote_identifier(setStmt->name));
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_RESET_ALL:
|
||||
{
|
||||
appendStringInfoString(buf, " RESET ALL");
|
||||
break;
|
||||
}
|
||||
|
||||
/* VAR_SET_MULTI is a special case for SET TRANSACTION that should not occur here */
|
||||
case VAR_SET_MULTI:
|
||||
default:
|
||||
{
|
||||
ereport(ERROR, (errmsg("Unable to deparse SET statement")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
static void AppendAlterDatabaseOwnerStmt(StringInfo buf, AlterOwnerStmt *stmt);
|
||||
static void AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt);
|
||||
static void AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt);
|
||||
|
||||
char *
|
||||
DeparseAlterDatabaseOwnerStmt(Node *node)
|
||||
|
@ -86,143 +85,6 @@ AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||
{
|
||||
appendStringInfo(buf, "ALTER DATABASE %s ", quote_identifier(stmt->dbname));
|
||||
|
||||
if (stmt->options)
|
||||
{
|
||||
ListCell *cell = NULL;
|
||||
appendStringInfo(buf, "WITH OPTION ");
|
||||
foreach(cell, stmt->options)
|
||||
{
|
||||
DefElem *def = castNode(DefElem, lfirst(cell));
|
||||
appendStringInfo(buf, "%s %s", quote_identifier(def->defname),
|
||||
quote_literal_cstr(strVal(def->arg)));
|
||||
if (cell != list_tail(stmt->options))
|
||||
{
|
||||
appendStringInfo(buf, ", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendStringInfo(buf, ";");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt)
|
||||
{
|
||||
appendStringInfo(buf, "ALTER DATABASE %s SET ", quote_identifier(stmt->dbname));
|
||||
|
||||
VariableSetStmt *varSetStmt = castNode(VariableSetStmt, stmt->setstmt);
|
||||
|
||||
|
||||
if (varSetStmt->kind == VAR_SET_VALUE)
|
||||
{
|
||||
appendStringInfo(buf, "%s = %s", quote_identifier(varSetStmt->name),
|
||||
quote_literal_cstr(strVal(varSetStmt->args)));
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET_ALL)
|
||||
{
|
||||
appendStringInfo(buf, "RESET ALL");
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET)
|
||||
{
|
||||
appendStringInfo(buf, "RESET %s", quote_identifier(varSetStmt->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
errmsg("unrecognized AlterDatabaseSetStmt kind: %d",
|
||||
varSetStmt->kind));
|
||||
}
|
||||
|
||||
appendStringInfo(buf, ";");
|
||||
}
|
||||
|
||||
static void
|
||||
AppendDefElemConnLimit(StringInfo buf, DefElem *def)
|
||||
{
|
||||
appendStringInfo(buf, " CONNECTION LIMIT %ld",(long int) defGetNumeric(def));
|
||||
}
|
||||
|
||||
static void
|
||||
AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||
{
|
||||
appendStringInfo(buf, "ALTER DATABASE %s ", quote_identifier(stmt->dbname));
|
||||
|
||||
if (stmt->options)
|
||||
{
|
||||
ListCell *cell = NULL;
|
||||
appendStringInfo(buf, "WITH ");
|
||||
foreach(cell, stmt->options)
|
||||
{
|
||||
DefElem *def = castNode(DefElem, lfirst(cell));
|
||||
printf("test");
|
||||
if (strcmp(def->defname, "is_template") == 0)
|
||||
{
|
||||
appendStringInfo(buf, "%s %s", quote_identifier(def->defname),
|
||||
quote_literal_cstr(strVal(def->arg)));
|
||||
}
|
||||
else if (strcmp(def->defname, "connection_limit") == 0)
|
||||
{
|
||||
AppendDefElemConnLimit(buf, def);
|
||||
}
|
||||
else if (strcmp(def->defname, "allow_connections") == 0)
|
||||
{
|
||||
ereport(ERROR,
|
||||
errmsg("ALLOW_CONNECTIONS is not supported"));
|
||||
}
|
||||
else{
|
||||
ereport(ERROR,
|
||||
errmsg("unrecognized AlterDatabaseStmt option: %s",
|
||||
def->defname));
|
||||
}
|
||||
|
||||
if (cell != list_tail(stmt->options))
|
||||
{
|
||||
appendStringInfo(buf, ", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendStringInfo(buf, ";");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt)
|
||||
{
|
||||
appendStringInfo(buf, "ALTER DATABASE %s SET ", quote_identifier(stmt->dbname));
|
||||
|
||||
VariableSetStmt *varSetStmt = castNode(VariableSetStmt, stmt->setstmt);
|
||||
|
||||
|
||||
if (varSetStmt->kind == VAR_SET_VALUE)
|
||||
{
|
||||
appendStringInfo(buf, "%s = %s", quote_identifier(varSetStmt->name),
|
||||
quote_literal_cstr(strVal(varSetStmt->args)));
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET_ALL)
|
||||
{
|
||||
appendStringInfo(buf, "RESET ALL");
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET)
|
||||
{
|
||||
appendStringInfo(buf, "RESET %s", quote_identifier(varSetStmt->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
errmsg("unrecognized AlterDatabaseSetStmt kind: %d",
|
||||
varSetStmt->kind));
|
||||
}
|
||||
|
||||
appendStringInfo(buf, ";");
|
||||
}
|
||||
|
||||
static void
|
||||
AppendDefElemConnLimit(StringInfo buf, DefElem *def)
|
||||
{
|
||||
|
@ -242,7 +104,6 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
|||
foreach(cell, stmt->options)
|
||||
{
|
||||
DefElem *def = castNode(DefElem, lfirst(cell));
|
||||
printf("test");
|
||||
if (strcmp(def->defname, "is_template") == 0)
|
||||
{
|
||||
appendStringInfo(buf, "%s %s", quote_identifier(def->defname),
|
||||
|
@ -275,38 +136,6 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
AppendAlterDatabaseSetStmt(StringInfo buf, AlterDatabaseSetStmt *stmt)
|
||||
{
|
||||
appendStringInfo(buf, "ALTER DATABASE %s SET ", quote_identifier(stmt->dbname));
|
||||
|
||||
VariableSetStmt *varSetStmt = castNode(VariableSetStmt, stmt->setstmt);
|
||||
|
||||
|
||||
if (varSetStmt->kind == VAR_SET_VALUE)
|
||||
{
|
||||
appendStringInfo(buf, "%s = %s", quote_identifier(varSetStmt->name),
|
||||
quote_literal_cstr(strVal(varSetStmt->args)));
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET_ALL)
|
||||
{
|
||||
appendStringInfo(buf, "RESET ALL");
|
||||
}
|
||||
else if (varSetStmt->kind == VAR_RESET)
|
||||
{
|
||||
appendStringInfo(buf, "RESET %s", quote_identifier(varSetStmt->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
errmsg("unrecognized AlterDatabaseSetStmt kind: %d",
|
||||
varSetStmt->kind));
|
||||
}
|
||||
|
||||
appendStringInfo(buf, ";");
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
DeparseGrantOnDatabaseStmt(Node *node)
|
||||
{
|
||||
|
@ -336,21 +165,6 @@ DeparseAlterDatabaseStmt(Node *node)
|
|||
}
|
||||
|
||||
|
||||
char *
|
||||
DeparseAlterDatabaseRenameStmt(Node *node)
|
||||
{
|
||||
RenameStmt *stmt = (RenameStmt *) node;
|
||||
|
||||
StringInfoData str;
|
||||
initStringInfo(&str);
|
||||
|
||||
appendStringInfo(&str, "ALTER DATABASE %s RENAME TO %s;", quote_identifier(
|
||||
stmt->subname), quote_identifier(stmt->newname));
|
||||
|
||||
return str.data;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
||||
{
|
||||
|
@ -359,7 +173,8 @@ DeparseAlterDatabaseRefreshCollStmt(Node *node)
|
|||
StringInfoData str;
|
||||
initStringInfo(&str);
|
||||
|
||||
appendStringInfo(&str, "ALTER DATABASE %s REFRESH COLLATION;", quote_identifier(
|
||||
appendStringInfo(&str, "ALTER DATABASE %s REFRESH COLLATION VERSION;",
|
||||
quote_identifier(
|
||||
stmt->dbname));
|
||||
|
||||
return str.data;
|
||||
|
|
|
@ -226,13 +226,6 @@ extern List * PreprocessGrantOnDatabaseStmt(Node *node, const char *queryString,
|
|||
extern List * PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext processUtilityContext);
|
||||
|
||||
extern List * PreprocessAlterDatabaseSetStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext processUtilityContext);
|
||||
|
||||
extern List * PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext
|
||||
processUtilityContext);
|
||||
|
||||
extern List * PreprocessAlterDatabaseRefreshCollStmt(Node *node, const char *queryString,
|
||||
ProcessUtilityContext
|
||||
processUtilityContext);
|
||||
|
|
|
@ -224,8 +224,6 @@ extern char * DeparseAlterExtensionStmt(Node *stmt);
|
|||
extern char * DeparseAlterDatabaseOwnerStmt(Node *node);
|
||||
extern char * DeparseGrantOnDatabaseStmt(Node *node);
|
||||
extern char * DeparseAlterDatabaseStmt(Node *node);
|
||||
extern char * DeparseAlterDatabaseSetStmt(Node *node);
|
||||
extern char * DeparseAlterDatabaseRenameStmt(Node *node);
|
||||
extern char * DeparseAlterDatabaseRefreshCollStmt(Node *node);
|
||||
|
||||
/* forward declaration for deparse_publication_stmts.c */
|
||||
|
|
Loading…
Reference in New Issue