Re: functions returning sets - Mailing list pgsql-general

From Jeff Rogers
Subject Re: functions returning sets
Date
Msg-id 200312160020.hBG0K4r01615@findlaw.com.
Whole thread Raw
In response to Re: functions returning sets  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: functions returning sets
List pgsql-general
> > select file from xml_files where 'foo' in (select pgxml_xpath(doc,'/top/nod
> e'))
> > parses, but it doesn't seem to give correct results.
>
> That should work as far as I know.  Can you give more detail?
>
>             regards, tom lane

Cut & paste from a window:

xml=# create table foo (id text, doc text) ;
CREATE TABLE
xml=# insert into foo values (1,'<top><node>a</node><node>b</node></top>');
INSERT 22106552 1
xml=# insert into foo values (2,'<top><node>a</node><node>b</node></top>');
INSERT 22106553 1
xml=# insert into foo values (3,'<top><node>a</node><node>b</node></top>');
INSERT 22106554 1
xml=# select id,pgxml_xpath(doc,'/top/node') from foo ;
 id | pgxml_xpath
----+-------------
 1  | a
 1  | b
 2  | a
 2  | b
 3  | a
 3  | b
(6 rows)

xml=# select id from foo where 'a' in (select pgxml_xpath(doc,'/top/node'));
 id
----
 1
 3
(2 rows)

I expect this latter to return all the ids, but it seems to only return every
other one.

-J


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [NOVICE] PostgreSQL Training
Next
From: Tom Lane
Date:
Subject: Re: functions returning sets