Convert NoLock heap opens to AccessShareLock.

Postgres 12 has added bunch of assertions to disallow NoLock
heap opens.
read_write_etc
Hadi Moshayedi 2019-07-19 11:12:51 -07:00
parent 3ff736aa57
commit 15ade3b715
3 changed files with 6 additions and 3 deletions

View File

@ -67,7 +67,7 @@ ErrorIfUnsupportedTruncateStmt(TruncateStmt *truncateStatement)
foreach(relationCell, relationList)
{
RangeVar *rangeVar = (RangeVar *) lfirst(relationCell);
Oid relationId = RangeVarGetRelid(rangeVar, NoLock, true);
Oid relationId = RangeVarGetRelid(rangeVar, AccessShareLock, true);
char relationKind = get_rel_relkind(relationId);
if (IsDistributedTable(relationId) &&
relationKind == RELKIND_FOREIGN_TABLE)
@ -94,7 +94,7 @@ EnsurePartitionTableNotReplicatedForTruncate(TruncateStmt *truncateStatement)
foreach(relationCell, truncateStatement->relations)
{
RangeVar *relationRV = (RangeVar *) lfirst(relationCell);
Relation relation = heap_openrv(relationRV, NoLock);
Relation relation = heap_openrv(relationRV, AccessShareLock);
Oid relationId = RelationGetRelid(relation);
if (!IsDistributedTable(relationId))

View File

@ -66,7 +66,7 @@ PartitionedTable(Oid relationId)
bool
PartitionedTableNoLock(Oid relationId)
{
Relation rel = try_relation_open(relationId, NoLock);
Relation rel = try_relation_open(relationId, AccessShareLock);
bool partitionedTable = false;
/* don't error out for tables that are dropped */

View File

@ -1333,6 +1333,8 @@ DeleteNodeRow(char *nodeName, int32 nodePort)
ScanKeyData scanKey[2];
Relation pgDistNode = heap_open(DistNodeRelationId(), RowExclusiveLock);
Relation identityIdx = index_open(RelationGetReplicaIndex(pgDistNode),
AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_dist_node_nodename,
BTEqualStrategyNumber, F_TEXTEQ, CStringGetTextDatum(nodeName));
@ -1360,6 +1362,7 @@ DeleteNodeRow(char *nodeName, int32 nodePort)
/* increment the counter so that next command won't see the row */
CommandCounterIncrement();
heap_close(identityIdx, NoLock);
heap_close(pgDistNode, NoLock);
}