Skip to content

Commit efcb601

Browse files
committed
Adjust the order of the prechecks in pgrowlocks()
4b82664 added a precheck to pgrowlocks() to ensure the given object's pg_class.relam is HEAP_TABLE_AM_OID, however, that check was put before another check which was checking if the given object was a partitioned table. Since the pg_class.relam is always InvalidOid for partitioned tables, if pgrowlocks() was called passing a partitioned table, then the "only heap AM is supported" error would be raised instead of the intended error about the given object being a partitioned table. Here we simply move the pg_class.relam check to after the check that verifies that we are in fact working with a normal (non-partitioned) table. Reported-by: jian he Discussion: https://postgr.es/m/CACJufxFaSp_WguFCf0X98951zFVX+dXFnF1mxAb-G3g1HiHOow@mail.gmail.com Backpatch-through: 12, where 4b82664 was introduced.
1 parent 975ae05 commit efcb601

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/pgrowlocks/pgrowlocks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ pgrowlocks(PG_FUNCTION_ARGS)
107107
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
108108
rel = relation_openrv(relrv, AccessShareLock);
109109

110-
if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)
111-
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
112-
errmsg("only heap AM is supported")));
113-
114110
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
115111
ereport(ERROR,
116112
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -122,6 +118,10 @@ pgrowlocks(PG_FUNCTION_ARGS)
122118
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
123119
errmsg("\"%s\" is not a table",
124120
RelationGetRelationName(rel))));
121+
else if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)
122+
ereport(ERROR,
123+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
124+
errmsg("only heap AM is supported")));
125125

126126
/*
127127
* check permissions: must have SELECT on table or be in

0 commit comments

Comments
 (0)