Subject: possible to create multivalued index from xpath() results in 8.3?
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/19/2007 10:20:24 AM
"Matt Magoffin" <postgresql.org@msqr.us> writes:
> 2) Even if I could have an xpath() result return an array with multiple
> values, like {value1,value2,value3} I wasn't able to define a GIN index
> against the xml[] type. Should this be possible?
Dunno about your other questions, but the answer to this one is "no"
--- AFAICS there is no indexing support of any kind for the xml type
in 8.3. Try casting to text[] instead.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
Subject: possible to create multivalued index from xpath() results in 8.3?
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/20/2007 2:29:42 PM
"Matt Magoffin" <postgresql.org@msqr.us> writes:
> Should the xpath() function return 3 individual text nodes like this:
> /elem[@key="mykey"]/text() => {
> value1,
> value2,
> value3
> }
> rather than concatenating these into a single text node result?
AFAICT that's exactly what it does.
regression=# select xpath('//foo[@key="mykey"]/text()', '<value>ABC<foo key="mykey">XYZ</foo></value><foo key="mykey">RST</foo><foo>DEF</foo>');
xpath
-----------
{XYZ,RST}
(1 row)
regression=#
Of course this is of type xml[], but you can cast to text[] and then
index.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
Subject: possible to create multivalued index from xpath() results in 8.3?
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/20/2007 10:38:16 PM
"Matt Magoffin" <postgresql.org@msqr.us> writes:
> Ugh, you're right of course! Somehow I had this wrong. So I tried to
> create an index on the xml[] result by casting to text[] but I got the
> "function must be immutable" error. Is there any reason the xml[] to
> text[] cast is not immutable?
Hmm ... I see that xmltotext() is marked 'stable' in pg_proc.h,
but texttoxml() is marked 'immutable', which is at best inconsistent.
It looks to me like they both depend on the GUC setting "xmloption",
which would mean they should both be stable. Peter, is there a bug
there? Also, is there a way to get rid of the GUC dependency so that
there's a reasonably safe way to index XML values?
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
|