mirror of https://github.com/citusdata/citus.git
introduce planner_compat and pg_plan_query_compat macros
As the new planner and pg_plan_query_compat methods expect the query string as well, macros are defined to be compatible in different versions of postgres. Relevant commit on Postgres: 6aba63ef3e606db71beb596210dd95fa73c44ce2 Command on Postgres: git log --all --grep="pg_plan_query"pull/3900/head
parent
bf831d2e59
commit
62879ee8c1
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) &&
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue