Skip to content

Commit b56818a

Browse files
committed
Teach pgrowlocks to check relkind before scanning
Author: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
1 parent fb886c1 commit b56818a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

contrib/pgrowlocks/pgrowlocks.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ pgrowlocks(PG_FUNCTION_ARGS)
9797

9898
relname = PG_GETARG_TEXT_PP(0);
9999
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
100-
rel = heap_openrv(relrv, AccessShareLock);
100+
rel = relation_openrv(relrv, AccessShareLock);
101+
102+
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
103+
ereport(ERROR,
104+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
105+
errmsg("\"%s\" is a partitioned table",
106+
RelationGetRelationName(rel)),
107+
errdetail("Partitioned tables do not contain rows.")));
108+
else if (rel->rd_rel->relkind != RELKIND_RELATION)
109+
ereport(ERROR,
110+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
111+
errmsg("\"%s\" is not a table",
112+
RelationGetRelationName(rel))));
101113

102114
/*
103115
* 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