Support schema elements in CREATE SCHEMA statements

pull/5786/head
Ahmet Gedemenli 2022-03-10 16:02:35 +03:00
parent 4312486141
commit 6eb8e6cce1
2 changed files with 17 additions and 5 deletions

View File

@ -44,6 +44,7 @@ static ObjectAddress GetObjectAddressBySchemaName(char *schemaName, bool missing
static List * FilterDistributedSchemas(List *schemas);
static bool SchemaHasDistributedTableWithFKey(char *schemaName);
static bool ShouldPropagateCreateSchemaStmt(void);
static void NoticeIfCreateSchemaStmtHasSchemaElements(Node *node);
/*
@ -63,6 +64,8 @@ PreprocessCreateSchemaStmt(Node *node, const char *queryString,
EnsureSequentialMode(OBJECT_SCHEMA);
NoticeIfCreateSchemaStmtHasSchemaElements(node);
/* deparse sql*/
const char *sql = DeparseTreeNode(node);
@ -392,3 +395,17 @@ ShouldPropagateCreateSchemaStmt()
return true;
}
static void
NoticeIfCreateSchemaStmtHasSchemaElements(Node *node)
{
CreateSchemaStmt *stmt = castNode(CreateSchemaStmt, node);
if (list_length(stmt->schemaElts) > 0)
{
ereport(NOTICE, (errmsg("schema elements will not be distributed"),
errdetail("Citus does not propagate other CREATE commands in "
"CREATE SCHEMA statements")));
}
}

View File

@ -87,11 +87,6 @@ DeparseAlterSchemaRenameStmt(Node *node)
static void
AppendCreateSchemaStmt(StringInfo buf, CreateSchemaStmt *stmt)
{
if (stmt->schemaElts != NIL)
{
elog(ERROR, "schema creating is not supported with other create commands");
}
appendStringInfoString(buf, "CREATE SCHEMA ");
if (stmt->if_not_exists)