Re: user defined XML aggregate not working as (i think) it should - Mailing list pgsql-general

From Tom Lane
Subject Re: user defined XML aggregate not working as (i think) it should
Date
Msg-id 12551.1349315897@sss.pgh.pa.us
Whole thread Raw
In response to user defined XML aggregate not working as (i think) it should  ("Rhys A.D. Stewart" <rhys.stewart@gmail.com>)
Responses Re: user defined XML aggregate not working as (i think) it should  ("Rhys A.D. Stewart" <rhys.stewart@gmail.com>)
List pgsql-general
"Rhys A.D. Stewart" <rhys.stewart@gmail.com> writes:
> I have an xml aggregate function that  always returns 'ERROR:  invalid
> XML content'. However an identical function that uses text produces
> valid xml with the same inputs.

I believe the reason this doesn't work is that the aggregate's initial
value is faulty: it's supposed to be an XML value and it isn't.

regression=# select ''::xml;
ERROR:  invalid XML content
LINE 1: select ''::xml;
               ^

It's unfortunate that the CREATE AGGREGATE command doesn't complain
about that --- maybe we could improve it.

As far as making a working aggregate goes, I'd try leaving off the
initcond clause (so that the initial value is NULL) and then marking
the transition function STRICT.  (plays around with xmlconcat on
nulls ...) hm, maybe you'd not even need the STRICT marking, though
personally I'd suggest it.

            regards, tom lane


pgsql-general by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Fwd: pros and cons of two security models
Next
From: Chris Travers
Date:
Subject: Re: Fwd: pros and cons of two security models