ERROR: permission info at index 1 ....

From: tender wang <tndrwang(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ERROR: permission info at index 1 ....
Date: 2023-02-13 14:32:32
Message-ID: CAHewXNnnNySD_YcKNuFpQDV2gxWA7_YLWqHmYVcyoOYxn8kY2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,
After a61b1f74823c commit, below query reports error:

create table perm_test1(a int);
create table perm_test2(b int);
select subq.c0
from (select (select a from perm_test1 order by a limit 1) as c0, b as c1
from perm_test2 where false order by c0, c1) as subq where false;
ERROR: permission info at index 1 (with relid=16457) does not match
provided RTE (with relid=16460)

Below codes can fix this:

--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -512,11 +512,16 @@ flatten_rtes_walker(Node *node,
flatten_rtes_walker_context *cxt)
* Recurse into subselects. Must update cxt->query to this
query so
* that the rtable and rteperminfos correspond with each
other.
*/
+ Query *current_query = cxt->query;
+ bool result;
+
cxt->query = (Query *) node;
- return query_tree_walker((Query *) node,
+ result = query_tree_walker((Query *) node,

flatten_rtes_walker,
(void *)
cxt,

QTW_EXAMINE_RTES_BEFORE);
+ cxt->query = current_query;
+ return result;
}

regards, tender wang

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2023-02-13 14:59:13 [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans
Previous Message Jelte Fennema 2023-02-13 14:13:04 Re: [EXTERNAL] Re: [PATCH] Support using "all" for the db user in pg_ident.conf