fix full join cte level

This commit is contained in:
ganyang
2022-11-24 16:26:56 +08:00
parent 7010581709
commit ed2b402418
3 changed files with 44 additions and 1 deletions

View File

@ -3439,6 +3439,13 @@ static Node* reduce_inequality_fulljoins_jointree_recurse(PlannerInfo* root, Nod
IncrementVarSublevelsUp(j1->quals, 2, 1);
IncrementVarSublevelsUp(j2->quals, 2, 1);
/*
* Upper-level vars in subquery are now two level far to their parent
* than before.
*/
IncrementVarSublevelsUp((Node*)setop1, 2, 1);
IncrementVarSublevelsUp((Node*)setop2, 2, 1);
/* No quals in FromExpr. Search 'QUALS SHOULD BE HERE.' in this
* source code file.
*/

View File

@ -158,3 +158,22 @@ order by 1,2,3,4;
| | | | 2 | li | adjani | 2000 | 3 | li | adjani | 5000
(5 rows)
--CTE test
create table cte_test(w_zip text);
create table cte_test2(w_name text);
create table cte_test3(d_id text);
with alias1 as (select w_zip alias2 from cte_test) select w_name from cte_test2 union select d_id from cte_test3 full join alias1 on cte_test3.d_id>alias1.alias2;
w_name
--------
(0 rows)
-- CTE test with smp
set query_dop = 4;
with alias1 as (select w_zip alias2 from cte_test) select w_name from cte_test2 union select d_id from cte_test3 full join alias1 on cte_test3.d_id>alias1.alias2;
w_name
--------
(0 rows)
drop table cte_test;
drop table cte_test2;
drop table cte_test3;

View File

@ -99,4 +99,21 @@ join fulljointest t3 on case t3.c4 when 100 then 'low'
when 5000 then 'high'
when 2000 then 'medium'
end between 'high' and 'high'
order by 1,2,3,4;
order by 1,2,3,4;
--CTE test
create table cte_test(w_zip text);
create table cte_test2(w_name text);
create table cte_test3(d_id text);
with alias1 as (select w_zip alias2 from cte_test) select w_name from cte_test2 union select d_id from cte_test3 full join alias1 on cte_test3.d_id>alias1.alias2;
-- CTE test with smp
set query_dop = 4;
with alias1 as (select w_zip alias2 from cte_test) select w_name from cte_test2 union select d_id from cte_test3 full join alias1 on cte_test3.d_id>alias1.alias2;
drop table cte_test;
drop table cte_test2;
drop table cte_test3;