Skip site navigation (1) Skip section navigation (2)

BUG #5434: select from xpath_table gives wrong results

From: "Oleg" <sacramento_fan(at)mail(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5434: select from xpath_table gives wrong results
Date: 2010-04-22 08:45:51
Message-ID: 201004220845.o3M8jpKi042967@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      5434
Logged by:          Oleg
Email address:      sacramento_fan(at)mail(dot)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?

Responses

pgsql-bugs by date

Next:From: Robert HaasDate: 2010-04-22 14:40:23
Subject: Re: BUG #5434: select from xpath_table gives wrong results
Previous:From: Jaime CasanovaDate: 2010-04-22 07:11:58
Subject: Fwd: BUG #5433: pg_dump (8.4.3) copy database failure!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group