Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
f71c7b9d
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,发现更多精彩内容 >>
提交
f71c7b9d
编写于
9月 23, 2007
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bugs in XML binary I/O functions. Heikki and Tom
上级
a8da5761
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
9 deletion
+30
-9
src/backend/utils/adt/xml.c
src/backend/utils/adt/xml.c
+30
-9
未找到文件。
src/backend/utils/adt/xml.c
浏览文件 @
f71c7b9d
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.4
6 2007/07/13 03:43:23
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.4
7 2007/09/23 21:36:42
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -232,37 +232,51 @@ xml_recv(PG_FUNCTION_ARGS)
xmlDocPtr
doc
;
xmlChar
*
encoding
=
NULL
;
str
=
pq_getmsgtext
(
buf
,
buf
->
len
-
buf
->
cursor
,
&
nbytes
);
/*
* Read the data in raw format. We don't know yet what the encoding
* is, as that information is embedded in the xml declaration; so we
* have to parse that before converting to server encoding.
*/
nbytes
=
buf
->
len
-
buf
->
cursor
;
str
=
(
char
*
)
pq_getmsgbytes
(
buf
,
nbytes
);
result
=
palloc
(
nbytes
+
VARHDRSZ
);
/*
* We need a null-terminated string to pass to parse_xml_decl(). Rather
* than make a separate copy, make the temporary result one byte bigger
* than it needs to be.
*/
result
=
palloc
(
nbytes
+
1
+
VARHDRSZ
);
SET_VARSIZE
(
result
,
nbytes
+
VARHDRSZ
);
memcpy
(
VARDATA
(
result
),
str
,
nbytes
);
str
=
VARDATA
(
result
);
str
[
nbytes
]
=
'\0'
;
parse_xml_decl
((
xmlChar
*
)
str
,
NULL
,
NULL
,
&
encoding
,
NULL
);
/*
* Parse the data to check if it is well-formed XML data. Assume
* that
ERROR occurred if parsing failed
.
* that
xml_parse will throw ERROR if not
.
*/
doc
=
xml_parse
(
result
,
xmloption
,
true
,
encoding
);
xmlFreeDoc
(
doc
);
/* Now that we know what we're dealing with, convert to server encoding */
newstr
=
(
char
*
)
pg_do_encoding_conversion
((
unsigned
char
*
)
str
,
nbytes
,
encoding
?
pg_char_to_encoding
((
char
*
)
encoding
)
:
PG_UTF8
,
GetDatabaseEncoding
());
pfree
(
str
);
if
(
newstr
!=
str
)
{
free
(
result
);
p
free
(
result
);
nbytes
=
strlen
(
newstr
);
result
=
palloc
(
nbytes
+
VARHDRSZ
);
SET_VARSIZE
(
result
,
nbytes
+
VARHDRSZ
);
memcpy
(
VARDATA
(
result
),
newstr
,
nbytes
);
pfree
(
newstr
);
}
PG_RETURN_XML_P
(
result
);
...
...
@@ -277,11 +291,18 @@ Datum
xml_send
(
PG_FUNCTION_ARGS
)
{
xmltype
*
x
=
PG_GETARG_XML_P
(
0
);
char
*
outval
=
xml_out_internal
(
x
,
pg_get_client_encoding
())
;
char
*
outval
;
StringInfoData
buf
;
/*
* xml_out_internal doesn't convert the encoding, it just prints
* the right declaration. pq_sendtext will do the conversion.
*/
outval
=
xml_out_internal
(
x
,
pg_get_client_encoding
());
pq_begintypsend
(
&
buf
);
pq_sendstring
(
&
buf
,
outval
);
pq_sendtext
(
&
buf
,
outval
,
strlen
(
outval
));
pfree
(
outval
);
PG_RETURN_BYTEA_P
(
pq_endtypsend
(
&
buf
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录