diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2007-01-10 20:33:54 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2007-01-10 20:33:54 +0000 |
commit | c0e977c18f1939cb0d948c51740aa8816d69c720 (patch) | |
tree | 71d15c5d3d7e793ff4beacfce21eb27b3d4c9d66 /src/backend/executor | |
parent | f21d5b61ce4ecd60d4d671990f9c6b886e234809 (diff) | |
download | postgresql-c0e977c18f1939cb0d948c51740aa8816d69c720.tar.gz postgresql-c0e977c18f1939cb0d948c51740aa8816d69c720.zip |
Use libxml's xmlwriter API for producing XML elements, instead of doing
our own printing dance. This does a better job of quoting and escaping the
values.
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execQual.c | 57 |
1 files changed, 6 insertions, 51 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index c23680f11be..994f7d57ac4 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.204 2007/01/07 22:49:55 petere Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.205 2007/01/10 20:33:54 petere Exp $ * *------------------------------------------------------------------------- */ @@ -2654,7 +2654,6 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, char *str; ListCell *arg; ListCell *narg; - bool found_arg; int i; if (isDone) @@ -2682,55 +2681,6 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, } break; - case IS_XMLELEMENT: - initStringInfo(&buf); - *isNull = false; - appendStringInfo(&buf, "<%s", xexpr->name); - i = 0; - forboth(arg, xmlExpr->named_args, narg, xexpr->arg_names) - { - ExprState *e = (ExprState *) lfirst(arg); - char *argname = strVal(lfirst(narg)); - - value = ExecEvalExpr(e, econtext, &isnull, NULL); - if (!isnull) - { - str = OutputFunctionCall(&xmlExpr->named_outfuncs[i], - value); - appendStringInfo(&buf, " %s=\"%s\"", argname, str); - pfree(str); - } - i++; - } - - found_arg = false; - foreach(arg, xmlExpr->args) - { - ExprState *e = (ExprState *) lfirst(arg); - - value = ExecEvalExpr(e, econtext, &isnull, NULL); - if (!isnull) - { - if (!found_arg) - { - appendStringInfoChar(&buf, '>'); - found_arg = true; - } - - /* we know the value is XML type */ - str = DatumGetCString(DirectFunctionCall1(xml_out, - value)); - appendStringInfoString(&buf, str); - pfree(str); - } - } - - if (!found_arg) - appendStringInfo(&buf, "/>"); - else - appendStringInfo(&buf, "</%s>", xexpr->name); - break; - case IS_XMLFOREST: initStringInfo(&buf); i = 0; @@ -2754,6 +2704,11 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext, break; /* The remaining cases don't need to set up buf */ + case IS_XMLELEMENT: + *isNull = false; + return PointerGetDatum(xmlelement(xmlExpr, econtext)); + break; + case IS_XMLPARSE: { ExprState *e; |