Add shard relation to pState in localCopy

CopyFrom expects an AccessShareLock on the table. Instead of adding an
explicit lock, we do it how postgres is doing, which is to use
addRangeTableEntryForRelation.

Commit:
c532d15dddff14b01fe9ef1d465013cb8ef186df
pg14_support_3
Sait Talha Nisanci 2021-08-19 15:03:49 +03:00
parent 19a61ad958
commit 5442882209
1 changed files with 2 additions and 4 deletions

View File

@ -209,10 +209,8 @@ DoLocalCopy(StringInfo buffer, Oid relationId, int64 shardId, CopyStmt *copyStat
Oid shardOid = GetTableLocalShardOid(relationId, shardId);
Relation shard = table_open(shardOid, RowExclusiveLock);
ParseState *pState = make_parsestate(NULL);
/* p_rtable of pState is set so that we can check constraints. */
pState->p_rtable = CreateRangeTable(shard, ACL_INSERT);
(void) addRangeTableEntryForRelation(pState, shard, AccessShareLock,
NULL, false, false);
CopyFromState_compat cstate = BeginCopyFrom_compat(pState, shard, NULL, NULL, false,
ReadFromLocalBufferCallback,
copyStatement->attlist,