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
pg14_support_after_rebase
Halil Ozan Akgul 2021-08-13 15:32:18 +03:00 committed by Sait Talha Nisanci
parent c19faedce6
commit 4e2dd2274e
4 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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)

View File

@ -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