Fix buggy recursion in flatten_rtes_walker().
Must save-and-restore the context we are modifying. Oversight in commit a61b1f748. Tender Wang Discussion: https://postgr.es/m/CAHewXNnnNySD_YcKNuFpQDV2gxWA7_YLWqHmYVcyoOYxn8kY2A@mail.gmail.com Discussion: https://postgr.es/m/20230212233711.GA1316@telsasoft.com
This commit is contained in:
parent
f50f029c49
commit
c7468c73f7
@ -536,11 +536,16 @@ flatten_rtes_walker(Node *node, flatten_rtes_walker_context *cxt)
|
|||||||
* Recurse into subselects. Must update cxt->query to this query so
|
* Recurse into subselects. Must update cxt->query to this query so
|
||||||
* that the rtable and rteperminfos correspond with each other.
|
* that the rtable and rteperminfos correspond with each other.
|
||||||
*/
|
*/
|
||||||
|
Query *save_query = cxt->query;
|
||||||
|
bool result;
|
||||||
|
|
||||||
cxt->query = (Query *) node;
|
cxt->query = (Query *) node;
|
||||||
return query_tree_walker((Query *) node,
|
result = query_tree_walker((Query *) node,
|
||||||
flatten_rtes_walker,
|
flatten_rtes_walker,
|
||||||
(void *) cxt,
|
(void *) cxt,
|
||||||
QTW_EXAMINE_RTES_BEFORE);
|
QTW_EXAMINE_RTES_BEFORE);
|
||||||
|
cxt->query = save_query;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return expression_tree_walker(node, flatten_rtes_walker,
|
return expression_tree_walker(node, flatten_rtes_walker,
|
||||||
(void *) cxt);
|
(void *) cxt);
|
||||||
|
@ -5569,6 +5569,18 @@ select atts.relid::regclass, s.* from pg_stats s join
|
|||||||
ERROR: column atts.relid does not exist
|
ERROR: column atts.relid does not exist
|
||||||
LINE 1: select atts.relid::regclass, s.* from pg_stats s join
|
LINE 1: select atts.relid::regclass, s.* from pg_stats s join
|
||||||
^
|
^
|
||||||
|
-- Test bug in rangetable flattening
|
||||||
|
explain (verbose, costs off)
|
||||||
|
select 1 from
|
||||||
|
(select * from int8_tbl where q1 <> (select 42) offset 0) ss
|
||||||
|
where false;
|
||||||
|
QUERY PLAN
|
||||||
|
--------------------------
|
||||||
|
Result
|
||||||
|
Output: 1
|
||||||
|
One-Time Filter: false
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Test LATERAL
|
-- Test LATERAL
|
||||||
--
|
--
|
||||||
|
@ -2086,6 +2086,12 @@ select atts.relid::regclass, s.* from pg_stats s join
|
|||||||
indexrelid from pg_index i) atts on atts.attnum = a.attnum where
|
indexrelid from pg_index i) atts on atts.attnum = a.attnum where
|
||||||
schemaname != 'pg_catalog';
|
schemaname != 'pg_catalog';
|
||||||
|
|
||||||
|
-- Test bug in rangetable flattening
|
||||||
|
explain (verbose, costs off)
|
||||||
|
select 1 from
|
||||||
|
(select * from int8_tbl where q1 <> (select 42) offset 0) ss
|
||||||
|
where false;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Test LATERAL
|
-- Test LATERAL
|
||||||
--
|
--
|
||||||
|
Loading…
x
Reference in New Issue
Block a user