Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
994cfba1
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,发现更多精彩内容 >>
提交
994cfba1
编写于
9月 08, 1998
作者:
V
Vadim B. Mikheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix GroupBY func broken by HAVING.
上级
6866cbc7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
43 deletion
+26
-43
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/planner.c
+26
-43
未找到文件。
src/backend/optimizer/plan/planner.c
浏览文件 @
994cfba1
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.3
3 1998/09/03 02:34:30 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.3
4 1998/09/08 02:50:20 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -95,17 +95,9 @@ Plan *
union_planner
(
Query
*
parse
)
{
List
*
tlist
=
parse
->
targetList
;
/*
* copy the original tlist, we will need the original one for the AGG
* node later on
*/
List
*
new_tlist
=
new_unsorted_tlist
(
tlist
);
int
tlist_len
=
length
(
tlist
);
List
*
rangetable
=
parse
->
rtable
;
Plan
*
result_plan
=
(
Plan
*
)
NULL
;
Index
rt_index
;
...
...
@@ -133,36 +125,18 @@ union_planner(Query *parse)
List
**
vpm
=
NULL
;
/*
* This is only necessary if aggregates are in use in queries
* like: SELECT sid FROM part GROUP BY sid HAVING MIN(pid) > 1;
* (pid is used but never selected for!!!) because the function
* 'query_planner' creates the plan for the lefttree of the
* 'GROUP' node and returns only those attributes contained in
* 'tlist'. The original 'tlist' contains only 'sid' here and
* that's why we have to to extend it to attributes which are not
* selected but are used in the havingQual.
*/
/*
* 'check_having_qual_for_vars' takes the havingQual and the
* actual 'tlist' as arguments and recursively scans the
* havingQual for attributes (VAR nodes) that are not contained in
* 'tlist' yet. If so, it creates a new entry and attaches it to
* the list 'new_tlist' (consisting of the VAR node and the RESDOM
* node as usual with tlists :-) )
* check_having_qual_for_vars takes the havingQual and the tlist
* as arguments and recursively scans the havingQual for VAR nodes
* that are not contained in tlist yet. If so, it creates a new entry
* and attaches it to the tlist. Latter, we use tlist_len to
* truncate tlist - ie restore actual tlist...
*/
if
(
parse
->
hasAggs
)
{
if
(
parse
->
havingQual
!=
NULL
)
new_tlist
=
check_having_qual_for_vars
(
parse
->
havingQual
,
new_
tlist
);
tlist
=
check_having_qual_for_vars
(
parse
->
havingQual
,
tlist
);
}
new_tlist
=
preprocess_targetlist
(
new_tlist
,
parse
->
commandType
,
parse
->
resultRelation
,
parse
->
rtable
);
/* Here starts the original (pre having) code */
tlist
=
preprocess_targetlist
(
tlist
,
parse
->
commandType
,
parse
->
resultRelation
,
...
...
@@ -176,7 +150,7 @@ union_planner(Query *parse)
PlannerVarParam
=
lcons
(
vpm
,
PlannerVarParam
);
result_plan
=
query_planner
(
parse
,
parse
->
commandType
,
new_
tlist
,
tlist
,
(
List
*
)
parse
->
qual
);
PlannerVarParam
=
lnext
(
PlannerVarParam
);
if
(
vpm
!=
NULL
)
...
...
@@ -199,9 +173,8 @@ union_planner(Query *parse)
*/
tuplePerGroup
=
parse
->
hasAggs
;
/* Use 'new_tlist' instead of 'tlist' */
result_plan
=
make_groupPlan
(
&
new_
tlist
,
make_groupPlan
(
&
tlist
,
tuplePerGroup
,
parse
->
groupClause
,
result_plan
);
...
...
@@ -215,11 +188,6 @@ union_planner(Query *parse)
int
old_length
=
0
,
new_length
=
0
;
/*
* Create the AGG node but use 'tlist' not 'new_tlist' as target
* list because we don't want the additional attributes (only used
* for the havingQual, see above) to show up in the result
*/
result_plan
=
(
Plan
*
)
make_agg
(
tlist
,
result_plan
);
/*
...
...
@@ -235,7 +203,22 @@ union_planner(Query *parse)
List
*
clause
;
List
**
vpm
=
NULL
;
/*
* Restore target list: get rid of Vars added for havingQual.
* Assumption: tlist_len > 0...
*/
{
List
*
l
;
int
tlen
=
0
;
foreach
(
l
,
((
Agg
*
)
result_plan
)
->
plan
.
targetlist
)
{
if
(
++
tlen
==
tlist_len
)
break
;
}
lnext
(
l
)
=
NIL
;
}
/*
* stuff copied from above to handle the use of attributes
* from outside in subselects
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录