!3459 当targetlist存在系统列时,不重写fulljoin
Merge pull request !3459 from pengjiong/fix_col
This commit is contained in:
@ -71,6 +71,7 @@
|
||||
./share/postgresql/extension/dolphin--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
./share/postgresql/extension/dist_fdw.control
|
||||
|
@ -65,6 +65,7 @@
|
||||
./share/postgresql/extension/dolphin--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
./share/postgresql/extension/dist_fdw.control
|
||||
|
@ -71,6 +71,7 @@
|
||||
./share/postgresql/extension/dolphin--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
./share/postgresql/extension/dist_fdw.control
|
||||
|
@ -1228,6 +1228,25 @@ static bool has_foreign_table_in_rtable(Query* query)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool contain_system_column(Node *var_list)
|
||||
{
|
||||
List* vars = pull_var_clause(var_list, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS);
|
||||
ListCell* lc = NULL;
|
||||
bool result = false;
|
||||
|
||||
foreach (lc, vars) {
|
||||
Var* var = (Var*)lfirst(lc);
|
||||
|
||||
if (var->varattno < 0) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list_free_ext(vars);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* --------------------
|
||||
* subquery_planner
|
||||
* Invokes the planner on a subquery. We recurse to here for each
|
||||
@ -1784,27 +1803,39 @@ Plan* subquery_planner(PlannerGlobal* glob, Query* parse, PlannerInfo* parent_ro
|
||||
#endif
|
||||
{
|
||||
bool support_rewrite = true;
|
||||
if (!fulljoin_2_left_union_right_anti_support(root->parse))
|
||||
support_rewrite = false;
|
||||
if (contain_volatile_functions((Node*)root->parse))
|
||||
support_rewrite = false;
|
||||
contain_func_context context =
|
||||
init_contain_func_context(list_make3_oid(ECEXTENSIONFUNCOID, ECHADOOPFUNCOID, RANDOMFUNCOID));
|
||||
if (contains_specified_func((Node*)root->parse, &context)) {
|
||||
char* func_name = get_func_name(((FuncExpr*)linitial(context.func_exprs))->funcid);
|
||||
ereport(DEBUG2,
|
||||
(errmodule(MOD_OPT_REWRITE),
|
||||
(errmsg("[Not rewrite full Join on true]: %s functions contained.", func_name))));
|
||||
pfree_ext(func_name);
|
||||
list_free_ext(context.funcids);
|
||||
context.funcids = NIL;
|
||||
list_free_ext(context.func_exprs);
|
||||
context.func_exprs = NIL;
|
||||
support_rewrite = false;
|
||||
}
|
||||
if (has_foreign_table_in_rtable(root->parse)) {
|
||||
support_rewrite = false;
|
||||
}
|
||||
do {
|
||||
if (contain_system_column((Node*)root->parse->targetList)) {
|
||||
support_rewrite = false;
|
||||
break;
|
||||
}
|
||||
if (!fulljoin_2_left_union_right_anti_support(root->parse)) {
|
||||
support_rewrite = false;
|
||||
break;
|
||||
}
|
||||
if (contain_volatile_functions((Node*)root->parse)) {
|
||||
support_rewrite = false;
|
||||
break;
|
||||
}
|
||||
contain_func_context context =
|
||||
init_contain_func_context(list_make3_oid(ECEXTENSIONFUNCOID, ECHADOOPFUNCOID, RANDOMFUNCOID));
|
||||
if (contains_specified_func((Node*)root->parse, &context)) {
|
||||
char* func_name = get_func_name(((FuncExpr*)linitial(context.func_exprs))->funcid);
|
||||
ereport(DEBUG2,
|
||||
(errmodule(MOD_OPT_REWRITE),
|
||||
(errmsg("[Not rewrite full Join on true]: %s functions contained.", func_name))));
|
||||
pfree_ext(func_name);
|
||||
list_free_ext(context.funcids);
|
||||
context.funcids = NIL;
|
||||
list_free_ext(context.func_exprs);
|
||||
context.func_exprs = NIL;
|
||||
support_rewrite = false;
|
||||
break;
|
||||
}
|
||||
if (has_foreign_table_in_rtable(root->parse)) {
|
||||
support_rewrite = false;
|
||||
break;
|
||||
}
|
||||
} while (0);
|
||||
if (support_rewrite) {
|
||||
reduce_inequality_fulljoins(root);
|
||||
DEBUG_QRW("After full join conversion");
|
||||
|
@ -144,3 +144,14 @@ select left(alias8.w_zip ,alias8.w_id) as alias10,true alias11,dense_rank() over
|
||||
|
||||
drop table fulltest;
|
||||
drop table fulltest2;
|
||||
-- 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
|
||||
------------------------------------------
|
||||
Hash Full Join
|
||||
Hash Cond: (t1.relname = t2.conname)
|
||||
-> Seq Scan on pg_class t1
|
||||
-> Hash
|
||||
-> Seq Scan on pg_constraint t2
|
||||
(5 rows)
|
||||
|
||||
|
@ -50,3 +50,6 @@ select left(alias8.w_zip ,alias8.w_id) as alias10,true alias11,dense_rank() over
|
||||
drop table fulltest;
|
||||
drop table fulltest2;
|
||||
|
||||
-- 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;
|
||||
|
||||
|
Reference in New Issue
Block a user