Use CMDTAG_SELECT_COMPAT

CMDTAG_SELECT exists in PG12 hence defining a MACRO such as
CMDTAG_SELECT -> "SELECT" is not possible. I chose CMDTAG_SELECT_COMPAT
because with the COMPAT suffix it is explicit that it maps to different
things in different versions and also has a less chance of mapping
something irrevelant. For example if we used SELECT as a macro, then it
would map every SELECT to whatever it is mapping to, which might have
unexpected/undesired behaviour.
pull/3900/head
Sait Talha Nisanci 2020-07-24 13:08:21 +03:00
parent d68bfc5687
commit b641f63bfd
6 changed files with 16 additions and 16 deletions

View File

@ -2821,8 +2821,8 @@ ProcessCopyStmt(CopyStmt *copyStatement, QueryCompletionCompat *completionTag, c
/* consider using RangeVarGetRelidExtended to check perms before locking */
Relation copiedRelation = table_openrv(copyStatement->relation,
isFrom ? RowExclusiveLock :
AccessShareLock);
isFrom ? RowExclusiveLock :
AccessShareLock);
bool isCitusRelation = IsCitusTable(RelationGetRelid(copiedRelation));

View File

@ -628,11 +628,12 @@ ExecutePlanIntoDestReceiver(PlannedStmt *queryPlan, ParamListInfo params,
/* don't display the portal in pg_cursors, it is for internal use only */
portal->visible = false;
PortalDefineQuerySelectCompat(portal,
NULL,
"",
list_make1(queryPlan),
NULL);
PortalDefineQuery(portal,
NULL,
"",
CMDTAG_SELECT_COMPAT,
list_make1(queryPlan),
NULL);
PortalStart(portal, params, eflags, GetActiveSnapshot());
PortalRun(portal, count, false, true, dest, dest, NULL);

View File

@ -266,7 +266,8 @@ StartPortalForQueryExecution(const char *queryString)
/* don't display the portal in pg_cursors, it is for internal use only */
portal->visible = false;
PortalDefineQuerySelectCompat(portal, NULL, queryString, list_make1(queryPlan), NULL);
PortalDefineQuery(portal, NULL, queryString, CMDTAG_SELECT_COMPAT, list_make1(
queryPlan), NULL);
int eflags = 0;
PortalStart(portal, NULL, eflags, GetActiveSnapshot());

View File

@ -634,7 +634,7 @@ NodeGroupHasShardPlacements(int32 groupId, bool onlyConsiderActivePlacements)
ScanKeyData scanKey[2];
Relation pgPlacement = table_open(DistPlacementRelationId(),
AccessShareLock);
AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_dist_placement_groupid,
BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(groupId));

View File

@ -95,7 +95,8 @@ LogTransactionRecord(int32 groupId, char *transactionName)
values[Anum_pg_dist_transaction_gid - 1] = CStringGetTextDatum(transactionName);
/* open transaction relation and insert new tuple */
Relation pgDistTransaction = table_open(DistTransactionRelationId(), RowExclusiveLock);
Relation pgDistTransaction = table_open(DistTransactionRelationId(),
RowExclusiveLock);
TupleDesc tupleDescriptor = RelationGetDescr(pgDistTransaction);
HeapTuple heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
@ -172,7 +173,7 @@ RecoverWorkerTransactions(WorkerNode *workerNode)
/* take table lock first to avoid running concurrently */
Relation pgDistTransaction = table_open(DistTransactionRelationId(),
ShareUpdateExclusiveLock);
ShareUpdateExclusiveLock);
TupleDesc tupleDescriptor = RelationGetDescr(pgDistTransaction);
/*

View File

@ -34,10 +34,8 @@
#define pg_plan_query_compat(p, q, c, b) pg_plan_query(p, q, c, b)
#define planner_compat(p, c, b) planner(p, NULL, c, b)
#define standard_planner_compat(a, c, d) standard_planner(a, NULL, c, d)
#define PortalDefineQuerySelectCompat(a, b, c, d, e) PortalDefineQuery(a, b, c, \
CMDTAG_SELECT, d, \
e)
#define getOwnedSequencesCompat(a, b) getOwnedSequences(a)
#define CMDTAG_SELECT_COMPAT CMDTAG_SELECT
#define ExplainOnePlanCompat(a, b, c, d, e, f, g) ExplainOnePlan(a, b, c, d, e, f, g, \
NULL)
#define varoattno varattnosyn
@ -51,8 +49,7 @@
#define pg_plan_query_compat(p, q, c, b) pg_plan_query(p, c, b)
#define planner_compat(p, c, b) planner(p, c, b)
#define standard_planner_compat(a, c, d) standard_planner(a, c, d)
#define PortalDefineQuerySelectCompat(a, b, c, d, e) PortalDefineQuery(a, b, c, "SELECT", \
d, e)
#define CMDTAG_SELECT_COMPAT "SELECT"
#define getOwnedSequencesCompat(a, b) getOwnedSequences(a, b)
#define ExplainOnePlanCompat(a, b, c, d, e, f, g) ExplainOnePlan(a, b, c, d, e, f, g)
#define Set_ptr_value(a, b) ((a)->data.ptr_value = (b))