create_distributed_views
Onder Kalaci 2021-06-30 16:44:12 +02:00
parent 7df6a42a70
commit bd4a3a42bb
3 changed files with 16 additions and 22 deletions

View File

@ -690,6 +690,13 @@ GetDistributeObjectOps(Node *node)
} }
} }
case T_ViewStmt:
{
ViewStmt *stmt = castNode(ViewStmt, node);
return &NoDistributeOps;
}
case T_AlterOwnerStmt: case T_AlterOwnerStmt:
{ {
AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node); AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node);

View File

@ -603,36 +603,25 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
"rename the role"))); "rename the role")));
} }
if (IsA(parsetree, ViewStmt)) if (IsA(parsetree, ViewStmt))
{ {
CommandCounterIncrement(); ViewStmt *v = (ViewStmt *) parsetree;
elog(INFO, "create view");
ViewStmt *v = (ViewStmt *)parsetree; Oid viewOid = RangeVarGetRelid(v->view, AccessShareLock, false);
Oid viewOid = RangeVarGetRelid(v->view, NoLock, false);
elog(INFO, "viewOid: %d", viewOid);
/* TODO: check the view depends on a distributed table that we should sync */ /* TODO: check the view depends on a distributed table that we should sync */
if (ClusterHasKnownMetadataWorkers()) if (ClusterHasKnownMetadataWorkers() && IsCoordinator())
{ {
/* /*
* Ensure that the views are also propagated to the metadata workers * Ensure that the views are also propagated to the metadata workers
*/ */
PropagateDependenciesOfViewList(list_make1_oid(viewOid)); PropagateDependenciesOfViewList(list_make1_oid(viewOid));
/* prevent recursive propagation */ /* TODO: this command fails*/
SendCommandToWorkersWithMetadata(DISABLE_DDL_PROPAGATION); char *viewDef = GetViewCreationCommand(viewOid);
SendCommandToWorkersWithMetadata(viewDef);
/* send the commands one by one */
{
char *viewDef = GetViewCreationCommand(viewOid);
elog(INFO, "viewDef: %s", viewDef);
SendCommandToWorkersWithMetadata(viewDef);
}
} }
} }
} }

View File

@ -321,6 +321,7 @@ SyncMetadataSnapshotToNode(WorkerNode *workerNode, bool raiseOnError)
} }
} }
#include "distributed/metadata/dependency.h" #include "distributed/metadata/dependency.h"
/* /*
@ -494,9 +495,6 @@ MetadataCreateCommands(void)
List *viewList = GetDependingViews(cacheEntry->relationId); List *viewList = GetDependingViews(cacheEntry->relationId);
PropagateDependenciesOfViewList(viewList); PropagateDependenciesOfViewList(viewList);
/* prevent recursive propagation */
SendCommandToWorkersWithMetadata(DISABLE_DDL_PROPAGATION);
/* send the commands one by one */ /* send the commands one by one */
Oid viewId; Oid viewId;
List *viewCommandList = NIL; List *viewCommandList = NIL;