mirror of https://github.com/citusdata/citus.git
Do not drop and recreate materialized views while creating local table
parent
1ee3e8b7f4
commit
147a110917
|
@ -585,7 +585,7 @@ ConvertTable(TableConversionState *con)
|
||||||
|
|
||||||
postLoadCommands =
|
postLoadCommands =
|
||||||
list_concat(postLoadCommands,
|
list_concat(postLoadCommands,
|
||||||
GetViewCreationTableDDLCommandsOfTable(con->relationId));
|
GetViewCreationTableDDLCommandsOfTable(con->relationId, true));
|
||||||
|
|
||||||
List *foreignKeyCommands = NIL;
|
List *foreignKeyCommands = NIL;
|
||||||
if (con->conversionType == ALTER_DISTRIBUTED_TABLE)
|
if (con->conversionType == ALTER_DISTRIBUTED_TABLE)
|
||||||
|
@ -1354,7 +1354,7 @@ DoesCascadeDropUnsupportedObject(Oid classId, Oid objectId, HTAB *nodeMap)
|
||||||
* that recursively depend on the table too.
|
* that recursively depend on the table too.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
GetViewCreationCommandsOfTable(Oid relationId)
|
GetViewCreationCommandsOfTable(Oid relationId, bool includeMatViews)
|
||||||
{
|
{
|
||||||
List *views = GetDependingViews(relationId);
|
List *views = GetDependingViews(relationId);
|
||||||
List *commands = NIL;
|
List *commands = NIL;
|
||||||
|
@ -1367,6 +1367,11 @@ GetViewCreationCommandsOfTable(Oid relationId)
|
||||||
/* See comments on CreateMaterializedViewDDLCommand for its limitations */
|
/* See comments on CreateMaterializedViewDDLCommand for its limitations */
|
||||||
if (get_rel_relkind(viewOid) == RELKIND_MATVIEW)
|
if (get_rel_relkind(viewOid) == RELKIND_MATVIEW)
|
||||||
{
|
{
|
||||||
|
if (!includeMatViews)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char *matViewCreateCommands = CreateMaterializedViewDDLCommand(viewOid);
|
char *matViewCreateCommands = CreateMaterializedViewDDLCommand(viewOid);
|
||||||
appendStringInfoString(query, matViewCreateCommands);
|
appendStringInfoString(query, matViewCreateCommands);
|
||||||
}
|
}
|
||||||
|
@ -1391,9 +1396,9 @@ GetViewCreationCommandsOfTable(Oid relationId)
|
||||||
* but the returned list includes objects of TableDDLCommand's, not strings.
|
* but the returned list includes objects of TableDDLCommand's, not strings.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
GetViewCreationTableDDLCommandsOfTable(Oid relationId)
|
GetViewCreationTableDDLCommandsOfTable(Oid relationId, bool includeMatViews)
|
||||||
{
|
{
|
||||||
List *commands = GetViewCreationCommandsOfTable(relationId);
|
List *commands = GetViewCreationCommandsOfTable(relationId, includeMatViews);
|
||||||
List *tableDDLCommands = NIL;
|
List *tableDDLCommands = NIL;
|
||||||
|
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
|
|
|
@ -330,7 +330,7 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys, bool autoConve
|
||||||
EnsureReferenceTablesExistOnAllNodes();
|
EnsureReferenceTablesExistOnAllNodes();
|
||||||
|
|
||||||
List *shellTableDDLEvents = GetShellTableDDLEventsForCitusLocalTable(relationId);
|
List *shellTableDDLEvents = GetShellTableDDLEventsForCitusLocalTable(relationId);
|
||||||
List *tableViewCreationCommands = GetViewCreationCommandsOfTable(relationId);
|
List *tableViewCreationCommands = GetViewCreationCommandsOfTable(relationId, false);
|
||||||
|
|
||||||
char *relationName = get_rel_name(relationId);
|
char *relationName = get_rel_name(relationId);
|
||||||
Oid relationSchemaId = get_rel_namespace(relationId);
|
Oid relationSchemaId = get_rel_namespace(relationId);
|
||||||
|
@ -1053,8 +1053,16 @@ DropViewsOnTable(Oid relationId)
|
||||||
char *qualifiedViewName = quote_qualified_identifier(schemaName, viewName);
|
char *qualifiedViewName = quote_qualified_identifier(schemaName, viewName);
|
||||||
|
|
||||||
StringInfo dropCommand = makeStringInfo();
|
StringInfo dropCommand = makeStringInfo();
|
||||||
appendStringInfo(dropCommand, "DROP VIEW IF EXISTS %s",
|
if (get_rel_relkind(viewId) == RELKIND_MATVIEW)
|
||||||
qualifiedViewName);
|
{
|
||||||
|
/*
|
||||||
|
* Since materialized views are not supported with Citus right now,
|
||||||
|
* skip them
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
appendStringInfo(dropCommand, "DROP VIEW IF EXISTS %s", qualifiedViewName);
|
||||||
|
|
||||||
ExecuteAndLogUtilityCommand(dropCommand->data);
|
ExecuteAndLogUtilityCommand(dropCommand->data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -564,8 +564,9 @@ 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);
|
extern List * GetViewCreationCommandsOfTable(Oid relationId, bool includeMatViews);
|
||||||
extern List * GetViewCreationTableDDLCommandsOfTable(Oid relationId);
|
extern List * GetViewCreationTableDDLCommandsOfTable(Oid relationId, bool
|
||||||
|
includeMatViews);
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue