1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Fix xmlconcat by properly merging the XML declarations. Add aggregate

function xmlagg.
This commit is contained in:
Peter Eisentraut
2007-01-20 09:27:20 +00:00
parent 9a83bd50b7
commit b4c8d49036
9 changed files with 171 additions and 19 deletions

View File

@ -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;