Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
a5a290ca
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,发现更多精彩内容 >>
提交
a5a290ca
编写于
9月 18, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make rule lister use aliases from FROM clause when a table column has
been given an alias. Otherwise, results are incorrect.
上级
2acdef18
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
19 deletion
+49
-19
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/ruleutils.c
+49
-19
未找到文件。
src/backend/utils/adt/ruleutils.c
浏览文件 @
a5a290ca
...
...
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.6
1 2000/09/12 21:07:05
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.6
2 2000/09/18 20:14:23
tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
...
...
@@ -109,7 +109,8 @@ static void get_from_clause_item(Node *jtnode, Query *query,
static
bool
tleIsArrayAssign
(
TargetEntry
*
tle
);
static
char
*
quote_identifier
(
char
*
ident
);
static
char
*
get_relation_name
(
Oid
relid
);
static
char
*
get_attribute_name
(
Oid
relid
,
int2
attnum
);
static
char
*
get_relid_attribute_name
(
Oid
relid
,
AttrNumber
attnum
);
static
char
*
get_rte_attribute_name
(
RangeTblEntry
*
rte
,
AttrNumber
attnum
);
#define only_marker(rte) ((rte)->inh ? "" : "ONLY ")
...
...
@@ -445,7 +446,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
* ----------
*/
appendStringInfo
(
&
keybuf
,
"%s"
,
quote_identifier
(
get
_attribute_name
(
idxrec
->
indrelid
,
quote_identifier
(
get_relid
_attribute_name
(
idxrec
->
indrelid
,
idxrec
->
indkey
[
keyno
])));
/* ----------
...
...
@@ -696,8 +697,8 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
quote_identifier
(
get_relation_name
(
ev_class
)));
if
(
ev_attr
>
0
)
appendStringInfo
(
buf
,
".%s"
,
quote_identifier
(
get_attribute_name
(
ev_class
,
ev_attr
)));
quote_identifier
(
get_
relid_
attribute_name
(
ev_class
,
ev_attr
)));
/* If the rule has an event qualification, add it */
if
(
ev_qual
==
NULL
)
...
...
@@ -908,7 +909,7 @@ get_select_query_def(Query *query, deparse_context *context)
char
*
attname
;
rte
=
get_rte_for_var
(
var
,
context
);
attname
=
get_
attribute_name
(
rte
->
relid
,
var
->
varattno
);
attname
=
get_
rte_attribute_name
(
rte
,
var
->
varattno
);
tell_as
=
(
strcmp
(
attname
,
tle
->
resdom
->
resname
)
!=
0
);
}
...
...
@@ -1164,7 +1165,7 @@ get_rule_expr(Node *node, deparse_context *context)
quote_identifier
(
rte
->
eref
->
relname
));
}
appendStringInfo
(
buf
,
"%s"
,
quote_identifier
(
get_
attribute_name
(
rte
->
relid
,
quote_identifier
(
get_
rte_attribute_name
(
rte
,
var
->
varattno
)));
}
break
;
...
...
@@ -1340,7 +1341,8 @@ get_rule_expr(Node *node, deparse_context *context)
if
(
!
OidIsValid
(
typrelid
))
elog
(
ERROR
,
"Argument type %s of FieldSelect is not a tuple type"
,
NameStr
(
typeStruct
->
typname
));
fieldname
=
get_attribute_name
(
typrelid
,
fselect
->
fieldnum
);
fieldname
=
get_relid_attribute_name
(
typrelid
,
fselect
->
fieldnum
);
appendStringInfo
(
buf
,
".%s"
,
quote_identifier
(
fieldname
));
}
break
;
...
...
@@ -2000,23 +2002,51 @@ get_relation_name(Oid relid)
/* ----------
* get_attribute_name - Get an attribute name by its
* relations Oid and its attnum
* get_relid_attribute_name
* Get an attribute name by its relations Oid and its attnum
*
* Same as underlying syscache routine get_attname(), except that error
* is handled by elog() instead of returning NULL.
* ----------
*/
static
char
*
get_
attribute_name
(
Oid
relid
,
int2
attnum
)
get_
relid_attribute_name
(
Oid
relid
,
AttrNumber
attnum
)
{
HeapTuple
atttup
;
Form_pg_attribute
attStruct
;
char
*
attname
;
atttup
=
SearchSysCacheTuple
(
ATTNUM
,
ObjectIdGetDatum
(
relid
),
(
Datum
)
attnum
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
atttup
))
attname
=
get_attname
(
relid
,
attnum
);
if
(
attname
==
NULL
)
elog
(
ERROR
,
"cache lookup of attribute %d in relation %u failed"
,
attnum
,
relid
);
return
attname
;
}
attStruct
=
(
Form_pg_attribute
)
GETSTRUCT
(
atttup
);
return
pstrdup
(
NameStr
(
attStruct
->
attname
));
/* ----------
* get_rte_attribute_name
* Get an attribute name from a RangeTblEntry
*
* This is unlike get_relid_attribute_name() because we use aliases if
* available.
* ----------
*/
static
char
*
get_rte_attribute_name
(
RangeTblEntry
*
rte
,
AttrNumber
attnum
)
{
/*
* If there is an alias, use it
*/
if
(
attnum
>
0
&&
attnum
<=
length
(
rte
->
eref
->
attrs
))
return
strVal
(
nth
(
attnum
-
1
,
rte
->
eref
->
attrs
));
/*
* Can get here for a system attribute (which never has an alias),
* or if alias name list is too short (which probably can't happen
* anymore). Neither of these cases is valid for a subselect RTE.
*/
if
(
rte
->
relid
==
InvalidOid
)
elog
(
ERROR
,
"Invalid attnum %d for rangetable entry %s"
,
attnum
,
rte
->
eref
->
relname
);
/*
* Use the real name of the table's column
*/
return
get_relid_attribute_name
(
rte
->
relid
,
attnum
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录