diff --git a/src/backend/distributed/executor/local_executor.c b/src/backend/distributed/executor/local_executor.c index 0b590e629..d7b5d24b9 100644 --- a/src/backend/distributed/executor/local_executor.c +++ b/src/backend/distributed/executor/local_executor.c @@ -94,6 +94,7 @@ #include "distributed/relation_access_tracking.h" #include "distributed/remote_commands.h" /* to access LogRemoteCommands */ #include "distributed/transaction_management.h" +#include "distributed/version_compat.h" #include "distributed/worker_protocol.h" #include "executor/tstoreReceiver.h" #include "executor/tuptable.h" @@ -293,7 +294,7 @@ ExecuteLocalTaskListExtended(List *taskList, * implemented. So, let planner to call distributed_planner() which * eventually calls standard_planner(). */ - localPlan = planner(shardQuery, cursorOptions, paramListInfo); + localPlan = planner_compat(shardQuery, NULL, cursorOptions, paramListInfo); } char *shardQueryString = NULL; @@ -333,7 +334,7 @@ LocallyPlanAndExecuteMultipleQueries(List *queryStrings, TupleDestination *tuple 0); int cursorOptions = 0; ParamListInfo paramListInfo = NULL; - PlannedStmt *localPlan = planner(shardQuery, cursorOptions, paramListInfo); + PlannedStmt *localPlan = planner_compat(shardQuery, NULL, cursorOptions, paramListInfo); totalProcessedRows += ExecuteLocalTaskPlan(localPlan, queryString, tupleDest, task, paramListInfo); diff --git a/src/backend/distributed/executor/multi_executor.c b/src/backend/distributed/executor/multi_executor.c index c4657ccf5..7c3395404 100644 --- a/src/backend/distributed/executor/multi_executor.c +++ b/src/backend/distributed/executor/multi_executor.c @@ -32,6 +32,7 @@ #include "distributed/multi_server_executor.h" #include "distributed/resource_lock.h" #include "distributed/transaction_management.h" +#include "distributed/version_compat.h" #include "distributed/worker_shard_visibility.h" #include "distributed/worker_protocol.h" #include "executor/execdebug.h" @@ -604,7 +605,7 @@ ExecuteQueryIntoDestReceiver(Query *query, ParamListInfo params, DestReceiver *d } /* plan the subquery, this may be another distributed query */ - PlannedStmt *queryPlan = pg_plan_query(query, cursorOptions, params); + PlannedStmt *queryPlan = pg_plan_query_compat(query, NULL, cursorOptions, params); ExecutePlanIntoDestReceiver(queryPlan, params, dest); } diff --git a/src/backend/distributed/executor/partitioned_intermediate_results.c b/src/backend/distributed/executor/partitioned_intermediate_results.c index 781bc0823..b08028040 100644 --- a/src/backend/distributed/executor/partitioned_intermediate_results.c +++ b/src/backend/distributed/executor/partitioned_intermediate_results.c @@ -26,6 +26,7 @@ #include "distributed/pg_dist_shard.h" #include "distributed/remote_commands.h" #include "distributed/tuplestore.h" +#include "distributed/version_compat.h" #include "distributed/worker_protocol.h" #include "nodes/makefuncs.h" #include "nodes/primnodes.h" @@ -258,7 +259,7 @@ StartPortalForQueryExecution(const char *queryString) Query *query = ParseQueryString(queryString, NULL, 0); int cursorOptions = CURSOR_OPT_PARALLEL_OK; - PlannedStmt *queryPlan = pg_plan_query(query, cursorOptions, NULL); + PlannedStmt *queryPlan = pg_plan_query_compat(query, NULL, cursorOptions, NULL); Portal portal = CreateNewPortal(); diff --git a/src/backend/distributed/planner/insert_select_planner.c b/src/backend/distributed/planner/insert_select_planner.c index aad31a2f0..67037916b 100644 --- a/src/backend/distributed/planner/insert_select_planner.c +++ b/src/backend/distributed/planner/insert_select_planner.c @@ -1388,7 +1388,7 @@ CreateNonPushableInsertSelectPlan(uint64 planId, Query *parse, ParamListInfo bou /* plan the subquery, this may be another distributed query */ int cursorOptions = CURSOR_OPT_PARALLEL_OK; - PlannedStmt *selectPlan = pg_plan_query(selectQueryCopy, cursorOptions, + PlannedStmt *selectPlan = pg_plan_query_compat(selectQueryCopy, NULL, cursorOptions, boundParams); bool repartitioned = IsRedistributablePlan(selectPlan->planTree) && diff --git a/src/backend/distributed/planner/local_plan_cache.c b/src/backend/distributed/planner/local_plan_cache.c index 881693e64..380cb0952 100644 --- a/src/backend/distributed/planner/local_plan_cache.c +++ b/src/backend/distributed/planner/local_plan_cache.c @@ -17,6 +17,7 @@ #include "distributed/deparse_shard_query.h" #include "distributed/citus_ruleutils.h" #include "distributed/metadata_cache.h" +#include "distributed/version_compat.h" #if PG_VERSION_NUM >= PG_VERSION_12 #include "optimizer/optimizer.h" #else @@ -89,7 +90,7 @@ CacheLocalPlanForShardQuery(Task *task, DistributedPlan *originalDistributedPlan LockRelationOid(rangeTableEntry->relid, lockMode); LocalPlannedStatement *localPlannedStatement = CitusMakeNode(LocalPlannedStatement); - localPlan = planner(shardQuery, 0, NULL); + localPlan = planner_compat(shardQuery, NULL, 0, NULL); localPlannedStatement->localPlan = localPlan; localPlannedStatement->shardId = task->anchorShardId; localPlannedStatement->localGroupId = GetLocalGroupId(); diff --git a/src/backend/distributed/planner/multi_explain.c b/src/backend/distributed/planner/multi_explain.c index 13082b2ca..9b0cc1e2f 100644 --- a/src/backend/distributed/planner/multi_explain.c +++ b/src/backend/distributed/planner/multi_explain.c @@ -1457,7 +1457,7 @@ ExplainOneQuery(Query *query, int cursorOptions, INSTR_TIME_SET_CURRENT(planstart); /* plan the query */ - PlannedStmt *plan = pg_plan_query(query, cursorOptions, params); + PlannedStmt *plan = pg_plan_query_compat(query, NULL, cursorOptions, params); INSTR_TIME_SET_CURRENT(planduration); INSTR_TIME_SUBTRACT(planduration, planstart); diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index 71f396fce..d1c07adb1 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -1174,7 +1174,7 @@ CreateDistributedSubPlan(uint32 subPlanId, Query *subPlanQuery) } DistributedSubPlan *subPlan = CitusMakeNode(DistributedSubPlan); - subPlan->plan = planner(subPlanQuery, cursorOptions, NULL); + subPlan->plan = planner_compat(subPlanQuery, NULL, cursorOptions, NULL); subPlan->subPlanId = subPlanId; return subPlan; diff --git a/src/backend/distributed/test/distributed_intermediate_results.c b/src/backend/distributed/test/distributed_intermediate_results.c index 7a095504a..474403d3e 100644 --- a/src/backend/distributed/test/distributed_intermediate_results.c +++ b/src/backend/distributed/test/distributed_intermediate_results.c @@ -27,6 +27,7 @@ #include "distributed/remote_commands.h" #include "distributed/tuplestore.h" #include "distributed/listutils.h" +#include "distributed/version_compat.h" #include "tcop/tcopprot.h" PG_FUNCTION_INFO_V1(partition_task_list_results); @@ -49,7 +50,7 @@ partition_task_list_results(PG_FUNCTION_ARGS) bool binaryFormat = PG_GETARG_BOOL(3); Query *parsedQuery = ParseQueryString(queryString, NULL, 0); - PlannedStmt *queryPlan = pg_plan_query(parsedQuery, + PlannedStmt *queryPlan = pg_plan_query_compat(parsedQuery, queryString, CURSOR_OPT_PARALLEL_OK, NULL); if (!IsCitusCustomScan(queryPlan->planTree)) @@ -122,7 +123,7 @@ redistribute_task_list_results(PG_FUNCTION_ARGS) bool binaryFormat = PG_GETARG_BOOL(3); Query *parsedQuery = ParseQueryString(queryString, NULL, 0); - PlannedStmt *queryPlan = pg_plan_query(parsedQuery, + PlannedStmt *queryPlan = pg_plan_query_compat(parsedQuery, queryString, CURSOR_OPT_PARALLEL_OK, NULL); if (!IsCitusCustomScan(queryPlan->planTree)) diff --git a/src/include/distributed/deparser.h b/src/include/distributed/deparser.h index 527d806bb..590391f31 100644 --- a/src/include/distributed/deparser.h +++ b/src/include/distributed/deparser.h @@ -18,6 +18,7 @@ #include "nodes/nodes.h" #include "nodes/parsenodes.h" #include "catalog/objectaddress.h" +#include "lib/stringinfo.h" /* forward declarations for format_collate.c */ /* Control flags for FormatCollateExtended, compatible with format_type_extended */ diff --git a/src/include/distributed/version_compat.h b/src/include/distributed/version_compat.h index 1004349a2..ca343a652 100644 --- a/src/include/distributed/version_compat.h +++ b/src/include/distributed/version_compat.h @@ -27,9 +27,13 @@ #if PG_VERSION_NUM >= PG_VERSION_13 #define lnext_compat(l, r) lnext(l, r) #define list_delete_cell_compat(l,c,p) list_delete_cell(l,c) +#define pg_plan_query_compat(p,q,c,b) pg_plan_query(p,q,c,b) +#define planner_compat(p,q,c,b) planner(p,q,c,b) #else /* pre PG13 */ #define lnext_compat(l, r) lnext(r) #define list_delete_cell_compat(l,c,p) list_delete_cell(l,c,p) +#define pg_plan_query_compat(p,q,c,b) pg_plan_query(p,c,b) +#define planner_compat(p,q,c,b) planner(p,c,b) #endif #if PG_VERSION_NUM >= PG_VERSION_12