Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
5e987038
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,发现更多精彩内容 >>
提交
5e987038
编写于
5月 19, 2001
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move ParserFuncOrColumn function higher in the file.
上级
5ec84743
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
131 addition
and
131 deletion
+131
-131
src/backend/parser/parse_func.c
src/backend/parser/parse_func.c
+131
-131
未找到文件。
src/backend/parser/parse_func.c
浏览文件 @
5e987038
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.10
6 2001/05/19 00:33:20
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.10
7 2001/05/19 00:37:45
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -104,136 +104,6 @@ ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int precedence)
return
retval
;
}
static
int
agg_get_candidates
(
char
*
aggname
,
Oid
typeId
,
CandidateList
*
candidates
)
{
CandidateList
current_candidate
;
Relation
pg_aggregate_desc
;
HeapScanDesc
pg_aggregate_scan
;
HeapTuple
tup
;
Form_pg_aggregate
agg
;
int
ncandidates
=
0
;
ScanKeyData
aggKey
[
1
];
*
candidates
=
NULL
;
ScanKeyEntryInitialize
(
&
aggKey
[
0
],
0
,
Anum_pg_aggregate_aggname
,
F_NAMEEQ
,
NameGetDatum
(
aggname
));
pg_aggregate_desc
=
heap_openr
(
AggregateRelationName
,
AccessShareLock
);
pg_aggregate_scan
=
heap_beginscan
(
pg_aggregate_desc
,
0
,
SnapshotSelf
,
/* ??? */
1
,
aggKey
);
while
(
HeapTupleIsValid
(
tup
=
heap_getnext
(
pg_aggregate_scan
,
0
)))
{
agg
=
(
Form_pg_aggregate
)
GETSTRUCT
(
tup
);
current_candidate
=
(
CandidateList
)
palloc
(
sizeof
(
struct
_CandidateList
));
current_candidate
->
args
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
));
current_candidate
->
args
[
0
]
=
agg
->
aggbasetype
;
current_candidate
->
next
=
*
candidates
;
*
candidates
=
current_candidate
;
ncandidates
++
;
}
heap_endscan
(
pg_aggregate_scan
);
heap_close
(
pg_aggregate_desc
,
AccessShareLock
);
return
ncandidates
;
}
/* agg_get_candidates() */
/* agg_select_candidate()
*
* Try to choose only one candidate aggregate function from a list of
* possible matches. Return value is Oid of input type of aggregate
* if successful, else InvalidOid.
*/
static
Oid
agg_select_candidate
(
Oid
typeid
,
CandidateList
candidates
)
{
CandidateList
current_candidate
;
CandidateList
last_candidate
;
Oid
current_typeid
;
int
ncandidates
;
CATEGORY
category
,
current_category
;
/*
* First look for exact matches or binary compatible matches. (Of
* course exact matches shouldn't even get here, but anyway.)
*/
ncandidates
=
0
;
last_candidate
=
NULL
;
for
(
current_candidate
=
candidates
;
current_candidate
!=
NULL
;
current_candidate
=
current_candidate
->
next
)
{
current_typeid
=
current_candidate
->
args
[
0
];
if
(
current_typeid
==
typeid
||
IS_BINARY_COMPATIBLE
(
current_typeid
,
typeid
))
{
last_candidate
=
current_candidate
;
ncandidates
++
;
}
}
if
(
ncandidates
==
1
)
return
last_candidate
->
args
[
0
];
/*
* If no luck that way, look for candidates which allow coercion and
* have a preferred type. Keep all candidates if none match.
*/
category
=
TypeCategory
(
typeid
);
ncandidates
=
0
;
last_candidate
=
NULL
;
for
(
current_candidate
=
candidates
;
current_candidate
!=
NULL
;
current_candidate
=
current_candidate
->
next
)
{
current_typeid
=
current_candidate
->
args
[
0
];
current_category
=
TypeCategory
(
current_typeid
);
if
(
current_category
==
category
&&
IsPreferredType
(
current_category
,
current_typeid
)
&&
can_coerce_type
(
1
,
&
typeid
,
&
current_typeid
))
{
/* only one so far? then keep it... */
if
(
last_candidate
==
NULL
)
{
candidates
=
current_candidate
;
last_candidate
=
current_candidate
;
ncandidates
=
1
;
}
/* otherwise, keep this one too... */
else
{
last_candidate
->
next
=
current_candidate
;
last_candidate
=
current_candidate
;
ncandidates
++
;
}
}
/* otherwise, don't bother keeping this one around... */
}
if
(
last_candidate
)
/* terminate rebuilt list */
last_candidate
->
next
=
NULL
;
if
(
ncandidates
==
1
)
return
candidates
->
args
[
0
];
return
InvalidOid
;
}
/* agg_select_candidate() */
/*
* parse function
* This code is confusing because the database can accept
...
...
@@ -709,6 +579,136 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
}
static
int
agg_get_candidates
(
char
*
aggname
,
Oid
typeId
,
CandidateList
*
candidates
)
{
CandidateList
current_candidate
;
Relation
pg_aggregate_desc
;
HeapScanDesc
pg_aggregate_scan
;
HeapTuple
tup
;
Form_pg_aggregate
agg
;
int
ncandidates
=
0
;
ScanKeyData
aggKey
[
1
];
*
candidates
=
NULL
;
ScanKeyEntryInitialize
(
&
aggKey
[
0
],
0
,
Anum_pg_aggregate_aggname
,
F_NAMEEQ
,
NameGetDatum
(
aggname
));
pg_aggregate_desc
=
heap_openr
(
AggregateRelationName
,
AccessShareLock
);
pg_aggregate_scan
=
heap_beginscan
(
pg_aggregate_desc
,
0
,
SnapshotSelf
,
/* ??? */
1
,
aggKey
);
while
(
HeapTupleIsValid
(
tup
=
heap_getnext
(
pg_aggregate_scan
,
0
)))
{
agg
=
(
Form_pg_aggregate
)
GETSTRUCT
(
tup
);
current_candidate
=
(
CandidateList
)
palloc
(
sizeof
(
struct
_CandidateList
));
current_candidate
->
args
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
));
current_candidate
->
args
[
0
]
=
agg
->
aggbasetype
;
current_candidate
->
next
=
*
candidates
;
*
candidates
=
current_candidate
;
ncandidates
++
;
}
heap_endscan
(
pg_aggregate_scan
);
heap_close
(
pg_aggregate_desc
,
AccessShareLock
);
return
ncandidates
;
}
/* agg_get_candidates() */
/* agg_select_candidate()
*
* Try to choose only one candidate aggregate function from a list of
* possible matches. Return value is Oid of input type of aggregate
* if successful, else InvalidOid.
*/
static
Oid
agg_select_candidate
(
Oid
typeid
,
CandidateList
candidates
)
{
CandidateList
current_candidate
;
CandidateList
last_candidate
;
Oid
current_typeid
;
int
ncandidates
;
CATEGORY
category
,
current_category
;
/*
* First look for exact matches or binary compatible matches. (Of
* course exact matches shouldn't even get here, but anyway.)
*/
ncandidates
=
0
;
last_candidate
=
NULL
;
for
(
current_candidate
=
candidates
;
current_candidate
!=
NULL
;
current_candidate
=
current_candidate
->
next
)
{
current_typeid
=
current_candidate
->
args
[
0
];
if
(
current_typeid
==
typeid
||
IS_BINARY_COMPATIBLE
(
current_typeid
,
typeid
))
{
last_candidate
=
current_candidate
;
ncandidates
++
;
}
}
if
(
ncandidates
==
1
)
return
last_candidate
->
args
[
0
];
/*
* If no luck that way, look for candidates which allow coercion and
* have a preferred type. Keep all candidates if none match.
*/
category
=
TypeCategory
(
typeid
);
ncandidates
=
0
;
last_candidate
=
NULL
;
for
(
current_candidate
=
candidates
;
current_candidate
!=
NULL
;
current_candidate
=
current_candidate
->
next
)
{
current_typeid
=
current_candidate
->
args
[
0
];
current_category
=
TypeCategory
(
current_typeid
);
if
(
current_category
==
category
&&
IsPreferredType
(
current_category
,
current_typeid
)
&&
can_coerce_type
(
1
,
&
typeid
,
&
current_typeid
))
{
/* only one so far? then keep it... */
if
(
last_candidate
==
NULL
)
{
candidates
=
current_candidate
;
last_candidate
=
current_candidate
;
ncandidates
=
1
;
}
/* otherwise, keep this one too... */
else
{
last_candidate
->
next
=
current_candidate
;
last_candidate
=
current_candidate
;
ncandidates
++
;
}
}
/* otherwise, don't bother keeping this one around... */
}
if
(
last_candidate
)
/* terminate rebuilt list */
last_candidate
->
next
=
NULL
;
if
(
ncandidates
==
1
)
return
candidates
->
args
[
0
];
return
InvalidOid
;
}
/* agg_select_candidate() */
/* func_get_candidates()
* get a list of all argument type vectors for which a function named
* funcname taking nargs arguments exists
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录