xml.c.diff
text/x-patch
114d113
< static text *xml_xmlpathobjtoxmltype(xmlXPathObjectPtr cur);
3269,3309d3267
<
< /*
< * Convert XML pathobject to text for non-nodeset objects
< */
< static text *
< xml_xmlpathobjtoxmltype(xmlXPathObjectPtr cur)
< {
< xmltype *result;
<
< if (cur->type == XPATH_BOOLEAN)
< {
< PG_TRY();
< {
< result = cstring_to_text((char *)(xmlXPathCastToBoolean(cur)?"t":"f"));
< }
< PG_CATCH();
< {
< PG_RE_THROW();
< }
< PG_END_TRY();
< }
< else
< {
< xmlChar *str;
<
< str = xmlXPathCastToString(cur);
< PG_TRY();
< {
< result = (xmltype *) cstring_to_text((char *) str);
< }
< PG_CATCH();
< {
< xmlFree(str);
< PG_RE_THROW();
< }
< PG_END_TRY();
< xmlFree(str);
< }
<
< return result;
< }
3463,3471c3421,3429
< switch (xpathobj->type) {
< case XPATH_NODESET: {
< /* return empty array in cases when nothing is found */
< if (xpathobj->nodesetval == NULL)
< res_nitems = 0;
< else
< res_nitems = xpathobj->nodesetval->nodeNr;
<
< if (res_nitems)
---
> /* return empty array in cases when nothing is found */
> if (xpathobj->nodesetval == NULL)
> res_nitems = 0;
> else
> res_nitems = xpathobj->nodesetval->nodeNr;
>
> if (res_nitems)
> {
> for (i = 0; i < xpathobj->nodesetval->nodeNr; i++)
3473,3482c3431,3437
< for (i = 0; i < xpathobj->nodesetval->nodeNr; i++)
< {
< Datum elem;
< bool elemisnull = false;
<
< elem = PointerGetDatum(xml_xmlnodetoxmltype(xpathobj->nodesetval->nodeTab[i]));
< astate = accumArrayResult(astate, elem,
< elemisnull, XMLOID,
< CurrentMemoryContext);
< }
---
> Datum elem;
> bool elemisnull = false;
>
> elem = PointerGetDatum(xml_xmlnodetoxmltype(xpathobj->nodesetval->nodeTab[i]));
> astate = accumArrayResult(astate, elem,
> elemisnull, XMLOID,
> CurrentMemoryContext);
3484d3438
< break;
3486,3500d3439
< case XPATH_BOOLEAN:
< case XPATH_NUMBER:
< case XPATH_STRING: {
< Datum elem;
< bool elemisnull = false;
<
< elem = PointerGetDatum(xml_xmlpathobjtoxmltype(xpathobj));
< astate = accumArrayResult(astate, elem,
< elemisnull, XMLOID,
< CurrentMemoryContext);
< break;
< }
< default: {
< }
< }
3524c3463
< if (astate== NULL)
---
> if (res_nitems == 0)