aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/xml.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2007-01-07 22:49:56 +0000
committerPeter Eisentraut <peter_e@gmx.net>2007-01-07 22:49:56 +0000
commitd807c7ef3f1a04026c3c4b5b24954f7fc84d0e46 (patch)
tree592a826a1d9a2cf29e6acae3f6cc0d5283708286 /src/backend/utils/adt/xml.c
parentde9aa5a7b4d9696b1daceba01d155cbd783bc883 (diff)
downloadpostgresql-d807c7ef3f1a04026c3c4b5b24954f7fc84d0e46.tar.gz
postgresql-d807c7ef3f1a04026c3c4b5b24954f7fc84d0e46.zip
Some fine-tuning of xmlpi in corner cases:
- correct error codes - do syntax checks in correct order - strip leading spaces of argument
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r--src/backend/utils/adt/xml.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 597ba4f7137..5137834efb1 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -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.12 2007/01/07 00:13:55 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.13 2007/01/07 22:49:56 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -257,7 +257,7 @@ xmlparse(text *data, bool is_document, bool preserve_whitespace)
xmltype *
-xmlpi(char *target, text *arg)
+xmlpi(char *target, text *arg, bool arg_is_null, bool *result_is_null)
{
#ifdef USE_LIBXML
xmltype *result;
@@ -265,10 +265,18 @@ xmlpi(char *target, text *arg)
if (pg_strncasecmp(target, "xml", 3) == 0)
ereport(ERROR,
- (errcode(ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION),
+ (errcode(ERRCODE_SYNTAX_ERROR), /* really */
errmsg("invalid XML processing instruction"),
errdetail("XML processing instruction target name cannot start with \"xml\".")));
+ /*
+ * Following the SQL standard, the null check comes after the
+ * syntax check above.
+ */
+ *result_is_null = arg_is_null;
+ if (*result_is_null)
+ return NULL;
+
initStringInfo(&buf);
appendStringInfo(&buf, "<?%s", target);
@@ -286,7 +294,7 @@ xmlpi(char *target, text *arg)
errdetail("XML processing instruction cannot contain \"?>\".")));
appendStringInfoChar(&buf, ' ');
- appendStringInfoString(&buf, string);
+ appendStringInfoString(&buf, string + strspn(string, " "));
pfree(string);
}
appendStringInfoString(&buf, "?>");