Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7468c7

Browse files
committed
Fix buggy recursion in flatten_rtes_walker().
Must save-and-restore the context we are modifying.Oversight in commita61b1f7.Tender WangDiscussion:https://postgr.es/m/CAHewXNnnNySD_YcKNuFpQDV2gxWA7_YLWqHmYVcyoOYxn8kY2A@mail.gmail.comDiscussion:https://postgr.es/m/20230212233711.GA1316@telsasoft.com
1 parentf50f029 commitc7468c7

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

‎src/backend/optimizer/plan/setrefs.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,16 @@ flatten_rtes_walker(Node *node, flatten_rtes_walker_context *cxt)
536536
* Recurse into subselects. Must update cxt->query to this query so
537537
* that the rtable and rteperminfos correspond with each other.
538538
*/
539+
Query*save_query=cxt->query;
540+
boolresult;
541+
539542
cxt->query= (Query*)node;
540-
returnquery_tree_walker((Query*)node,
541-
flatten_rtes_walker,
542-
(void*)cxt,
543-
QTW_EXAMINE_RTES_BEFORE);
543+
result=query_tree_walker((Query*)node,
544+
flatten_rtes_walker,
545+
(void*)cxt,
546+
QTW_EXAMINE_RTES_BEFORE);
547+
cxt->query=save_query;
548+
returnresult;
544549
}
545550
returnexpression_tree_walker(node,flatten_rtes_walker,
546551
(void*)cxt);

‎src/test/regress/expected/join.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5569,6 +5569,18 @@ select atts.relid::regclass, s.* from pg_stats s join
55695569
ERROR: column atts.relid does not exist
55705570
LINE 1: select atts.relid::regclass, s.* from pg_stats s join
55715571
^
5572+
-- Test bug in rangetable flattening
5573+
explain (verbose, costs off)
5574+
select 1 from
5575+
(select * from int8_tbl where q1 <> (select 42) offset 0) ss
5576+
where false;
5577+
QUERY PLAN
5578+
--------------------------
5579+
Result
5580+
Output: 1
5581+
One-Time Filter: false
5582+
(3 rows)
5583+
55725584
--
55735585
-- Test LATERAL
55745586
--

‎src/test/regress/sql/join.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,12 @@ select atts.relid::regclass, s.* from pg_stats s join
20862086
indexrelidfrom pg_index i) attsonatts.attnum=a.attnumwhere
20872087
schemaname!='pg_catalog';
20882088

2089+
-- Test bug in rangetable flattening
2090+
explain (verbose, costs off)
2091+
select1from
2092+
(select*from int8_tblwhere q1<> (select42) offset0) ss
2093+
where false;
2094+
20892095
--
20902096
-- Test LATERAL
20912097
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp