mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Allow empty content in xml type
The xml type previously rejected "content" that is empty or consists only of spaces. But the SQL/XML standard allows that, so change that. The accepted values for XML "documents" are not changed. Reviewed-by: Ali Akbar <the.apaan@gmail.com>
This commit is contained in:
@ -1400,11 +1400,15 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace,
|
|||||||
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
|
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
|
||||||
doc->standalone = standalone;
|
doc->standalone = standalone;
|
||||||
|
|
||||||
res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
|
/* allow empty content */
|
||||||
utf8string + count, NULL);
|
if (*(utf8string + count))
|
||||||
if (res_code != 0 || xmlerrcxt->err_occurred)
|
{
|
||||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT,
|
res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
|
||||||
"invalid XML content");
|
utf8string + count, NULL);
|
||||||
|
if (res_code != 0 || xmlerrcxt->err_occurred)
|
||||||
|
xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT,
|
||||||
|
"invalid XML content");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PG_CATCH();
|
PG_CATCH();
|
||||||
|
@ -194,6 +194,18 @@ SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as fun
|
|||||||
<foo funny="<>&"'" funnier="b<a/>r"/>
|
<foo funny="<>&"'" funnier="b<a/>r"/>
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SELECT xmlparse(content '');
|
||||||
|
xmlparse
|
||||||
|
----------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT xmlparse(content ' ');
|
||||||
|
xmlparse
|
||||||
|
----------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SELECT xmlparse(content 'abc');
|
SELECT xmlparse(content 'abc');
|
||||||
xmlparse
|
xmlparse
|
||||||
----------
|
----------
|
||||||
@ -251,6 +263,22 @@ SELECT xmlparse(content '<nosuchprefix:tag/>');
|
|||||||
<nosuchprefix:tag/>
|
<nosuchprefix:tag/>
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SELECT xmlparse(document '');
|
||||||
|
ERROR: invalid XML document
|
||||||
|
DETAIL: line 1: switching encoding : no input
|
||||||
|
|
||||||
|
^
|
||||||
|
line 1: Document is empty
|
||||||
|
|
||||||
|
^
|
||||||
|
line 1: Start tag expected, '<' not found
|
||||||
|
|
||||||
|
^
|
||||||
|
SELECT xmlparse(document ' ');
|
||||||
|
ERROR: invalid XML document
|
||||||
|
DETAIL: line 1: Start tag expected, '<' not found
|
||||||
|
|
||||||
|
^
|
||||||
SELECT xmlparse(document 'abc');
|
SELECT xmlparse(document 'abc');
|
||||||
ERROR: invalid XML document
|
ERROR: invalid XML document
|
||||||
DETAIL: line 1: Start tag expected, '<' not found
|
DETAIL: line 1: Start tag expected, '<' not found
|
||||||
|
@ -164,6 +164,14 @@ SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as fun
|
|||||||
ERROR: unsupported XML feature
|
ERROR: unsupported XML feature
|
||||||
DETAIL: This functionality requires the server to be built with libxml support.
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
|
SELECT xmlparse(content '');
|
||||||
|
ERROR: unsupported XML feature
|
||||||
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
|
SELECT xmlparse(content ' ');
|
||||||
|
ERROR: unsupported XML feature
|
||||||
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
SELECT xmlparse(content 'abc');
|
SELECT xmlparse(content 'abc');
|
||||||
ERROR: unsupported XML feature
|
ERROR: unsupported XML feature
|
||||||
DETAIL: This functionality requires the server to be built with libxml support.
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
@ -196,6 +204,14 @@ SELECT xmlparse(content '<nosuchprefix:tag/>');
|
|||||||
ERROR: unsupported XML feature
|
ERROR: unsupported XML feature
|
||||||
DETAIL: This functionality requires the server to be built with libxml support.
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
|
SELECT xmlparse(document '');
|
||||||
|
ERROR: unsupported XML feature
|
||||||
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
|
SELECT xmlparse(document ' ');
|
||||||
|
ERROR: unsupported XML feature
|
||||||
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
|
HINT: You need to rebuild PostgreSQL using --with-libxml.
|
||||||
SELECT xmlparse(document 'abc');
|
SELECT xmlparse(document 'abc');
|
||||||
ERROR: unsupported XML feature
|
ERROR: unsupported XML feature
|
||||||
DETAIL: This functionality requires the server to be built with libxml support.
|
DETAIL: This functionality requires the server to be built with libxml support.
|
||||||
|
@ -60,6 +60,8 @@ SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp as bar));
|
|||||||
SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as funnier));
|
SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'b<a/>r' as funnier));
|
||||||
|
|
||||||
|
|
||||||
|
SELECT xmlparse(content '');
|
||||||
|
SELECT xmlparse(content ' ');
|
||||||
SELECT xmlparse(content 'abc');
|
SELECT xmlparse(content 'abc');
|
||||||
SELECT xmlparse(content '<abc>x</abc>');
|
SELECT xmlparse(content '<abc>x</abc>');
|
||||||
SELECT xmlparse(content '<invalidentity>&</invalidentity>');
|
SELECT xmlparse(content '<invalidentity>&</invalidentity>');
|
||||||
@ -69,6 +71,8 @@ SELECT xmlparse(content '<relativens xmlns=''relative''/>');
|
|||||||
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
|
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
|
||||||
SELECT xmlparse(content '<nosuchprefix:tag/>');
|
SELECT xmlparse(content '<nosuchprefix:tag/>');
|
||||||
|
|
||||||
|
SELECT xmlparse(document '');
|
||||||
|
SELECT xmlparse(document ' ');
|
||||||
SELECT xmlparse(document 'abc');
|
SELECT xmlparse(document 'abc');
|
||||||
SELECT xmlparse(document '<abc>x</abc>');
|
SELECT xmlparse(document '<abc>x</abc>');
|
||||||
SELECT xmlparse(document '<invalidentity>&</abc>');
|
SELECT xmlparse(document '<invalidentity>&</abc>');
|
||||||
|
Reference in New Issue
Block a user