mirror of https://github.com/citusdata/citus.git
Create GetViewCreationTableDDLCommandsOfTable
parent
1b39051aef
commit
73a600c203
|
@ -573,8 +573,9 @@ ConvertTable(TableConversionState *con)
|
||||||
List *justBeforeDropCommands = NIL;
|
List *justBeforeDropCommands = NIL;
|
||||||
List *attachPartitionCommands = NIL;
|
List *attachPartitionCommands = NIL;
|
||||||
|
|
||||||
postLoadCommands = list_concat(postLoadCommands,
|
postLoadCommands =
|
||||||
GetViewCreationCommandsOfTable(con->relationId, true));
|
list_concat(postLoadCommands,
|
||||||
|
GetViewCreationTableDDLCommandsOfTable(con->relationId));
|
||||||
|
|
||||||
List *foreignKeyCommands = NIL;
|
List *foreignKeyCommands = NIL;
|
||||||
if (con->conversionType == ALTER_DISTRIBUTED_TABLE)
|
if (con->conversionType == ALTER_DISTRIBUTED_TABLE)
|
||||||
|
@ -1255,7 +1256,7 @@ CreateCitusTableLike(TableConversionState *con)
|
||||||
* that recursively depend on the table too.
|
* that recursively depend on the table too.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
GetViewCreationCommandsOfTable(Oid relationId, bool asTableDDLCommand)
|
GetViewCreationCommandsOfTable(Oid relationId)
|
||||||
{
|
{
|
||||||
List *views = GetDependingViews(relationId);
|
List *views = GetDependingViews(relationId);
|
||||||
List *commands = NIL;
|
List *commands = NIL;
|
||||||
|
@ -1280,20 +1281,33 @@ GetViewCreationCommandsOfTable(Oid relationId, bool asTableDDLCommand)
|
||||||
char *alterViewCommmand = AlterViewOwnerCommand(viewOid);
|
char *alterViewCommmand = AlterViewOwnerCommand(viewOid);
|
||||||
appendStringInfoString(query, alterViewCommmand);
|
appendStringInfoString(query, alterViewCommmand);
|
||||||
|
|
||||||
if (asTableDDLCommand)
|
|
||||||
{
|
|
||||||
commands = lappend(commands, makeTableDDLCommandString(query->data));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
commands = lappend(commands, query->data);
|
commands = lappend(commands, query->data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GetViewCreationTableDDLCommandsOfTable is the same as GetViewCreationCommandsOfTable,
|
||||||
|
* but the returned list includes objects of TableDDLCommand's, not strings.
|
||||||
|
*/
|
||||||
|
List *
|
||||||
|
GetViewCreationTableDDLCommandsOfTable(Oid relationId)
|
||||||
|
{
|
||||||
|
List *commands = GetViewCreationCommandsOfTable(relationId);
|
||||||
|
List *tableDDLCommands = NIL;
|
||||||
|
|
||||||
|
char *command = NULL;
|
||||||
|
foreach_ptr(command, commands)
|
||||||
|
{
|
||||||
|
tableDDLCommands = lappend(tableDDLCommands, makeTableDDLCommandString(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tableDDLCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CreateMaterializedViewDDLCommand creates the command to create materialized view.
|
* CreateMaterializedViewDDLCommand creates the command to create materialized view.
|
||||||
* Note that this function doesn't support
|
* Note that this function doesn't support
|
||||||
|
|
|
@ -329,7 +329,7 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys, bool autoConve
|
||||||
EnsureReferenceTablesExistOnAllNodes();
|
EnsureReferenceTablesExistOnAllNodes();
|
||||||
|
|
||||||
List *shellTableDDLEvents = GetShellTableDDLEventsForCitusLocalTable(relationId);
|
List *shellTableDDLEvents = GetShellTableDDLEventsForCitusLocalTable(relationId);
|
||||||
List *tableViewCreationCommands = GetViewCreationCommandsOfTable(relationId, false);
|
List *tableViewCreationCommands = GetViewCreationCommandsOfTable(relationId);
|
||||||
|
|
||||||
char *relationName = get_rel_name(relationId);
|
char *relationName = get_rel_name(relationId);
|
||||||
Oid relationSchemaId = get_rel_namespace(relationId);
|
Oid relationSchemaId = get_rel_namespace(relationId);
|
||||||
|
|
|
@ -534,7 +534,8 @@ extern ObjectAddress AlterViewStmtObjectAddress(Node *node, bool missing_ok);
|
||||||
extern List * PreprocessDropViewStmt(Node *node, const char *queryString,
|
extern List * PreprocessDropViewStmt(Node *node, const char *queryString,
|
||||||
ProcessUtilityContext processUtilityContext);
|
ProcessUtilityContext processUtilityContext);
|
||||||
extern char * CreateViewDDLCommand(Oid viewOid);
|
extern char * CreateViewDDLCommand(Oid viewOid);
|
||||||
extern List * GetViewCreationCommandsOfTable(Oid relationId, bool asTableDDLCommand);
|
extern List * GetViewCreationCommandsOfTable(Oid relationId);
|
||||||
|
extern List * GetViewCreationTableDDLCommandsOfTable(Oid relationId);
|
||||||
extern char * AlterViewOwnerCommand(Oid viewOid);
|
extern char * AlterViewOwnerCommand(Oid viewOid);
|
||||||
extern char * DeparseViewStmt(Node *node);
|
extern char * DeparseViewStmt(Node *node);
|
||||||
extern char * DeparseDropViewStmt(Node *node);
|
extern char * DeparseDropViewStmt(Node *node);
|
||||||
|
|
|
@ -574,6 +574,7 @@ BEGIN;
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE table_2_to_view_in_transaction(a int);
|
CREATE TABLE table_2_to_view_in_transaction(a int);
|
||||||
SELECT create_distributed_table('table_2_to_view_in_transaction', 'a');
|
SELECT create_distributed_table('table_2_to_view_in_transaction', 'a');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
|
|
Loading…
Reference in New Issue