From 8b35795362be5fd06fe22575a64bce81002a22c2 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 12 Jan 2007 21:47:27 +0000 Subject: [PATCH] Use XML output escaping also in XMLFOREST. --- src/backend/executor/execQual.c | 9 ++++----- src/backend/utils/adt/xml.c | 8 ++------ src/include/utils/xml.h | 3 ++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 994f7d57ac..8052f8b2d7 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.205 2007/01/10 20:33:54 petere Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.206 2007/01/12 21:47:26 petere Exp $ * *------------------------------------------------------------------------- */ @@ -2692,11 +2692,10 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, value = ExecEvalExpr(e, econtext, &isnull, NULL); if (!isnull) { - str = OutputFunctionCall(&xmlExpr->named_outfuncs[i], - value); appendStringInfo(&buf, "<%s>%s", - argname, str, argname); - pfree(str); + argname, + map_sql_value_to_xml_value(value, exprType((Node *) e->expr)), + argname); *isNull = false; } i++; diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 3689c9203e..da04bee15d 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.15 2007/01/12 16:29:24 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.16 2007/01/12 21:47:26 petere Exp $ * *------------------------------------------------------------------------- */ @@ -70,8 +70,6 @@ static void xml_ereport_by_code(int level, int sqlcode, static xmlChar *xml_text2xmlChar(text *in); static xmlDocPtr xml_parse(text *data, bool is_document, bool preserve_whitespace); -static char *map_sql_value_to_xml_value(Datum value, Oid type); - #endif /* USE_LIBXML */ #define NO_XML_SUPPORT() \ @@ -1260,11 +1258,10 @@ map_xml_name_to_sql_identifier(char *name) } -#ifdef USE_LIBXML /* * Map SQL value to XML value; see SQL/XML:2003 section 9.16. */ -static char * +char * map_sql_value_to_xml_value(Datum value, Oid type) { StringInfoData buf; @@ -1341,4 +1338,3 @@ map_sql_value_to_xml_value(Datum value, Oid type) return buf.data; } -#endif /* USE_LIBXML */ diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h index c4e508c488..b7b105ef15 100644 --- a/src/include/utils/xml.h +++ b/src/include/utils/xml.h @@ -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/include/utils/xml.h,v 1.8 2007/01/10 20:33:54 petere Exp $ + * $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.9 2007/01/12 21:47:27 petere Exp $ * *------------------------------------------------------------------------- */ @@ -40,5 +40,6 @@ extern xmltype *xmlroot(xmltype *data, text *version, int standalone); extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped); extern char *map_xml_name_to_sql_identifier(char *name); +extern char *map_sql_value_to_xml_value(Datum value, Oid type); #endif /* XML_H */ -- 2.40.0