From b4c8d49036b971d892b2dfe1c71d3f0cee116e7f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 20 Jan 2007 09:27:20 +0000 Subject: Fix xmlconcat by properly merging the XML declarations. Add aggregate function xmlagg. --- src/backend/executor/execQual.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/backend/executor/execQual.c') diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index ca804dea210..60f9d35f1f7 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.207 2007/01/14 13:11:53 petere Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.208 2007/01/20 09:27:19 petere Exp $ * *------------------------------------------------------------------------- */ @@ -2651,7 +2651,6 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, StringInfoData buf; Datum value; bool isnull; - char *str; ListCell *arg; ListCell *narg; int i; @@ -2663,20 +2662,22 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, switch (xexpr->op) { case IS_XMLCONCAT: - initStringInfo(&buf); - foreach(arg, xmlExpr->args) { - ExprState *e = (ExprState *) lfirst(arg); + List *values = NIL; - value = ExecEvalExpr(e, econtext, &isnull, NULL); - if (!isnull) + foreach(arg, xmlExpr->args) + { + ExprState *e = (ExprState *) lfirst(arg); + + value = ExecEvalExpr(e, econtext, &isnull, NULL); + if (!isnull) + values = lappend(values, DatumGetPointer(value)); + } + + if (list_length(values) > 0) { - /* we know the value is XML type */ - str = DatumGetCString(DirectFunctionCall1(xml_out, - value)); - appendStringInfoString(&buf, str); - pfree(str); *isNull = false; + return PointerGetDatum(xmlconcat(values)); } } break; -- cgit v1.2.3