Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZuQ0y-0006sk-Ir for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2015 19:16:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZuQ0x-0000dk-Eb for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2015 19:16:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZuOCk-0008Cs-Lz for pgsql-bugs@postgresql.org; Thu, 05 Nov 2015 17:20:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZuOCh-0001nP-Dd for pgsql-bugs@postgresql.org; Thu, 05 Nov 2015 17:20:05 +0000 MIME-Version: 1.0 Subject: BUG #13756: jsonb_path_ops gin index produce empty result on nested array To: pgsql-bugs@postgresql.org From: sdiz@sdiz.net Date: Thu, 05 Nov 2015 17:19:33 +0000 Message-ID: <20151105171933.14035.25039@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.1 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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