From 0f8cfaf8921fed35f0b92d918ce95eec7b46ff05 Mon Sep 17 00:00:00 2001 From: Amit Langote Date: Tue, 13 Jun 2023 12:52:47 +0900 Subject: Retain relkind too in RTE_SUBQUERY entries for views. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 47bb9db75 modified the ApplyRetrieveRule()'s conversion of a view's original RTE_RELATION entry into an RTE_SUBQUERY one to retain relid, rellockmode, and perminfoindex so that the executor can lock the view and check its permissions. It seems better to also retain relkind for cross-checking that the exception of an RTE_SUBQUERY entry being allowed to carry relation details only applies to views, so do so. Bump catversion because this changes the output format of RTE_SUBQUERY RTEs. Suggested-by: David Steele Reviewed-by: David Steele Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/3953179e-9540-e5d1-a743-4bef368785b0%40pgmasters.net --- src/backend/executor/execMain.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/backend/executor/execMain.c') diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index c76fdf59ec4..4c5a7bbf620 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -595,6 +595,15 @@ ExecCheckPermissions(List *rangeTable, List *rteperminfos, if (rte->perminfoindex != 0) { /* Sanity checks */ + + /* + * Only relation RTEs and subquery RTEs that were once relation + * RTEs (views) have their perminfoindex set. + */ + Assert(rte->rtekind == RTE_RELATION || + (rte->rtekind == RTE_SUBQUERY && + rte->relkind == RELKIND_VIEW)); + (void) getRTEPermissionInfo(rteperminfos, rte); /* Many-to-one mapping not allowed */ Assert(!bms_is_member(rte->perminfoindex, indexset)); -- cgit v1.2.3