Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
5cc38649
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,发现更多精彩内容 >>
提交
5cc38649
编写于
8月 04, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
record_out and friends need to cope with dropped columns in the row
datatype. Per example from Gaetano Mendola, 2004-07-25.
上级
8515efa1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
69 addition
and
30 deletion
+69
-30
src/backend/utils/adt/rowtypes.c
src/backend/utils/adt/rowtypes.c
+69
-30
未找到文件。
src/backend/utils/adt/rowtypes.c
浏览文件 @
5cc38649
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.
3 2004/06/06 18:06:2
5 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.
4 2004/08/04 19:31:1
5 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -58,6 +58,7 @@ record_in(PG_FUNCTION_ARGS)
TupleDesc
tupdesc
;
HeapTuple
tuple
;
RecordIOData
*
my_extra
;
bool
needComma
=
false
;
int
ncolumns
;
int
i
;
char
*
ptr
;
...
...
@@ -131,6 +132,26 @@ record_in(PG_FUNCTION_ARGS)
ColumnIOData
*
column_info
=
&
my_extra
->
columns
[
i
];
Oid
column_type
=
tupdesc
->
attrs
[
i
]
->
atttypid
;
/* Ignore dropped columns in datatype, but fill with nulls */
if
(
tupdesc
->
attrs
[
i
]
->
attisdropped
)
{
values
[
i
]
=
(
Datum
)
0
;
nulls
[
i
]
=
'n'
;
continue
;
}
if
(
needComma
)
{
/* Skip comma that separates prior field from this one */
if
(
*
ptr
==
','
)
ptr
++
;
else
/* *ptr must be ')' */
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TEXT_REPRESENTATION
),
errmsg
(
"malformed record literal:
\"
%s
\"
"
,
string
),
errdetail
(
"Too few columns."
)));
}
/* Check for null: completely empty input means null */
if
(
*
ptr
==
','
||
*
ptr
==
')'
)
{
...
...
@@ -203,27 +224,9 @@ record_in(PG_FUNCTION_ARGS)
/*
* Prep for next column
*/
if
(
*
ptr
==
','
)
{
if
(
i
==
ncolumns
-
1
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TEXT_REPRESENTATION
),
errmsg
(
"malformed record literal:
\"
%s
\"
"
,
string
),
errdetail
(
"Too many columns."
)));
ptr
++
;
}
else
{
/* *ptr must be ')' */
if
(
i
<
ncolumns
-
1
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TEXT_REPRESENTATION
),
errmsg
(
"malformed record literal:
\"
%s
\"
"
,
string
),
errdetail
(
"Too few columns."
)));
}
needComma
=
true
;
}
/* The check for ')' here is redundant except when ncolumns == 0 */
if
(
*
ptr
++
!=
')'
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_TEXT_REPRESENTATION
),
...
...
@@ -259,6 +262,7 @@ record_out(PG_FUNCTION_ARGS)
TupleDesc
tupdesc
;
HeapTupleData
tuple
;
RecordIOData
*
my_extra
;
bool
needComma
=
false
;
int
ncolumns
;
int
i
;
Datum
*
values
;
...
...
@@ -333,8 +337,13 @@ record_out(PG_FUNCTION_ARGS)
char
*
tmp
;
bool
nq
;
if
(
i
>
0
)
/* Ignore dropped columns in datatype */
if
(
tupdesc
->
attrs
[
i
]
->
attisdropped
)
continue
;
if
(
needComma
)
appendStringInfoChar
(
&
buf
,
','
);
needComma
=
true
;
if
(
nulls
[
i
]
==
'n'
)
{
...
...
@@ -414,6 +423,8 @@ record_recv(PG_FUNCTION_ARGS)
HeapTuple
tuple
;
RecordIOData
*
my_extra
;
int
ncolumns
;
int
usercols
;
int
validcols
;
int
i
;
Datum
*
values
;
char
*
nulls
;
...
...
@@ -463,13 +474,21 @@ record_recv(PG_FUNCTION_ARGS)
values
=
(
Datum
*
)
palloc
(
ncolumns
*
sizeof
(
Datum
));
nulls
=
(
char
*
)
palloc
(
ncolumns
*
sizeof
(
char
));
/* Verify number of columns */
i
=
pq_getmsgint
(
buf
,
4
);
if
(
i
!=
ncolumns
)
/* Fetch number of columns user thinks it has */
usercols
=
pq_getmsgint
(
buf
,
4
);
/* Need to scan to count nondeleted columns */
validcols
=
0
;
for
(
i
=
0
;
i
<
ncolumns
;
i
++
)
{
if
(
!
tupdesc
->
attrs
[
i
]
->
attisdropped
)
validcols
++
;
}
if
(
usercols
!=
validcols
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"wrong number of columns: %d, expected %d"
,
i
,
ncolumn
s
)));
usercols
,
validcol
s
)));
/* Process each column */
for
(
i
=
0
;
i
<
ncolumns
;
i
++
)
...
...
@@ -479,6 +498,14 @@ record_recv(PG_FUNCTION_ARGS)
Oid
coltypoid
;
int
itemlen
;
/* Ignore dropped columns in datatype, but fill with nulls */
if
(
tupdesc
->
attrs
[
i
]
->
attisdropped
)
{
values
[
i
]
=
(
Datum
)
0
;
nulls
[
i
]
=
'n'
;
continue
;
}
/* Verify column datatype */
coltypoid
=
pq_getmsgint
(
buf
,
sizeof
(
Oid
));
if
(
coltypoid
!=
column_type
)
...
...
@@ -570,6 +597,7 @@ record_send(PG_FUNCTION_ARGS)
HeapTupleData
tuple
;
RecordIOData
*
my_extra
;
int
ncolumns
;
int
validcols
;
int
i
;
Datum
*
values
;
char
*
nulls
;
...
...
@@ -633,7 +661,14 @@ record_send(PG_FUNCTION_ARGS)
/* And build the result string */
pq_begintypsend
(
&
buf
);
pq_sendint
(
&
buf
,
ncolumns
,
4
);
/* Need to scan to count nondeleted columns */
validcols
=
0
;
for
(
i
=
0
;
i
<
ncolumns
;
i
++
)
{
if
(
!
tupdesc
->
attrs
[
i
]
->
attisdropped
)
validcols
++
;
}
pq_sendint
(
&
buf
,
validcols
,
4
);
for
(
i
=
0
;
i
<
ncolumns
;
i
++
)
{
...
...
@@ -641,6 +676,10 @@ record_send(PG_FUNCTION_ARGS)
Oid
column_type
=
tupdesc
->
attrs
[
i
]
->
atttypid
;
bytea
*
outputbytes
;
/* Ignore dropped columns in datatype */
if
(
tupdesc
->
attrs
[
i
]
->
attisdropped
)
continue
;
pq_sendint
(
&
buf
,
column_type
,
sizeof
(
Oid
));
if
(
nulls
[
i
]
==
'n'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录