Skip to content

Commit 9d0f799

Browse files
committed
Use table/index_close() more consistently
All the code paths updated here have been using relation_close() to close a relation that has already been opened with table_open() or index_open(), where a relkind check is enforced. table_close() and index_open() do the same thing as relation_close(), so there was no harm, but being inconsistent could lead to issues if the internals of these close() functions begin to introduce some logic specific to each relkind in the future. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/aUKamYGiDKO6byp5@ip-10-97-1-34.eu-west-3.compute.internal
1 parent d49936f commit 9d0f799

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/backend/access/brin/brin.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,8 +1478,8 @@ brin_summarize_range(PG_FUNCTION_ARGS)
14781478
/* Restore userid and security context */
14791479
SetUserIdAndSecContext(save_userid, save_sec_context);
14801480

1481-
relation_close(indexRel, ShareUpdateExclusiveLock);
1482-
relation_close(heapRel, ShareUpdateExclusiveLock);
1481+
index_close(indexRel, ShareUpdateExclusiveLock);
1482+
table_close(heapRel, ShareUpdateExclusiveLock);
14831483

14841484
PG_RETURN_INT32((int32) numSummarized);
14851485
}
@@ -1568,8 +1568,8 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
15681568
errmsg("index \"%s\" is not valid",
15691569
RelationGetRelationName(indexRel))));
15701570

1571-
relation_close(indexRel, ShareUpdateExclusiveLock);
1572-
relation_close(heapRel, ShareUpdateExclusiveLock);
1571+
index_close(indexRel, ShareUpdateExclusiveLock);
1572+
table_close(heapRel, ShareUpdateExclusiveLock);
15731573

15741574
PG_RETURN_VOID();
15751575
}

src/backend/parser/parse_utilcmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
25722572
}
25732573

25742574
/* Close the index relation but keep the lock */
2575-
relation_close(index_rel, NoLock);
2575+
index_close(index_rel, NoLock);
25762576

25772577
index->indexOid = index_oid;
25782578
}

0 commit comments

Comments
 (0)