From 57b1085df55d092e2a728043ec607db8fdef2483 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 9 Sep 2014 11:34:52 -0400 Subject: 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 --- src/backend/utils/adt/xml.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/backend/utils/adt/xml.c') diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 422be69bd6d..119dfc7efec 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -1400,11 +1400,15 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace, doc->encoding = xmlStrdup((const xmlChar *) "UTF-8"); doc->standalone = standalone; - res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, - utf8string + count, NULL); - if (res_code != 0 || xmlerrcxt->err_occurred) - xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT, - "invalid XML content"); + /* allow empty content */ + if (*(utf8string + count)) + { + res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, + utf8string + count, NULL); + if (res_code != 0 || xmlerrcxt->err_occurred) + xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT, + "invalid XML content"); + } } } PG_CATCH(); -- cgit v1.2.3