pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13756: jsonb_path_ops gin index produce empty result on nested array
3+ messages / 3 participants
[nested] [flat]

* BUG #13756: jsonb_path_ops gin index produce empty result on nested array
@ 2015-11-05 17:19 sdiz@sdiz.net
  2015-11-05 20:32 ` Re: BUG #13756: jsonb_path_ops gin index produce empty result on nested array Peter Geoghegan <pg@heroku.com>
  2015-11-05 23:18 ` Re: BUG #13756: jsonb_path_ops gin index produce empty result on nested array Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: sdiz@sdiz.net @ 2015-11-05 17:19 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13756
Logged by:          Daniel Cheng
Email address:      sdiz@sdiz.net
PostgreSQL version: 9.4.5
Operating system:   Debian (testing)
Description:        

Table with jsonb_path_ops produce wrong result when using the following
query.
Same query produce different result depends on which query plan is used.



db=> select version();
                                                version                     
                           
--------------------------------------------------------------------------------------------------------
 PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (Debian
5.2.1-21) 5.2.1 20151003, 64-bit
(1 row)

db=> 
db=> create table t ( j jsonb);
CREATE TABLE
db=> insert into t (j) values ('{"a":[ ["b",{"x":1}], ["b",{"x":2}]]}');
INSERT 0 1
db=> create index on t USING   gin(j jsonb_path_ops) ;
CREATE INDEX
db=> select * from t where j @> '{"a":[[{"x":2}]]}'::jsonb;
                     j                     
-------------------------------------------
 {"a": [["b", {"x": 1}], ["b", {"x": 2}]]}
(1 row)

db=> SET enable_seqscan = OFF;
SET
db=> select * from t where j @> '{"a":[[{"x":2}]]}'::jsonb;
 j 
---
(0 rows)
db=> explain analyse select * from t where j @> '{"a":[[{"x":2}]]}'::jsonb;
                                                   QUERY PLAN               
                                    
-----------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on t  (cost=8.00..12.01 rows=1 width=32) (actual
time=0.010..0.010 rows=0 loops=1)
   Recheck Cond: (j @> '{"a": [[{"x": 2}]]}'::jsonb)
   ->  Bitmap Index Scan on t_j_idx1  (cost=0.00..8.00 rows=1 width=0)
(actual time=0.009..0.009 rows=0 loops=1)
         Index Cond: (j @> '{"a": [[{"x": 2}]]}'::jsonb)
 Planning time: 0.059 ms
 Execution time: 0.032 ms
(6 rows)

db=> drop table t;
DROP TABLE


Regards,
Daniel


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #13756: jsonb_path_ops gin index produce empty result on nested array
  2015-11-05 17:19 BUG #13756: jsonb_path_ops gin index produce empty result on nested array sdiz@sdiz.net
@ 2015-11-05 20:32 ` Peter Geoghegan <pg@heroku.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Peter Geoghegan @ 2015-11-05 20:32 UTC (permalink / raw)
  To: sdiz@sdiz.net; +Cc: pgsql-bugs

On Thu, Nov 5, 2015 at 9:19 AM,  <sdiz@sdiz.net> wrote:
> Table with jsonb_path_ops produce wrong result when using the following
> query.

I can reproduce this.

I agree that this does look like a bug in jsonb_path_ops. Investigating.

Thanks for the test case.

-- 
Peter Geoghegan


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #13756: jsonb_path_ops gin index produce empty result on nested array
  2015-11-05 17:19 BUG #13756: jsonb_path_ops gin index produce empty result on nested array sdiz@sdiz.net
@ 2015-11-05 23:18 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2015-11-05 23:18 UTC (permalink / raw)
  To: sdiz@sdiz.net; +Cc: pgsql-bugs

sdiz@sdiz.net writes:
> Table with jsonb_path_ops produce wrong result when using the following
> query.

Fix pushed here:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=788e35ac0bc00489e2b86a930d8c126410...

Thanks for the report!

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-11-05 23:18 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-11-05 17:19 BUG #13756: jsonb_path_ops gin index produce empty result on nested array sdiz@sdiz.net
2015-11-05 20:32 ` Peter Geoghegan <pg@heroku.com>
2015-11-05 23:18 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox