The following bug has been logged online:

Bug reference:      5434
Logged by:          Oleg
Email address:      sacramento_...@mail.ru
PostgreSQL version: 8.4.3
Operating system:   KUbuntu
Description:        select from xpath_table gives wrong results
Details: 

Here is a code:

create table tmp_xml(rowId SERIAL UNIQUE NOT NULL,
                  xml_context xml,
                  CONSTRAINT PK_tmp_xml PRIMARY KEY (rowId));

insert into tmp_xml (xml_context)
values('<root>'
         '<obj obj_id="1" obj_name="First Object"/>'
         '<obj obj_id="2" obj_name="Second Object" obj_master="1"/>'
         '<obj obj_id="3" obj_name="Third Object"/>'
         '<obj obj_id="4" obj_name="Fourth Object" obj_master="1"/>'
       '</root>');

SELECT t.OBJ_ID, t.OBJ_NAME, t.OBJ_MASTER
FROM xpath_table('rowId',
                 'xml_context',
                'tmp_xml',
               
'/root/obj/@obj_id|/root/obj/@obj_name|/root/obj/@obj_master|',
                 'true')
        AS t(row_id integer, 
             OBJ_ID integer, 
             OBJ_NAME varchar(255),
             OBJ_MASTER INT
             );

I was sure, that result of this query should be like this:

obj_id | obj_name        | obj_master
----------------------------------------
   1   |   First Object  |   
   2   |   Second Object |    1
   3   |   Third Object  | 
   4   |   Fourth Object |    1

But instead of I got this result:

obj_id | obj_name        | obj_master
----------------------------------------
   1   |   First Object  |    1
   2   |   Second Object |    1
   3   |   Third Object  | 
   4   |   Fourth Object |    

Why is this so? Maybe I use xpath_table wrong way?

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

Reply via email to