mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Teach pgrowlocks to check relkind before scanning
Author: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
This commit is contained in:
@ -97,7 +97,19 @@ pgrowlocks(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
relname = PG_GETARG_TEXT_PP(0);
|
relname = PG_GETARG_TEXT_PP(0);
|
||||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
||||||
rel = heap_openrv(relrv, AccessShareLock);
|
rel = relation_openrv(relrv, AccessShareLock);
|
||||||
|
|
||||||
|
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg("\"%s\" is a partitioned table",
|
||||||
|
RelationGetRelationName(rel)),
|
||||||
|
errdetail("Partitioned tables do not contain rows.")));
|
||||||
|
else if (rel->rd_rel->relkind != RELKIND_RELATION)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg("\"%s\" is not a table",
|
||||||
|
RelationGetRelationName(rel))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check permissions: must have SELECT on table or be in
|
* check permissions: must have SELECT on table or be in
|
||||||
|
Reference in New Issue
Block a user