!4449 当join quals包含placeholdervar时,不重写fulljoin

Merge pull request !4449 from pengjiong/fix_case
This commit is contained in:
opengauss_bot
2023-11-24 01:55:34 +00:00
committed by Gitee
3 changed files with 47 additions and 0 deletions

View File

@ -1271,6 +1271,24 @@ static inline bool contain_system_column(Node *var_list)
return result;
}
static inline bool contain_placeholdervar(Node *var_list)
{
List* vars = pull_var_clause(var_list, PVC_RECURSE_AGGREGATES, PVC_INCLUDE_PLACEHOLDERS);
ListCell* lc = NULL;
bool result = false;
foreach (lc, vars) {
Node* var = (Node*)lfirst(lc);
if (IsA(var, PlaceHolderVar)) {
result = true;
break;
}
}
list_free_ext(vars);
return result;
}
/* --------------------
* subquery_planner
* Invokes the planner on a subquery. We recurse to here for each
@ -1833,6 +1851,10 @@ Plan* subquery_planner(PlannerGlobal* glob, Query* parse, PlannerInfo* parent_ro
support_rewrite = false;
break;
}
if (root->parse->jointree != NULL && contain_placeholdervar(root->parse->jointree->quals)) {
support_rewrite = false;
break;
}
if (!fulljoin_2_left_union_right_anti_support(root->parse)) {
support_rewrite = false;
break;

View File

@ -144,6 +144,27 @@ select left(alias8.w_zip ,alias8.w_id) as alias10,true alias11,dense_rank() over
drop table fulltest;
drop table fulltest2;
CREATE TABLE fj_table0 ( column32 INT , column36 INT ) ;
SELECT 1 FROM fj_table0 LEFT JOIN ( SELECT 1 column29 FROM fj_table0 FULL JOIN fj_table0 AS alias0 ON FALSE ) AS alias1 ON TRUE WHERE column29 = 1 ;
?column?
----------
(0 rows)
explain (costs off) SELECT 1 FROM fj_table0 LEFT JOIN ( SELECT 1 column29 FROM fj_table0 FULL JOIN fj_table0 AS alias0 ON FALSE ) AS alias1 ON TRUE WHERE column29 = 1 ;
QUERY PLAN
------------------------------------------------------
Nested Loop Left Join
Filter: ((1) = 1)
-> Seq Scan on fj_table0
-> Materialize
-> Merge Full Join
Join Filter: false
-> Seq Scan on fj_table0
-> Materialize
-> Seq Scan on fj_table0 alias0
(9 rows)
drop table fj_table0;
-- contain system column, don't rewrite full join
explain (costs off) select t1.oid from pg_class t1 full join pg_constraint t2 on t1.relname = t2.conname;
QUERY PLAN

View File

@ -49,6 +49,10 @@ select left(alias8.w_zip ,alias8.w_id) as alias10,true alias11,dense_rank() over
drop table fulltest;
drop table fulltest2;
CREATE TABLE fj_table0 ( column32 INT , column36 INT ) ;
SELECT 1 FROM fj_table0 LEFT JOIN ( SELECT 1 column29 FROM fj_table0 FULL JOIN fj_table0 AS alias0 ON FALSE ) AS alias1 ON TRUE WHERE column29 = 1 ;
explain (costs off) SELECT 1 FROM fj_table0 LEFT JOIN ( SELECT 1 column29 FROM fj_table0 FULL JOIN fj_table0 AS alias0 ON FALSE ) AS alias1 ON TRUE WHERE column29 = 1 ;
drop table fj_table0;
-- contain system column, don't rewrite full join
explain (costs off) select t1.oid from pg_class t1 full join pg_constraint t2 on t1.relname = t2.conname;