From 46c6630328f5a14f5e904599fb06befa4d8331f2 Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Mon, 21 Mar 2022 13:55:09 +0300 Subject: [PATCH] Qualify CREATE AGGREGATE stmts in Preprocess (#5834) --- src/backend/distributed/commands/aggregate.c | 16 ++++++++++++++-- .../distributed/commands/distribute_object_ops.c | 2 +- src/include/distributed/commands.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/commands/aggregate.c b/src/backend/distributed/commands/aggregate.c index f6161df49..3e6de88e5 100644 --- a/src/backend/distributed/commands/aggregate.c +++ b/src/backend/distributed/commands/aggregate.c @@ -22,6 +22,20 @@ #include "utils/lsyscache.h" +/* + * PreprocessDefineAggregateStmt only qualifies the node with schema name. + * We will handle the rest in the Postprocess phase. + */ +List * +PreprocessDefineAggregateStmt(Node *node, const char *queryString, + ProcessUtilityContext processUtilityContext) +{ + QualifyTreeNode((Node *) node); + + return NIL; +} + + /* * PostprocessDefineAggregateStmt actually creates the plan we need to execute for * aggregate propagation. @@ -37,8 +51,6 @@ List * PostprocessDefineAggregateStmt(Node *node, const char *queryString) { - QualifyTreeNode((Node *) node); - DefineStmt *stmt = castNode(DefineStmt, node); if (!ShouldPropagate()) diff --git a/src/backend/distributed/commands/distribute_object_ops.c b/src/backend/distributed/commands/distribute_object_ops.c index ce4f70f7d..800392081 100644 --- a/src/backend/distributed/commands/distribute_object_ops.c +++ b/src/backend/distributed/commands/distribute_object_ops.c @@ -44,7 +44,7 @@ static DistributeObjectOps Aggregate_AlterOwner = { static DistributeObjectOps Aggregate_Define = { .deparse = NULL, .qualify = QualifyDefineAggregateStmt, - .preprocess = NULL, + .preprocess = PreprocessDefineAggregateStmt, .postprocess = PostprocessDefineAggregateStmt, .address = DefineAggregateStmtObjectAddress, .markDistributed = true, diff --git a/src/include/distributed/commands.h b/src/include/distributed/commands.h index 342692f47..ef22bbb63 100644 --- a/src/include/distributed/commands.h +++ b/src/include/distributed/commands.h @@ -123,6 +123,8 @@ typedef enum SearchForeignKeyColumnFlags /* aggregate.c - forward declarations */ +extern List * PreprocessDefineAggregateStmt(Node *node, const char *queryString, + ProcessUtilityContext processUtilityContext); extern List * PostprocessDefineAggregateStmt(Node *node, const char *queryString); /* cluster.c - forward declarations */