Skip to content

Commit 73635b6

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 13503eb commit 73635b6

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
@@ -81,10 +81,6 @@ pgrowlocks(PG_FUNCTION_ARGS)
8181
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
8282
rel = relation_openrv(relrv, AccessShareLock);
8383

84-
if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)
85-
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
86-
errmsg("only heap AM is supported")));
87-
8884
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
8985
ereport(ERROR,
9086
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -96,6 +92,10 @@ pgrowlocks(PG_FUNCTION_ARGS)
9692
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
9793
errmsg("\"%s\" is not a table",
9894
RelationGetRelationName(rel))));
95+
else if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)
96+
ereport(ERROR,
97+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
98+
errmsg("only heap AM is supported")));
9999

100100
/*
101101
* check permissions: must have SELECT on table or be in

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy