Skip to content

Commit 8c64622

Browse files

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/reader.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "nodes/parsenodes.h"
2323
#include "parser/parse_coerce.h"
2424
#include "pgstat.h"
25+
#include "storage/lmgr.h"
2526
#include "utils/builtins.h"
2627
#include "utils/lsyscache.h"
2728
#include "utils/memutils.h"
@@ -461,7 +462,15 @@ CheckerInit(Checker *checker, Relation rel, TupleChecker *tchecker)
461462
}
462463
#endif
463464

464-
#if PG_VERSION_NUM >= 160000
465+
#if PG_VERSION_NUM >= 180000
466+
/*
467+
* In PostgreSQL 18, ExecCheckPermissions() requires the relation to be locked.
468+
* Acquire an AccessShareLock before calling it and release the lock afterward.
469+
*/
470+
LockRelationOid(RelationGetRelid(rel), AccessShareLock);
471+
ExecCheckPermissions(range_table, perminfos, true);
472+
UnlockRelationOid(RelationGetRelid(rel), AccessShareLock);
473+
#elif PG_VERSION_NUM >= 160000
465474
ExecCheckPermissions(range_table, perminfos, true);
466475
#elif PG_VERSION_NUM >= 90100
467476
/* This API is published only from 9.1.

0 commit comments

Comments
 (0)