Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
67af5bac
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
67af5bac
编写于
1月 12, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix another place that wasn't maintaining AND/OR flatness of an
already-canonicalized qual expression.
上级
5590be0a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
15 deletion
+65
-15
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/planner.c
+14
-9
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/plan/subselect.c
+51
-6
未找到文件。
src/backend/optimizer/plan/planner.c
浏览文件 @
67af5bac
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.16
3 2003/12/28 21:57:36
tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.16
4 2004/01/12 22:20:28
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -380,6 +380,10 @@ preprocess_expression(Query *parse, Node *expr, int kind)
* If it's a qual or havingQual, canonicalize it. It seems most useful
* to do this before applying eval_const_expressions, since the latter
* can optimize flattened AND/ORs better than unflattened ones.
*
* Note: all processing of a qual expression after this point must be
* careful to maintain AND/OR flatness --- that is, do not generate a
* tree with AND directly under AND, nor OR directly under OR.
*/
if
(
kind
==
EXPRKIND_QUAL
)
{
...
...
@@ -396,14 +400,6 @@ preprocess_expression(Query *parse, Node *expr, int kind)
*/
expr
=
eval_const_expressions
(
expr
);
/*
* If it's a qual or havingQual, convert it to implicit-AND format.
* (We don't want to do this before eval_const_expressions, since the
* latter would be unable to simplify a top-level AND correctly.)
*/
if
(
kind
==
EXPRKIND_QUAL
)
expr
=
(
Node
*
)
make_ands_implicit
((
Expr
*
)
expr
);
/* Expand SubLinks to SubPlans */
if
(
parse
->
hasSubLinks
)
expr
=
SS_process_sublinks
(
expr
,
(
kind
==
EXPRKIND_QUAL
));
...
...
@@ -417,6 +413,15 @@ preprocess_expression(Query *parse, Node *expr, int kind)
if
(
PlannerQueryLevel
>
1
)
expr
=
SS_replace_correlation_vars
(
expr
);
/*
* If it's a qual or havingQual, convert it to implicit-AND format.
* (We don't want to do this before eval_const_expressions, since the
* latter would be unable to simplify a top-level AND correctly. Also,
* SS_process_sublinks expects explicit-AND format.)
*/
if
(
kind
==
EXPRKIND_QUAL
)
expr
=
(
Node
*
)
make_ands_implicit
((
Expr
*
)
expr
);
return
expr
;
}
...
...
src/backend/optimizer/plan/subselect.c
浏览文件 @
67af5bac
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.8
6 2003/11/29 19:51:50 pgsq
l Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.8
7 2004/01/12 22:20:28 tg
l Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -848,13 +848,58 @@ process_sublinks_mutator(Node *node, bool *isTopQual)
Assert
(
!
IsA
(
node
,
Query
));
/*
* If we recurse down through anything other than a List node, we are
* definitely not at top qual level anymore.
* Because make_subplan() could return an AND or OR clause, we have to
* take steps to preserve AND/OR flatness of a qual. We assume the input
* has been AND/OR flattened and so we need no recursion here.
*
* If we recurse down through anything other than an AND node,
* we are definitely not at top qual level anymore. (Due to the coding
* here, we will not get called on the List subnodes of an AND, so no
* check is needed for List.)
*/
if
(
IsA
(
node
,
List
))
if
(
and_clause
(
node
))
{
List
*
newargs
=
NIL
;
List
*
l
;
/* Still at qual top-level */
locTopQual
=
*
isTopQual
;
else
locTopQual
=
false
;
foreach
(
l
,
((
BoolExpr
*
)
node
)
->
args
)
{
Node
*
newarg
;
newarg
=
process_sublinks_mutator
(
lfirst
(
l
),
(
void
*
)
&
locTopQual
);
if
(
and_clause
(
newarg
))
newargs
=
nconc
(
newargs
,
((
BoolExpr
*
)
newarg
)
->
args
);
else
newargs
=
lappend
(
newargs
,
newarg
);
}
return
(
Node
*
)
make_andclause
(
newargs
);
}
/* otherwise not at qual top-level */
locTopQual
=
false
;
if
(
or_clause
(
node
))
{
List
*
newargs
=
NIL
;
List
*
l
;
foreach
(
l
,
((
BoolExpr
*
)
node
)
->
args
)
{
Node
*
newarg
;
newarg
=
process_sublinks_mutator
(
lfirst
(
l
),
(
void
*
)
&
locTopQual
);
if
(
or_clause
(
newarg
))
newargs
=
nconc
(
newargs
,
((
BoolExpr
*
)
newarg
)
->
args
);
else
newargs
=
lappend
(
newargs
,
newarg
);
}
return
(
Node
*
)
make_orclause
(
newargs
);
}
return
expression_tree_mutator
(
node
,
process_sublinks_mutator
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录