Search Postgresql Archives

user defined XML aggregate not working as (i think) it should

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings!

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.

create schema kml;

CREATE  FUNCTION kml.precon(text, text) RETURNS text AS $$ select
$1||$2  $$  LANGUAGE sql;

CREATE FUNCTION kml.precon(xml, xml) RETURNS xml AS $$ select
xmlconcat($1,$2) $$   LANGUAGE sql;

CREATE AGGREGATE kml.documentagg(text) (  SFUNC=kml.precon,
STYPE=text,  INITCOND='');

CREATE AGGREGATE kml.documentagg(xml) (SFUNC=kml.precon,   STYPE=xml,
INITCOND='');

with one as (
select '<Placemark><name>892033</name><description>MRIL-JULY-2012_RA
265/5-410</description><Point><coordinates>-76.801342826571982,17.98077767785141</coordinates></Point></Placemark>'
k
union
select '<Placemark><name>900527</name><description>MRIL-JULY-2012_RA
265/5-810 </description><Point><coordinates>-76.803804151610237,17.98304310341128</coordinates></Point></Placemark>'
union
select '<Placemark><name>920661</name><description>MRIL-JULY-2012_RA
001/6-310</description><Point><coordinates>-77.886619999671524,18.441619925883373</coordinates></Point></Placemark>'
)

select k from one ;  /* returns 3 rows of text. expected*/

select k::xml from one ;  /* returns 3 rows of xml. expected*/

select kml.documentagg(k) from one; /* returns one row text */

select kml.documentagg(k)::xml from one; /* returns one row xml */

select kml.documentagg(k::xml) from one ; /* ********** Error
********** ERROR: invalid XML content SQL state: 2200N */


Given that the text agg can be cast to xml without any errors I'm at a
loss as to why the xml agg is failing.

Regards,

Rhys


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux