From 4e2dd2274e03283eb800ba751ca163cbfd4d9bfe Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Fri, 13 Aug 2021 15:32:18 +0300 Subject: [PATCH] Introduces CopyFromState_compat macro CopyState struct is divided into parts and one of them is CopyFromState This macro uses the appropriate one for PG versions Relevant PG commit: c532d15dddff14b01fe9ef1d465013cb8ef186df --- src/backend/distributed/commands/local_multi_copy.c | 2 +- src/backend/distributed/commands/multi_copy.c | 4 ++-- src/backend/distributed/executor/multi_executor.c | 2 +- src/include/distributed/version_compat.h | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backend/distributed/commands/local_multi_copy.c b/src/backend/distributed/commands/local_multi_copy.c index ca532ef70..f5fa6abb7 100644 --- a/src/backend/distributed/commands/local_multi_copy.c +++ b/src/backend/distributed/commands/local_multi_copy.c @@ -213,7 +213,7 @@ DoLocalCopy(StringInfo buffer, Oid relationId, int64 shardId, CopyStmt *copyStat /* p_rtable of pState is set so that we can check constraints. */ pState->p_rtable = CreateRangeTable(shard, ACL_INSERT); - CopyState cstate = BeginCopyFrom(pState, shard, NULL, false, + CopyFromState_compat cstate = BeginCopyFrom(pState, shard, NULL, false, ReadFromLocalBufferCallback, copyStatement->attlist, copyStatement->options); CopyFrom(cstate); diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index 98449d0d3..ad597a11d 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -520,7 +520,7 @@ CopyToExistingShards(CopyStmt *copyStatement, QueryCompletionCompat *completionT } /* initialize copy state to read from COPY data source */ - CopyState copyState = BeginCopyFrom(NULL, + CopyFromState_compat copyState = BeginCopyFrom(NULL, copiedDistributedRelation, copyStatement->filename, copyStatement->is_program, @@ -617,7 +617,7 @@ CopyToNewShards(CopyStmt *copyStatement, QueryCompletionCompat *completionTag, O (ShardConnections *) palloc0(sizeof(ShardConnections)); /* initialize copy state to read from COPY data source */ - CopyState copyState = BeginCopyFrom(NULL, + CopyFromState_compat copyState = BeginCopyFrom(NULL, distributedRelation, copyStatement->filename, copyStatement->is_program, diff --git a/src/backend/distributed/executor/multi_executor.c b/src/backend/distributed/executor/multi_executor.c index 121766a02..65f2a718b 100644 --- a/src/backend/distributed/executor/multi_executor.c +++ b/src/backend/distributed/executor/multi_executor.c @@ -410,7 +410,7 @@ ReadFileIntoTupleStore(char *fileName, char *copyFormat, TupleDesc tupleDescript location); copyOptions = lappend(copyOptions, copyOption); - CopyState copyState = BeginCopyFrom(NULL, stubRelation, fileName, false, NULL, + CopyFromState_compat copyState = BeginCopyFrom(NULL, stubRelation, fileName, false, NULL, NULL, copyOptions); while (true) diff --git a/src/include/distributed/version_compat.h b/src/include/distributed/version_compat.h index 0694219be..994da5f2d 100644 --- a/src/include/distributed/version_compat.h +++ b/src/include/distributed/version_compat.h @@ -48,6 +48,7 @@ #define VACOPTVALUE_DISABLED_COMPAT VACOPTVALUE_DISABLED #define VACOPTVALUE_ENABLED_COMPAT VACOPTVALUE_ENABLED #define IsReindexWithParam_compat(reindex, param) IsReindexWithParam(reindex, param) +#define CopyFromState_compat CopyFromState #else #define AlterTableStmtObjType(a) ((a)->relkind) #define F_NEXTVAL_COMPAT F_NEXTVAL_OID @@ -69,6 +70,7 @@ ((strcmp(param, "concurrently") == 0) ? ((reindex)->concurrent) : \ ((strcmp(param, "verbose") == 0) ? ((reindex)->options == REINDEXOPT_VERBOSE) : \ false)) +#define CopyFromState_compat CopyState #endif #if PG_VERSION_NUM >= PG_VERSION_13