diff -Nru jsquery-1.1.1/debian/changelog jsquery-1.2/debian/changelog --- jsquery-1.1.1/debian/changelog 2023-07-31 09:35:36.000000000 +0000 +++ jsquery-1.2/debian/changelog 2023-10-21 11:15:58.000000000 +0000 @@ -1,3 +1,16 @@ +jsquery (1.2-1) unstable; urgency=medium + + * New upstream version 1.2. + + -- Christoph Berg Sat, 21 Oct 2023 13:15:58 +0200 + +jsquery (1.1.1-8) unstable; urgency=medium + + * Upload for PostgreSQL 16. + * Use ${postgresql:Depends}. + + -- Christoph Berg Sat, 16 Sep 2023 15:18:06 +0200 + jsquery (1.1.1-7) unstable; urgency=medium * Fix Datum handling on PG16. diff -Nru jsquery-1.1.1/debian/control jsquery-1.2/debian/control --- jsquery-1.1.1/debian/control 2023-07-31 09:35:34.000000000 +0000 +++ jsquery-1.2/debian/control 2023-10-21 11:12:45.000000000 +0000 @@ -8,15 +8,15 @@ debhelper-compat (= 13), flex, postgresql-all (>= 217~), -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Rules-Requires-Root: no Homepage: https://github.com/postgrespro/jsquery Vcs-Browser: https://salsa.debian.org/postgresql/jsquery Vcs-Git: https://salsa.debian.org/postgresql/jsquery.git -Package: postgresql-15-jsquery +Package: postgresql-16-jsquery Architecture: any -Depends: postgresql-15, ${misc:Depends}, ${shlibs:Depends} +Depends: ${postgresql:Depends}, ${misc:Depends}, ${shlibs:Depends} Description: PostgreSQL JSON query language with GIN indexing support JsQuery provides additional functionality for the PostgreSQL jsonb datatype, such as a simple and effective way to search in nested objects and arrays, and diff -Nru jsquery-1.1.1/debian/control.in jsquery-1.2/debian/control.in --- jsquery-1.1.1/debian/control.in 2023-07-31 09:29:37.000000000 +0000 +++ jsquery-1.2/debian/control.in 2023-10-21 11:12:45.000000000 +0000 @@ -8,7 +8,7 @@ debhelper-compat (= 13), flex, postgresql-all (>= 217~), -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Rules-Requires-Root: no Homepage: https://github.com/postgrespro/jsquery Vcs-Browser: https://salsa.debian.org/postgresql/jsquery @@ -16,7 +16,7 @@ Package: postgresql-PGVERSION-jsquery Architecture: any -Depends: postgresql-PGVERSION, ${misc:Depends}, ${shlibs:Depends} +Depends: ${postgresql:Depends}, ${misc:Depends}, ${shlibs:Depends} Description: PostgreSQL JSON query language with GIN indexing support JsQuery provides additional functionality for the PostgreSQL jsonb datatype, such as a simple and effective way to search in nested objects and arrays, and diff -Nru jsquery-1.1.1/debian/patches/bison3.7 jsquery-1.2/debian/patches/bison3.7 --- jsquery-1.1.1/debian/patches/bison3.7 2023-07-31 09:29:37.000000000 +0000 +++ jsquery-1.2/debian/patches/bison3.7 1970-01-01 00:00:00.000000000 +0000 @@ -1,3382 +0,0 @@ ---- /dev/null -+++ b/expected/jsquery_1.out -@@ -0,0 +1,3379 @@ -+CREATE EXTENSION jsquery; -+set escape_string_warning=off; -+set standard_conforming_strings=on; -+CREATE TABLE test_jsquery (v jsonb); -+\copy test_jsquery from 'data/test_jsquery.data' -+select 'asd.zzz = 13'::jsquery; -+ jsquery -+------------------ -+ "asd"."zzz" = 13 -+(1 row) -+ -+select 'asd.zzz < 13'::jsquery; -+ jsquery -+------------------ -+ "asd"."zzz" < 13 -+(1 row) -+ -+select 'asd(zzz < 13)'::jsquery; -+ jsquery -+------------------ -+ "asd"."zzz" < 13 -+(1 row) -+ -+select 'asd(zzz < 13 AND x = true)'::jsquery; -+ jsquery -+---------------------------------- -+ "asd"("zzz" < 13 AND "x" = true) -+(1 row) -+ -+select 'asd(zzz < 13 AND x = "true")'::jsquery; -+ jsquery -+------------------------------------ -+ "asd"("zzz" < 13 AND "x" = "true") -+(1 row) -+ -+select 'asd(zzz < 13 AND x.zxc = "true")'::jsquery; -+ jsquery -+------------------------------------------ -+ "asd"("zzz" < 13 AND "x"."zxc" = "true") -+(1 row) -+ -+select 'asd(zzz < 13 OR #.zxc = "true" /* test */)'::jsquery; -+ jsquery -+--------------------------------------- -+ "asd"("zzz" < 13 OR #."zxc" = "true") -+(1 row) -+ -+select 'asd(* < 13 AND /* ttt */ #.zxc = "true")'::jsquery; -+ jsquery -+------------------------------------ -+ "asd"(* < 13 AND #."zxc" = "true") -+(1 row) -+ -+select '(* < 13 AND #.zxc = "true")'::jsquery; -+ jsquery -+------------------------------- -+ (* < 13 AND #."zxc" = "true") -+(1 row) -+ -+select '* < 13 AND #.zxc/* t2 */ = "true"'::jsquery; -+ jsquery -+------------------------------- -+ (* < 13 AND #."zxc" = "true") -+(1 row) -+ -+select '* < 13 AND #.zxc"x" = "true"'::jsquery; -+ERROR: bad jsquery representation -+LINE 1: select '* < 13 AND #.zxc"x" = "true"'::jsquery; -+ ^ -+DETAIL: syntax error, unexpected STRING_P, expecting end of file at or near """ -+select 'a < 1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < -1'::jsquery; -+ jsquery -+---------- -+ "a" < -1 -+(1 row) -+ -+select 'a < +1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < .1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < -.1'::jsquery; -+ jsquery -+------------ -+ "a" < -0.1 -+(1 row) -+ -+select 'a < +.1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < 0.1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < -0.1'::jsquery; -+ jsquery -+------------ -+ "a" < -0.1 -+(1 row) -+ -+select 'a < +0.1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < 10.1'::jsquery; -+ jsquery -+------------ -+ "a" < 10.1 -+(1 row) -+ -+select 'a < -10.1'::jsquery; -+ jsquery -+------------- -+ "a" < -10.1 -+(1 row) -+ -+select 'a < +10.1'::jsquery; -+ jsquery -+------------ -+ "a" < 10.1 -+(1 row) -+ -+select 'a < 1e1'::jsquery; -+ jsquery -+---------- -+ "a" < 10 -+(1 row) -+ -+select 'a < -1e1'::jsquery; -+ jsquery -+----------- -+ "a" < -10 -+(1 row) -+ -+select 'a < +1e1'::jsquery; -+ jsquery -+---------- -+ "a" < 10 -+(1 row) -+ -+select 'a < .1e1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < -.1e1'::jsquery; -+ jsquery -+---------- -+ "a" < -1 -+(1 row) -+ -+select 'a < +.1e1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < 0.1e1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < -0.1e1'::jsquery; -+ jsquery -+---------- -+ "a" < -1 -+(1 row) -+ -+select 'a < +0.1e1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < 10.1e1'::jsquery; -+ jsquery -+----------- -+ "a" < 101 -+(1 row) -+ -+select 'a < -10.1e1'::jsquery; -+ jsquery -+------------ -+ "a" < -101 -+(1 row) -+ -+select 'a < +10.1e1'::jsquery; -+ jsquery -+----------- -+ "a" < 101 -+(1 row) -+ -+select 'a < 1e-1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < -1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < -0.1 -+(1 row) -+ -+select 'a < +1e-1'::jsquery; -+ jsquery -+----------- -+ "a" < 0.1 -+(1 row) -+ -+select 'a < .1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 0.01 -+(1 row) -+ -+select 'a < -.1e-1'::jsquery; -+ jsquery -+------------- -+ "a" < -0.01 -+(1 row) -+ -+select 'a < +.1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 0.01 -+(1 row) -+ -+select 'a < 0.1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 0.01 -+(1 row) -+ -+select 'a < -0.1e-1'::jsquery; -+ jsquery -+------------- -+ "a" < -0.01 -+(1 row) -+ -+select 'a < +0.1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 0.01 -+(1 row) -+ -+select 'a < 10.1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 1.01 -+(1 row) -+ -+select 'a < -10.1e-1'::jsquery; -+ jsquery -+------------- -+ "a" < -1.01 -+(1 row) -+ -+select 'a < +10.1e-1'::jsquery; -+ jsquery -+------------ -+ "a" < 1.01 -+(1 row) -+ -+select 'a < 1e+1'::jsquery; -+ jsquery -+---------- -+ "a" < 10 -+(1 row) -+ -+select 'a < -1e+1'::jsquery; -+ jsquery -+----------- -+ "a" < -10 -+(1 row) -+ -+select 'a < +1e+1'::jsquery; -+ jsquery -+---------- -+ "a" < 10 -+(1 row) -+ -+select 'a < .1e+1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < -.1e+1'::jsquery; -+ jsquery -+---------- -+ "a" < -1 -+(1 row) -+ -+select 'a < +.1e+1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < 0.1e+1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < -0.1e+1'::jsquery; -+ jsquery -+---------- -+ "a" < -1 -+(1 row) -+ -+select 'a < +0.1e+1'::jsquery; -+ jsquery -+--------- -+ "a" < 1 -+(1 row) -+ -+select 'a < 10.1e+1'::jsquery; -+ jsquery -+----------- -+ "a" < 101 -+(1 row) -+ -+select 'a < -10.1e+1'::jsquery; -+ jsquery -+------------ -+ "a" < -101 -+(1 row) -+ -+select 'a < +10.1e+1'::jsquery; -+ jsquery -+----------- -+ "a" < 101 -+(1 row) -+ -+select 'a in (0,1,2)'::jsquery; -+ jsquery -+------------------ -+ "a" IN (0, 1, 2) -+(1 row) -+ -+select 'a IN (0,null, "null", xxx, "zzz", 2)'::jsquery; -+ jsquery -+------------------------------------------- -+ "a" IN (0, null, "null", "xxx", "zzz", 2) -+(1 row) -+ -+select 'not < 1'::jsquery; -+ jsquery -+----------- -+ "not" < 1 -+(1 row) -+ -+select 'not not < 1'::jsquery; -+ jsquery -+----------------- -+ (NOT "not" < 1) -+(1 row) -+ -+select 'not( not < 1)'::jsquery; -+ jsquery -+----------------- -+ (NOT "not" < 1) -+(1 row) -+ -+select 'not.x < 1'::jsquery; -+ jsquery -+--------------- -+ "not"."x" < 1 -+(1 row) -+ -+select 'x.not < 1'::jsquery; -+ jsquery -+--------------- -+ "x"."not" < 1 -+(1 row) -+ -+select 'a.%(not x > 0 and not (y < 0 or z = 0))'::jsquery; -+ jsquery -+----------------------------------------------------- -+ "a".%((NOT "x" > 0) AND (NOT ("y" < 0 OR "z" = 0))) -+(1 row) -+ -+select 'is < 1'::jsquery; -+ jsquery -+---------- -+ "is" < 1 -+(1 row) -+ -+select 'in < 1'::jsquery; -+ jsquery -+---------- -+ "in" < 1 -+(1 row) -+ -+select 'not is < 1'::jsquery; -+ jsquery -+---------------- -+ (NOT "is" < 1) -+(1 row) -+ -+select 'not in < 1'::jsquery; -+ jsquery -+---------------- -+ (NOT "in" < 1) -+(1 row) -+ -+select 'in in (1,2)'::jsquery; -+ jsquery -+---------------- -+ "in" IN (1, 2) -+(1 row) -+ -+select 'is in (1,2)'::jsquery; -+ jsquery -+---------------- -+ "is" IN (1, 2) -+(1 row) -+ -+select 'not in (1,2)'::jsquery; -+ jsquery -+----------------- -+ "not" IN (1, 2) -+(1 row) -+ -+select 'in is numeric'::jsquery; -+ jsquery -+----------------- -+ "in" IS NUMERIC -+(1 row) -+ -+select 'is is numeric'::jsquery; -+ jsquery -+----------------- -+ "is" IS NUMERIC -+(1 row) -+ -+select 'not is numeric'::jsquery; -+ jsquery -+------------------ -+ "not" IS NUMERIC -+(1 row) -+ -+select 'not.in < 1'::jsquery; -+ jsquery -+---------------- -+ "not"."in" < 1 -+(1 row) -+ -+select 'not.is < 1'::jsquery; -+ jsquery -+---------------- -+ "not"."is" < 1 -+(1 row) -+ -+select 'not.not < 1'::jsquery; -+ jsquery -+----------------- -+ "not"."not" < 1 -+(1 row) -+ -+select 'in.in < 1'::jsquery; -+ jsquery -+--------------- -+ "in"."in" < 1 -+(1 row) -+ -+select 'in.is < 1'::jsquery; -+ jsquery -+--------------- -+ "in"."is" < 1 -+(1 row) -+ -+select 'in.not < 1'::jsquery; -+ jsquery -+---------------- -+ "in"."not" < 1 -+(1 row) -+ -+select 'is.in < 1'::jsquery; -+ jsquery -+--------------- -+ "is"."in" < 1 -+(1 row) -+ -+select 'is.is < 1'::jsquery; -+ jsquery -+--------------- -+ "is"."is" < 1 -+(1 row) -+ -+select 'is.not < 1'::jsquery; -+ jsquery -+---------------- -+ "is"."not" < 1 -+(1 row) -+ -+select 'a.b.#4 > 4'::jsquery; -+ jsquery -+---------------- -+ "a"."b".#4 > 4 -+(1 row) -+ -+select 'a.b.#10203.* > 4'::jsquery; -+ jsquery -+---------------------- -+ "a"."b".#10203.* > 4 -+(1 row) -+ -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; -+ false -+------- -+ f -+(1 row) -+ -+select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; -+ ?column? -+------------------------------------------------------ -+ (("asd".# = 3 AND "zzz" = true) OR "xxx".# = "zero") -+(1 row) -+ -+select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; -+ ?column? -+------------------------------------------------------------------ -+ (((NOT "asd".# = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) -+(1 row) -+ -+select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; -+ ?column? -+----------------------------------------------------------------------- -+ (((NOT "asd".#3."f" = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) -+(1 row) -+ -+select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+--Unicode -+select 'a\t = "dollar \u0024 character"'::jsquery; -+ jsquery -+------------------------------ -+ "a\t" = "dollar $ character" -+(1 row) -+ -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select 'a\r = "\n\""'::jsquery; -+ jsquery -+---------------- -+ "a\r" = "\n\"" -+(1 row) -+ -+select 'a\r = "\u0000"'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = "\u0000"'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = \u0000'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = \u0000'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = "\abcd"'::jsquery AS err; -+ERROR: bad jsquery representation -+LINE 1: select 'a\r = "\abcd"'::jsquery AS err; -+ ^ -+DETAIL: Escape sequence is invalid at or near "\a" -+select 'a\r = "\\abcd"'::jsquery; -+ jsquery -+------------------ -+ "a\r" = "\\abcd" -+(1 row) -+ -+select 'a\r = "x\u0000"'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = "x\u0000"'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = x\u0000'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = x\u0000'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = "x\abcd"'::jsquery AS err; -+ERROR: bad jsquery representation -+LINE 1: select 'a\r = "x\abcd"'::jsquery AS err; -+ ^ -+DETAIL: Escape sequence is invalid at or near "\a" -+select 'a\r = "x\\abcd"'::jsquery; -+ jsquery -+------------------- -+ "a\r" = "x\\abcd" -+(1 row) -+ -+select 'a\r = "x\u0000x"'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = "x\u0000x"'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = x\u0000x'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = x\u0000x'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = "x\abcdx"'::jsquery AS err; -+ERROR: bad jsquery representation -+LINE 1: select 'a\r = "x\abcdx"'::jsquery AS err; -+ ^ -+DETAIL: Escape sequence is invalid at or near "\a" -+select 'a\r = "x\\abcdx"'::jsquery; -+ jsquery -+-------------------- -+ "a\r" = "x\\abcdx" -+(1 row) -+ -+select 'a\r = "\u0000x"'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = "\u0000x"'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = \u0000x'::jsquery; -+ERROR: unsupported Unicode escape sequence -+LINE 1: select 'a\r = \u0000x'::jsquery; -+ ^ -+DETAIL: \u0000 cannot be converted to text. -+select 'a\r = "\abcdx"'::jsquery AS err; -+ERROR: bad jsquery representation -+LINE 1: select 'a\r = "\abcdx"'::jsquery AS err; -+ ^ -+DETAIL: Escape sequence is invalid at or near "\a" -+select 'a\r = "\\abcdx"'::jsquery; -+ jsquery -+------------------- -+ "a\r" = "\\abcdx" -+(1 row) -+ -+select 'a\r = x"\\abcd"'::jsquery AS err; -+ERROR: bad jsquery representation -+LINE 1: select 'a\r = x"\\abcd"'::jsquery AS err; -+ ^ -+DETAIL: syntax error, unexpected STRING_P, expecting end of file at or near """ -+--IS -+select 'as IS boolean OR as is ARRAY OR as is ObJect OR as is Numeric OR as is string'::jsquery; -+ jsquery -+------------------------------------------------------------------------------------------------- -+ (((("as" IS BOOLEAN OR "as" IS ARRAY) OR "as" IS OBJECT) OR "as" IS NUMERIC) OR "as" IS STRING) -+(1 row) -+ -+select '{"as": "xxx"}' @@ 'as IS string'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"as": "xxx"}' @@ 'as IS boolean OR as is ARRAY OR as is ObJect OR as is Numeric'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"as": 5}' @@ 'as is Numeric'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"as": true}' @@ 'as is boolean'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"as": false}' @@ 'as is boolean'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"as": "false"}' @@ 'as is boolean'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '["xxx"]' @@ '$ IS array'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"as": false}' @@ '$ IS object'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '"xxx"' @@ '$ IS string'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '"xxx"' @@ '$ IS numeric'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+--hint -+select 'a /*-- noindex */ = 5'::jsquery; -+ jsquery -+-------------------------- -+ "a" /*-- noindex */ = 5 -+(1 row) -+ -+select 'a /*-- index */ = 5'::jsquery; -+ jsquery -+------------------------ -+ "a" /*-- index */ = 5 -+(1 row) -+ -+select 'asd.# = 3'::jsquery & 'zzz /*-- noindex */ = true' | 'xxx.# /*-- index */ = zero'; -+ ?column? -+-------------------------------------------------------------------------------------- -+ (("asd".# = 3 AND "zzz" /*-- noindex */ = true) OR "xxx".# /*-- index */ = "zero") -+(1 row) -+ -+select 'a /*-- xxx */ = 5'::jsquery; -+ jsquery -+--------- -+ "a" = 5 -+(1 row) -+ -+select 'a /* index */ = 5'::jsquery; -+ jsquery -+--------- -+ "a" = 5 -+(1 row) -+ -+select 'a /* noindex */ = 5'::jsquery; -+ jsquery -+--------- -+ "a" = 5 -+(1 row) -+ -+select 'a = /*-- noindex */ 5'::jsquery; -+ERROR: bad jsquery representation -+LINE 1: select 'a = /*-- noindex */ 5'::jsquery; -+ ^ -+DETAIL: syntax error, unexpected HINT_P at or near "*/" -+select 'a = /* noindex */ 5'::jsquery; -+ jsquery -+--------- -+ "a" = 5 -+(1 row) -+ -+--LENGTH -+select 'a.@# = 4'::jsquery; -+ jsquery -+------------ -+ "a".@# = 4 -+(1 row) -+ -+select 'a.@#.$ = 4'::jsquery as noerror; -+ noerror -+-------------- -+ "a".@#.$ = 4 -+(1 row) -+ -+select 'a.@#.a = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.a = 4'::jsquery as error; -+ ^ -+select 'a.@#.* = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.* = 4'::jsquery as error; -+ ^ -+select 'a.@#.% = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.% = 4'::jsquery as error; -+ ^ -+select 'a.@#.# = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.# = 4'::jsquery as error; -+ ^ -+select 'a.@#.*: = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.*: = 4'::jsquery as error; -+ ^ -+select 'a.@#.%: = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.%: = 4'::jsquery as error; -+ ^ -+select 'a.@#.#: = 4'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@#.#: = 4'::jsquery as error; -+ ^ -+select 'a.@# (a = 5 or b = 6)'::jsquery as error; -+ERROR: Array length should be last in path -+LINE 1: select 'a.@# (a = 5 or b = 6)'::jsquery as error; -+ ^ -+select '[]' @@ '@# = 0'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[]' @@ '@# < 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[]' @@ '@# > 1'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1]' @@ '@# = 0'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1]' @@ '@# < 2'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1]' @@ '@# > 1'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2]' @@ '@# = 0'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2]' @@ '@# < 2'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[1,2]' @@ '@# > 1'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2]' @@ '@# in (1, 2)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[1,2]' @@ '@# in (1, 3)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":[1,2]}' @@ '@# in (2, 4)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":[1,2]}' @@ 'a.@# in (2, 4)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":[1,2]}' @@ '%.@# in (2, 4)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":[1,2]}' @@ '*.@# in (2, 4)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":[1,2]}' @@ '*.@# ($ = 4 or $ = 2)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":[1,2]}' @@ '@# = 1'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+--filter -+select '?( not b>0). x'::jsquery; -+ jsquery -+------------------------ -+ ?((NOT "b" > 0)) ."x" -+(1 row) -+ -+select 'a.?(b>0 and x= 0 ) .c'::jsquery; -+ jsquery -+------------------------------------ -+ "a". ?(("b" > 0 AND "x" = 0)) ."c" -+(1 row) -+ -+select 'a.$. ?(b>0 and x= 0 ) . c.k'::jsquery; -+ jsquery -+------------------------------------------ -+ "a".$. ?(("b" > 0 AND "x" = 0)) ."c"."k" -+(1 row) -+ -+select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery; -+ jsquery -+-------------------------------------------- -+ "a".$. ?(("b" > 0 AND "x".* = 0)) ."c"."k" -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; -+ ?column? -+---------- -+ [1, 2] -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; -+ ?column? -+---------- -+ [20] -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; -+ ?column? -+---------------------------------------- -+ [{"a": 2, "b": 20}, {"a": 3, "b": 30}] -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; -+ ?column? -+---------- -+ -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; -+ ?column? -+----------- -+ [1, 2, 3] -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; -+ ?column? -+---------------------------- -+ [{"a": 1, "b": 2, "c": 3}] -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; -+ ?column? -+---------------------------- -+ [{"a": 1, "b": 2, "c": 3}] -+(1 row) -+ -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; -+ ?column? -+---------- -+ -+(1 row) -+ -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; -+ ?column? -+----------------------------------------------------------- -+ [{"a": 1, "b": 10}, {"a": 2, "b": 20}, {"a": 3, "b": 30}] -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ '#'::jsquery; -+ ?column? -+----------- -+ [1, 2, 3] -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; -+ ?column? -+------------- -+ [[1, 2, 3]] -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; -+ ?column? -+---------- -+ -+(1 row) -+ -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; -+ ?column? -+------------- -+ [[1, 2, 3]] -+(1 row) -+ -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; -+ ?column? -+------------ -+ [{"c": 1}] -+(1 row) -+ -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; -+ ?column? -+-------------------------- -+ [{"a": {"b": {"c": 1}}}] -+(1 row) -+ -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; -+ ?column? -+---------- -+ ["NYC"] -+(1 row) -+ -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; -+ ?column? -+------------------ -+ [["NYC", "CYN"]] -+(1 row) -+ -+--ALL -+select 'a.*: = 4'::jsquery; -+ jsquery -+------------ -+ "a".*: = 4 -+(1 row) -+ -+select '%: = 4'::jsquery; -+ jsquery -+--------- -+ %: = 4 -+(1 row) -+ -+select '#:.i = 4'::jsquery; -+ jsquery -+------------ -+ #:."i" = 4 -+(1 row) -+ -+select '[]' @@ '#: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[2,3,4]' @@ '#: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[2,3,5]' @@ '#: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[2,3,5]' @@ '# ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '[2,3,"x"]' @@ '#: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{}' @@ '%: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{}' @@ '*: ($ is object)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '"a"' @@ '*: is string'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '1' @@ '*: is string'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":2,"b":3,"c":4}' @@ '%: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":2,"b":3,"c":5}' @@ '%: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":2,"b":3,"c":5}' @@ '% ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":2,"b":3,"c":"x"}' @@ '%: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":2,"b":3,"c":4}' @@ '*: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":2,"b":3,"c":5}' @@ '*: ($ > 1 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":2,"b":3,"c":4}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":2,"b":3,"c":5}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"b":{"ba":3, "bb":4}}' @@ '*: ($ is object OR ($ > 1 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":4}}' @@ '*: ($ is object OR ($ > 0 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR ($> 0 and $ < 5))'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '* ($ > 0 and $ < 5)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":[5,6]}' @@ '*: ($ is object OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":[5,6]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":8}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":"x"}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":null}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}}' @@ '%:.aa is numeric'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1}, "b":{"aa":true, "bb":2}}' @@ '%:.aa is numeric'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}, "aa":16}' @@ '*: (not $ is object or $.aa is numeric)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}}' @@ '*: (not $ is object or $.aa is numeric or % is object)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+SELECT 'test.# IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64)'::jsquery; -+ jsquery -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -+ "test".# IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64) -+(1 row) -+ -+select '[]' @@ '(@# > 0 and #: = 16)'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; -+ ?column? -+---------- -+ t -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; -+ ?column? -+---------- -+ f -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; -+ ?column? -+---------- -+ [1, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; -+ ?column? -+---------- -+ -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; -+ ?column? -+---------- -+ [1, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; -+ ?column? -+---------- -+ [1, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; -+ ?column? -+----------- -+ [1, 2, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; -+ ?column? -+---------- -+ [1, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; -+ ?column? -+---------- -+ [2, 3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; -+ ?column? -+---------- -+ -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; -+ ?column? -+---------- -+ [1] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; -+ ?column? -+---------- -+ [3] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; -+ ?column? -+---------- -+ [1, 2] -+(1 row) -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; -+ ?column? -+----------- -+ [3, 1, 2] -+(1 row) -+ -+select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; -+ ?column? -+------------------- -+ [3, [6, 5, 4], 2] -+(1 row) -+ -+--extract entries for index scan -+SELECT gin_debug_query_path_value('NOT NOT NOT x(y(NOT (a=1) and NOT (b=2)) OR NOT NOT (c=3)) and z = 5'); -+ gin_debug_query_path_value -+---------------------------- -+ AND + -+ z = 5 , entry 0 + -+ OR + -+ x.y.a = 1 , entry 1 + -+ x.y.b = 2 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('NOT #(x=1) and NOT *(y=1) and NOT %(z=1) '); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#(NOT x=1) and *(NOT y=1) and %(NOT z=1) '); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('NOT #(NOT x=1) and NOT *(NOT y=1) and NOT %(NOT z=1) '); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#(x = "a" and y > 0 and y < 1 and z > 0)'); -+ gin_debug_query_path_value -+---------------------------- -+ #.x = "a" , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#(x = "a" and y /*-- index */ >= 0 and y < 1 and z > 0)'); -+ gin_debug_query_path_value -+----------------------------- -+ AND + -+ #.x = "a" , entry 0 + -+ #.y >= 0 , < 1 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#(x /*-- noindex */ = "a" and y > 0 and y <= 1 and z /*-- index */ > 0)'); -+ gin_debug_query_path_value -+----------------------------- -+ AND + -+ #.y > 0 , <= 1 , entry 0 + -+ #.z > 0 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x = 1 and (y /*-- index */ > 0 and y < 1 OR z > 0)'); -+ gin_debug_query_path_value -+---------------------------- -+ AND + -+ x = 1 , entry 0 + -+ OR + -+ y > 0 , < 1 , entry 1 + -+ z > 0 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('%.x = 1'); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('*.x = "b"'); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x && [1,2,3]'); -+ gin_debug_query_path_value -+---------------------------- -+ OR + -+ x.# = 1 , entry 0 + -+ x.# = 2 , entry 1 + -+ x.# = 3 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x @> [1,2,3]'); -+ gin_debug_query_path_value -+---------------------------- -+ AND + -+ x.# = 1 , entry 0 + -+ x.# = 2 , entry 1 + -+ x.# = 3 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x <@ [1,2,3]'); -+ gin_debug_query_path_value -+---------------------------- -+ OR + -+ x = [] , entry 0 + -+ x.# = 1 , entry 1 + -+ x.# = 2 , entry 2 + -+ x.# = 3 , entry 3 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x = *'); -+ gin_debug_query_path_value -+---------------------------- -+ x = * , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x is boolean'); -+ gin_debug_query_path_value -+---------------------------- -+ x IS boolean , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x is string'); -+ gin_debug_query_path_value -+---------------------------- -+ x IS string , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x is numeric'); -+ gin_debug_query_path_value -+---------------------------- -+ x IS numeric , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x is array'); -+ gin_debug_query_path_value -+---------------------------- -+ x IS array , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('x is object'); -+ gin_debug_query_path_value -+---------------------------- -+ x IS object , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#:(x=1) AND %:(y=1) AND *:(z=1)'); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)'); -+ gin_debug_query_path_value -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)'); -+ gin_debug_query_path_value -+---------------------------- -+ #.x = 1 , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('$ = true'); -+ gin_debug_query_path_value -+---------------------------- -+ $ = true , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('$ . ? (review_votes > 10) . review_rating < 7'); -+ gin_debug_query_path_value -+-------------------------------- -+ AND + -+ review_rating < 7 , entry 0 + -+ review_votes > 10 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_path_value('similar_product_ids . ? (# = "B0002W4TL2") . $'); -+ gin_debug_query_path_value -+------------------------------------------------- -+ similar_product_ids.# = "B0002W4TL2" , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('NOT NOT NOT x(y(NOT (a=1) and NOT (b=2)) OR NOT NOT (c=3)) and z = 5'); -+ gin_debug_query_value_path -+---------------------------- -+ AND + -+ z = 5 , entry 0 + -+ OR + -+ x.y.a = 1 , entry 1 + -+ x.y.b = 2 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('NOT #(x=1) and NOT *(y=1) and NOT %(z=1) '); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#(NOT x=1) and *(NOT y=1) and %(NOT z=1) '); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('NOT #(NOT x=1) and NOT *(NOT y=1) and NOT %(NOT z=1) '); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#(x = "a" and y > 0 and y < 1 and z > 0)'); -+ gin_debug_query_value_path -+---------------------------- -+ #.x = "a" , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#(x = "a" and y /*-- index */ >= 0 and y < 1 and z > 0)'); -+ gin_debug_query_value_path -+----------------------------- -+ AND + -+ #.x = "a" , entry 0 + -+ #.y >= 0 , < 1 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#(x /*-- noindex */ = "a" and y > 0 and y <= 1 and z /*-- index */ > 0)'); -+ gin_debug_query_value_path -+----------------------------- -+ AND + -+ #.y > 0 , <= 1 , entry 0 + -+ #.z > 0 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x = 1 and (y /*-- index */ > 0 and y < 1 OR z > 0)'); -+ gin_debug_query_value_path -+---------------------------- -+ AND + -+ x = 1 , entry 0 + -+ OR + -+ y > 0 , < 1 , entry 1 + -+ z > 0 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('%.x = 1'); -+ gin_debug_query_value_path -+---------------------------- -+ %.x = 1 , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('*.x = "b"'); -+ gin_debug_query_value_path -+---------------------------- -+ *.x = "b" , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x && [1,2,3]'); -+ gin_debug_query_value_path -+---------------------------- -+ OR + -+ x.# = 1 , entry 0 + -+ x.# = 2 , entry 1 + -+ x.# = 3 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x @> [1,2,3]'); -+ gin_debug_query_value_path -+---------------------------- -+ AND + -+ x.# = 1 , entry 0 + -+ x.# = 2 , entry 1 + -+ x.# = 3 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x <@ [1,2,3]'); -+ gin_debug_query_value_path -+---------------------------- -+ OR + -+ x = [] , entry 0 + -+ x.# = 1 , entry 1 + -+ x.# = 2 , entry 2 + -+ x.# = 3 , entry 3 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x = [1,2,3]'); -+ gin_debug_query_value_path -+---------------------------- -+ AND + -+ x.# = 1 , entry 0 + -+ x.# = 2 , entry 1 + -+ x.# = 3 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x = *'); -+ gin_debug_query_value_path -+---------------------------- -+ x = * , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x is boolean'); -+ gin_debug_query_value_path -+---------------------------- -+ x IS boolean , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x is string'); -+ gin_debug_query_value_path -+---------------------------- -+ x IS string , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x is numeric'); -+ gin_debug_query_value_path -+---------------------------- -+ x IS numeric , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x is array'); -+ gin_debug_query_value_path -+---------------------------- -+ x IS array , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('x is object'); -+ gin_debug_query_value_path -+---------------------------- -+ x IS object , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#:(x=1) AND %:(y=1) AND *:(z=1)'); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)'); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)'); -+ gin_debug_query_value_path -+---------------------------- -+ AND + -+ #.x = 1 , entry 0 + -+ %.y = 1 , entry 1 + -+ *.z = 1 , entry 2 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('(@# > 0 and #: = 16)'); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)'); -+ gin_debug_query_value_path -+---------------------------- -+ NULL + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('tags.#.term. ? ( # = "NYC").x > 0'); -+ gin_debug_query_value_path -+---------------------------------- -+ tags.#.term.# = "NYC" , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('$ = true'); -+ gin_debug_query_value_path -+---------------------------- -+ $ = true , entry 0 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('$ . ? (review_votes > 10) . review_rating < 7'); -+ gin_debug_query_value_path -+-------------------------------- -+ AND + -+ review_rating < 7 , entry 0 + -+ review_votes > 10 , entry 1 + -+ -+(1 row) -+ -+SELECT gin_debug_query_value_path('similar_product_ids . ? (# = "B0002W4TL2") . $'); -+ gin_debug_query_value_path -+------------------------------------------------- -+ similar_product_ids.# = "B0002W4TL2" , entry 0 + -+ -+(1 row) -+ -+---table and index -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 0; -+ count -+------- -+ 654 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 19; -+ count -+------- -+ 13 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 < 19; -+ count -+------- -+ 985 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 >= 19; -+ count -+------- -+ 16 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 <= 19; -+ count -+------- -+ 988 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 = 19; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 16 AND -+ (v->>'review_helpful_votes')::int4 < 20; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ count -+------- -+ 654 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+ count -+------- -+ 13 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+ count -+------- -+ 985 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+ count -+------- -+ 16 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+ count -+------- -+ 988 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+ count -+------- -+ 54 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+ count -+------- -+ 5 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+ count -+------- -+ 1017 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+ count -+------- -+ 51 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+ count -+------- -+ 1001 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+ count -+------- -+ 40 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+ count -+------- -+ 1034 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+ count -+------- -+ 1001 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+ count -+------- -+ 79 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+(2 rows) -+ -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+ {"array": [3, 4, 5]} -+(5 rows) -+ -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+(3 rows) -+ -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2, 3]} -+(1 row) -+ -+create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); -+set enable_seqscan = off; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ QUERY PLAN -+------------------------------------------------------------------------ -+ Aggregate -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) -+(5 rows) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ count -+------- -+ 654 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+ count -+------- -+ 13 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+ count -+------- -+ 985 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+ count -+------- -+ 16 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+ count -+------- -+ 988 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+ count -+------- -+ 54 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+ count -+------- -+ 5 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+ count -+------- -+ 1017 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+ count -+------- -+ 51 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+ count -+------- -+ 1001 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+ count -+------- -+ 1034 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+ count -+------- -+ 1001 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+ count -+------- -+ 79 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" && [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ QUERY PLAN -+-------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" = [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" = [2, 3]'::jsquery) -+(6 rows) -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+(2 rows) -+ -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+ {"array": [3, 4, 5]} -+(5 rows) -+ -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+(3 rows) -+ -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2, 3]} -+(1 row) -+ -+drop index t_idx; -+create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); -+set enable_seqscan = off; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ QUERY PLAN -+------------------------------------------------------------------------ -+ Aggregate -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) -+(5 rows) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ count -+------- -+ 654 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+ count -+------- -+ 13 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+ count -+------- -+ 985 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+ count -+------- -+ 16 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+ count -+------- -+ 988 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+ count -+------- -+ 8 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+ count -+------- -+ 54 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+ count -+------- -+ 1 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+ count -+------- -+ 4 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+ count -+------- -+ 5 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+ count -+------- -+ 1017 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+ count -+------- -+ 51 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+ count -+------- -+ 1001 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+ count -+------- -+ 7 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+ count -+------- -+ 2 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+ count -+------- -+ 10 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+ count -+------- -+ 1034 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+ count -+------- -+ 950 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+ count -+------- -+ 79 -+(1 row) -+ -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ count -+------- -+ 3 -+(1 row) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" && [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+ QUERY PLAN -+--------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) -+(6 rows) -+ -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ QUERY PLAN -+-------------------------------------------------------------- -+ Sort -+ Sort Key: v -+ -> Bitmap Heap Scan on test_jsquery -+ Recheck Cond: (v @@ '"array" = [2, 3]'::jsquery) -+ -> Bitmap Index Scan on t_idx -+ Index Cond: (v @@ '"array" = [2, 3]'::jsquery) -+(6 rows) -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+(2 rows) -+ -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2]} -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+ {"array": [3, 4, 5]} -+(5 rows) -+ -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+ v -+---------------------- -+ {"array": [2, 3]} -+ {"array": [1, 2, 3]} -+ {"array": [2, 3, 4]} -+(3 rows) -+ -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ v -+------------------- -+ {"array": [2, 3]} -+(1 row) -+ -+RESET enable_seqscan; diff -Nru jsquery-1.1.1/debian/patches/e45ff3833c4d022b8c055b90a7b254c1038d5f6b jsquery-1.2/debian/patches/e45ff3833c4d022b8c055b90a7b254c1038d5f6b --- jsquery-1.1.1/debian/patches/e45ff3833c4d022b8c055b90a7b254c1038d5f6b 2023-07-31 09:34:56.000000000 +0000 +++ jsquery-1.2/debian/patches/e45ff3833c4d022b8c055b90a7b254c1038d5f6b 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -commit e45ff3833c4d022b8c055b90a7b254c1038d5f6b -Author: Marina Polyakova -Date: Wed Jun 29 17:15:13 2022 +0300 - - PGPRO-6864: do not use the function pg_atoi if possible - - In PostgreSQL version 12 or higher it's more effecient to use the function - pg_strtoint32 instead (see the commit 86eaf208ea048936df6be77276a246d3f92e9620). - And in PostgreSQL 15 the function pg_atoi was removed altogether (see the commit - 73508475d69e90f98ebd9b7e1a5933a26a49c5e9). Therefore if possible use the - function pg_strtoint32 instead. - -diff --git a/jsquery_gram.y b/jsquery_gram.y -index 21bcfb0..84621e1 100644 ---- a/jsquery_gram.y -+++ b/jsquery_gram.y -@@ -71,7 +71,11 @@ makeIndexArray(string *s) - { - JsQueryParseItem* v = makeItemType(jqiIndexArray); - -+#if PG_VERSION_NUM >= 120000 -+ v->arrayIndex = pg_strtoint32(s->val); -+#else - v->arrayIndex = pg_atoi(s->val, 4, 0); -+#endif - - return v; - } diff -Nru jsquery-1.1.1/debian/patches/pg12 jsquery-1.2/debian/patches/pg12 --- jsquery-1.1.1/debian/patches/pg12 2023-07-31 09:29:37.000000000 +0000 +++ jsquery-1.2/debian/patches/pg12 1970-01-01 00:00:00.000000000 +0000 @@ -1,2665 +0,0 @@ -commit b96ef6d7205e20fa508dd5c73761adf380b73643 -Author: Teodor Sigaev -Date: Wed Sep 18 18:42:47 2019 +0300 - - Support for 12 pgsql. Only test was changed: 12 version has new operator - jsonb @@ jsonpath which conflicts (in tests) with jsonb @@ jsquery. So, - add explicit cast in tests. - -diff --git a/expected/jsquery.out b/expected/jsquery.out -index 7a06abb..6767433 100644 ---- a/expected/jsquery.out -+++ b/expected/jsquery.out -@@ -530,343 +530,343 @@ select 'a.b.#10203.* > 4'::jsquery; - "a"."b".#10203.* > 4 - (1 row) - --select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'; -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'; -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'; -+select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'; -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'; -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)' as "false"; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; - false - ------- - f - (1 row) - --select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'; -+select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'; -+select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": 1}'::jsonb @@ 'a in (0,2)'; -+select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; - ?column? - ---------- - f - (1 row) - --select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'; -+select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; - ?column? - ------------------------------------------------------ - (("asd".# = 3 AND "zzz" = true) OR "xxx".# = "zero") - (1 row) - --select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; -+select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; - ?column? - ------------------------------------------------------------------ - (((NOT "asd".# = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) - (1 row) - --select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; -+select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; - ?column? - ----------------------------------------------------------------------- - (((NOT "asd".#3."f" = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) -@@ -890,175 +890,175 @@ select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery; - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,2,3]'::jsonb @@ '# && [2]'; -+select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[1,2,3]'::jsonb @@ '#($ && [2])'; -+select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[1,2,3]'::jsonb @@ '$ && [2]'; -+select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,2,3]'::jsonb @@ '$ ($ && [2])'; -+select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,2,3]'::jsonb @@ '$ = 2'; -+select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[1,2,3]'::jsonb @@ '# = 2'; -+select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,2,3]'::jsonb @@ '#.$ = 2'; -+select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,2,3]'::jsonb @@ '#($ = 2)'; -+select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'; -+select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[3,4]'::jsonb @@ '# > 2 and # < 5'; -+select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'; -+select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[1,6]'::jsonb @@ '# > 2 and # < 5'; -+select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; - ?column? - ---------- - f - (1 row) - --select '"XXX"'::jsonb @@ '$="XXX"'; -+select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; - ?column? - ---------- - t - (1 row) - --select '"XXX"'::jsonb @@ '#.$="XXX"'; -+select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; - ?column? - ---------- - f -@@ -1071,19 +1071,19 @@ select 'a\t = "dollar \u0024 character"'::jsquery; - "a\t" = "dollar $ character" - (1 row) - --select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'; -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'; -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'; -+select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; - ?column? - ---------- - t -@@ -1471,157 +1471,157 @@ select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery; - "a".$. ?(("b" > 0 AND "x".* = 0)) ."c"."k" - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; - ?column? - ---------- - t - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; - ?column? - ---------- - f - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; - ?column? - ---------- - [1, 2] - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; - ?column? - ---------- - [20] - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; - ?column? - ---------------------------------------- - [{"a": 2, "b": 20}, {"a": 3, "b": 30}] - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; - ?column? - ---------- - - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; - ?column? - ----------- - [1, 2, 3] - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; - ?column? - ---------------------------- - [{"a": 1, "b": 2, "c": 3}] - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; - ?column? - ---------------------------- - [{"a": 1, "b": 2, "c": 3}] - (1 row) - --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; - ?column? - ---------- - - (1 row) - --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; - ?column? - ----------------------------------------------------------- - [{"a": 1, "b": 10}, {"a": 2, "b": 20}, {"a": 3, "b": 30}] - (1 row) - --select '[1,2,3]'::jsonb ~~ '#'; -+select '[1,2,3]'::jsonb ~~ '#'::jsquery; - ?column? - ----------- - [1, 2, 3] - (1 row) - --select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'; -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'; -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'; -+select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; - ?column? - ------------- - [[1, 2, 3]] - (1 row) - --select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'; -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; - ?column? - ---------- - - (1 row) - --select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'; -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; - ?column? - ------------- - [[1, 2, 3]] - (1 row) - --select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'; -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; - ?column? - ------------ - [{"c": 1}] - (1 row) - --select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'; -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; - ?column? - -------------------------- - [{"a": {"b": {"c": 1}}}] - (1 row) - --select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'; -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; - ?column? - ---------- - ["NYC"] - (1 row) - --select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'; -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; - ?column? - ------------------ - [["NYC", "CYN"]] -@@ -1856,133 +1856,133 @@ select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery; - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; - ?column? - ---------- - t - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; - ?column? - ---------- - f - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; - ?column? - ---------- - [1, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; - ?column? - ---------- - - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; - ?column? - ---------- - [1, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; - ?column? - ---------- - [1, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; - ?column? - ----------- - [1, 2, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; - ?column? - ---------- - [1, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; - ?column? - ---------- - [2, 3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; - ?column? - ---------- - - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; - ?column? - ---------- - [1] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; - ?column? - ---------- - [3] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; - ?column? - ---------- - [1, 2] - (1 row) - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; - ?column? - ----------- - [3, 1, 2] - (1 row) - --select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; -+select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; - ?column? - ------------------- - [3, [6, 5, 4], 2] -@@ -2465,249 +2465,249 @@ select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 16 - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; - count - ------- - 654 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; - count - ------- - 13 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; - count - ------- - 985 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; - count - ------- - 16 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; - count - ------- - 988 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; - count - ------- - 54 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'customer_id = null'; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_votes = true'; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'product_group = false'; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 't = *'; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ 't is boolean'; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is string'; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is numeric'; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is array'; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is object'; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is boolean'; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is string'; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is numeric'; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; - count - ------- - 5 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is array'; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is object'; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; - count - ------- - 1017 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; - count - ------- - 51 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; - count - ------- - 1001 - (1 row) - --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; - count - ------- - 40 - (1 row) - --select count(*) from test_jsquery where v @@ '$ > 2'; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ = false'; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't'; -+select count(*) from test_jsquery where v @@ 't'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ '$'; -+select count(*) from test_jsquery where v @@ '$'::jsquery; - count - ------- - 1034 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; - count - ------- - 1001 - (1 row) - --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; - count - ------- - 79 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; - count - ------- - 3 - (1 row) - --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2]} - {"array": [2, 3]} - (2 rows) - --select v from test_jsquery where v @@ 'array && [2,3]' order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2]} -@@ -2717,7 +2717,7 @@ select v from test_jsquery where v @@ 'array && [2,3]' order by v; - {"array": [3, 4, 5]} - (5 rows) - --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2, 3]} -@@ -2725,7 +2725,7 @@ select v from test_jsquery where v @@ 'array @> [2,3]' order by v; - {"array": [2, 3, 4]} - (3 rows) - --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2, 3]} -@@ -2733,7 +2733,7 @@ select v from test_jsquery where v @@ 'array = [2,3]' order by v; - - create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); - set enable_seqscan = off; --explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; - QUERY PLAN - ------------------------------------------------------------------------ - Aggregate -@@ -2743,242 +2743,242 @@ explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful - Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) - (5 rows) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; - count - ------- - 654 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; - count - ------- - 13 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; - count - ------- - 985 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; - count - ------- - 16 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; - count - ------- - 988 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; - count - ------- - 54 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'customer_id = null'; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_votes = true'; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'product_group = false'; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 't = *'; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ 't is boolean'; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is string'; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is numeric'; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is array'; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is object'; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is boolean'; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is string'; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is numeric'; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; - count - ------- - 5 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is array'; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is object'; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; - count - ------- - 1017 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; - count - ------- - 51 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; - count - ------- - 1001 - (1 row) - --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ '$ > 2'; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ = false'; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't'; -+select count(*) from test_jsquery where v @@ 't'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ '$'; -+select count(*) from test_jsquery where v @@ '$'::jsquery; - count - ------- - 1034 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; - count - ------- - 1001 - (1 row) - --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; - count - ------- - 79 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; - count - ------- - 3 - (1 row) - --explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -2989,7 +2989,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order - Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -3000,7 +3000,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order - Index Cond: (v @@ '"array" && [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -3011,7 +3011,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order - Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - QUERY PLAN - -------------------------------------------------------------- - Sort -@@ -3022,14 +3022,14 @@ explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order - Index Cond: (v @@ '"array" = [2, 3]'::jsquery) - (6 rows) - --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2]} - {"array": [2, 3]} - (2 rows) - --select v from test_jsquery where v @@ 'array && [2,3]' order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2]} -@@ -3039,7 +3039,7 @@ select v from test_jsquery where v @@ 'array && [2,3]' order by v; - {"array": [3, 4, 5]} - (5 rows) - --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2, 3]} -@@ -3047,7 +3047,7 @@ select v from test_jsquery where v @@ 'array @> [2,3]' order by v; - {"array": [2, 3, 4]} - (3 rows) - --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2, 3]} -@@ -3056,7 +3056,7 @@ select v from test_jsquery where v @@ 'array = [2,3]' order by v; - drop index t_idx; - create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); - set enable_seqscan = off; --explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; - QUERY PLAN - ------------------------------------------------------------------------ - Aggregate -@@ -3066,242 +3066,242 @@ explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful - Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) - (5 rows) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; - count - ------- - 654 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; - count - ------- - 13 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; - count - ------- - 985 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; - count - ------- - 16 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; - count - ------- - 988 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; - count - ------- - 8 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; - count - ------- - 54 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ 'customer_id = null'; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'review_votes = true'; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 'product_group = false'; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; - count - ------- - 1 - (1 row) - --select count(*) from test_jsquery where v @@ 't = *'; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ 't is boolean'; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is string'; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is numeric'; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is array'; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't is object'; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is boolean'; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is string'; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; - count - ------- - 4 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is numeric'; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; - count - ------- - 5 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is array'; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ '$ is object'; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; - count - ------- - 1017 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; - count - ------- - 51 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; - count - ------- - 1001 - (1 row) - --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; - count - ------- - 7 - (1 row) - --select count(*) from test_jsquery where v @@ '$ > 2'; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; - count - ------- - 3 - (1 row) - --select count(*) from test_jsquery where v @@ '$ = false'; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; - count - ------- - 2 - (1 row) - --select count(*) from test_jsquery where v @@ 't'; -+select count(*) from test_jsquery where v @@ 't'::jsquery; - count - ------- - 10 - (1 row) - --select count(*) from test_jsquery where v @@ '$'; -+select count(*) from test_jsquery where v @@ '$'::jsquery; - count - ------- - 1034 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; - count - ------- - 950 - (1 row) - --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; - count - ------- - 79 - (1 row) - --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; - count - ------- - 3 - (1 row) - --explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -3312,7 +3312,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order - Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -3323,7 +3323,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order - Index Cond: (v @@ '"array" && [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; - QUERY PLAN - --------------------------------------------------------------- - Sort -@@ -3334,7 +3334,7 @@ explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order - Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) - (6 rows) - --explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - QUERY PLAN - -------------------------------------------------------------- - Sort -@@ -3345,14 +3345,14 @@ explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order - Index Cond: (v @@ '"array" = [2, 3]'::jsquery) - (6 rows) - --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2]} - {"array": [2, 3]} - (2 rows) - --select v from test_jsquery where v @@ 'array && [2,3]' order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2]} -@@ -3362,7 +3362,7 @@ select v from test_jsquery where v @@ 'array && [2,3]' order by v; - {"array": [3, 4, 5]} - (5 rows) - --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; - v - ---------------------- - {"array": [2, 3]} -@@ -3370,7 +3370,7 @@ select v from test_jsquery where v @@ 'array @> [2,3]' order by v; - {"array": [2, 3, 4]} - (3 rows) - --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - v - ------------------- - {"array": [2, 3]} -diff --git a/sql/jsquery.sql b/sql/jsquery.sql -index fb501b6..0b50dbe 100644 ---- a/sql/jsquery.sql -+++ b/sql/jsquery.sql -@@ -105,124 +105,124 @@ select 'is.not < 1'::jsquery; - select 'a.b.#4 > 4'::jsquery; - select 'a.b.#10203.* > 4'::jsquery; - --select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'; --select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'; --select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'; --select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'; --select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'; --select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'; -- -- --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'; -- --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'; -- --select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'; -- --select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; --select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; --select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; -- --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'; -- --select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'; --select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'; -- --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'; -- --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)' as "false"; --select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'; -- --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'; --select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'; -- --select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'; --select '{"a": 1}'::jsonb @@ 'a in (0,2)'; -- --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'; -- --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'; -- --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'; -- --select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'; --select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; --select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; -+select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; -+select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; -+select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; -+ -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; -+ -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; -+ -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; -+select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; -+ -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; -+select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; -+select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; -+ -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; -+select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; -+ -+select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; -+select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; -+ -+select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; -+select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; -+select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; - - select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery; - select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery; - select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery; - --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'; -- --select '[1,2,3]'::jsonb @@ '# && [2]'; --select '[1,2,3]'::jsonb @@ '#($ && [2])'; --select '[1,2,3]'::jsonb @@ '$ && [2]'; --select '[1,2,3]'::jsonb @@ '$ ($ && [2])'; --select '[1,2,3]'::jsonb @@ '$ = 2'; --select '[1,2,3]'::jsonb @@ '# = 2'; --select '[1,2,3]'::jsonb @@ '#.$ = 2'; --select '[1,2,3]'::jsonb @@ '#($ = 2)'; -- --select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'; --select '[3,4]'::jsonb @@ '# > 2 and # < 5'; --select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'; --select '[1,6]'::jsonb @@ '# > 2 and # < 5'; -- --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'; --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'; --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'; --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'; --select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'; -- --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'; --select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'; --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'; --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'; --select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'; -- --select '"XXX"'::jsonb @@ '$="XXX"'; --select '"XXX"'::jsonb @@ '#.$="XXX"'; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; -+ -+select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; -+select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; -+select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; -+select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; -+select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; -+select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; -+select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; -+select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; -+ -+select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; -+select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; -+select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; -+select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; -+ -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; -+select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; -+ -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; -+select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; -+select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; -+ -+select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; -+select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; - - --Unicode - - select 'a\t = "dollar \u0024 character"'::jsquery; --select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'; --select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'; --select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'; -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; -+select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; -+select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; - select 'a\r = "\n\""'::jsquery; - select 'a\r = "\u0000"'::jsquery; - select 'a\r = \u0000'::jsquery; -@@ -301,32 +301,32 @@ select '?( not b>0). x'::jsquery; - select 'a.?(b>0 and x= 0 ) .c'::jsquery; - select 'a.$. ?(b>0 and x= 0 ) . c.k'::jsquery; - select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'; --select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'; --select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'; --select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'; --select '[1,2,3]'::jsonb ~~ '#'; --select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'; --select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'; --select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'; --select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'; --select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'; --select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'; --select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'; --select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'; --select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; -+select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; -+select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; -+select '[1,2,3]'::jsonb ~~ '#'::jsquery; -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; -+select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; -+select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; -+select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; -+select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; -+select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; - - --ALL - select 'a.*: = 4'::jsquery; -@@ -369,29 +369,29 @@ SELECT 'test.# IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,2 - select '[]' @@ '(@# > 0 and #: = 16)'::jsquery; - select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery; - --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'; -- --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'; --select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; --select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; -+ -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; -+select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; -+select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; - - --extract entries for index scan - -@@ -463,164 +463,164 @@ select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 16 - (v->>'review_helpful_votes')::int4 < 20; - - --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; --select count(*) from test_jsquery where v @@ 'customer_id = null'; --select count(*) from test_jsquery where v @@ 'review_votes = true'; --select count(*) from test_jsquery where v @@ 'product_group = false'; --select count(*) from test_jsquery where v @@ 't = *'; --select count(*) from test_jsquery where v @@ 't is boolean'; --select count(*) from test_jsquery where v @@ 't is string'; --select count(*) from test_jsquery where v @@ 't is numeric'; --select count(*) from test_jsquery where v @@ 't is array'; --select count(*) from test_jsquery where v @@ 't is object'; --select count(*) from test_jsquery where v @@ '$ is boolean'; --select count(*) from test_jsquery where v @@ '$ is string'; --select count(*) from test_jsquery where v @@ '$ is numeric'; --select count(*) from test_jsquery where v @@ '$ is array'; --select count(*) from test_jsquery where v @@ '$ is object'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; --select count(*) from test_jsquery where v @@ '$ > 2'; --select count(*) from test_jsquery where v @@ '$ = false'; --select count(*) from test_jsquery where v @@ 't'; --select count(*) from test_jsquery where v @@ '$'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -- --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; --select v from test_jsquery where v @@ 'array && [2,3]' order by v; --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - - create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); - set enable_seqscan = off; - --explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -- --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; --select count(*) from test_jsquery where v @@ 'customer_id = null'; --select count(*) from test_jsquery where v @@ 'review_votes = true'; --select count(*) from test_jsquery where v @@ 'product_group = false'; --select count(*) from test_jsquery where v @@ 't = *'; --select count(*) from test_jsquery where v @@ 't is boolean'; --select count(*) from test_jsquery where v @@ 't is string'; --select count(*) from test_jsquery where v @@ 't is numeric'; --select count(*) from test_jsquery where v @@ 't is array'; --select count(*) from test_jsquery where v @@ 't is object'; --select count(*) from test_jsquery where v @@ '$ is boolean'; --select count(*) from test_jsquery where v @@ '$ is string'; --select count(*) from test_jsquery where v @@ '$ is numeric'; --select count(*) from test_jsquery where v @@ '$ is array'; --select count(*) from test_jsquery where v @@ '$ is object'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; --select count(*) from test_jsquery where v @@ '$ > 2'; --select count(*) from test_jsquery where v @@ '$ = false'; --select count(*) from test_jsquery where v @@ 't'; --select count(*) from test_jsquery where v @@ '$'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -- --explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; -- --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; --select v from test_jsquery where v @@ 'array && [2,3]' order by v; --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - - drop index t_idx; - - create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); - set enable_seqscan = off; - --explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -- --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND -- v @@ 'review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; --select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; --select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; --select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; --select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; --select count(*) from test_jsquery where v @@ 'customer_id = null'; --select count(*) from test_jsquery where v @@ 'review_votes = true'; --select count(*) from test_jsquery where v @@ 'product_group = false'; --select count(*) from test_jsquery where v @@ 't = *'; --select count(*) from test_jsquery where v @@ 't is boolean'; --select count(*) from test_jsquery where v @@ 't is string'; --select count(*) from test_jsquery where v @@ 't is numeric'; --select count(*) from test_jsquery where v @@ 't is array'; --select count(*) from test_jsquery where v @@ 't is object'; --select count(*) from test_jsquery where v @@ '$ is boolean'; --select count(*) from test_jsquery where v @@ '$ is string'; --select count(*) from test_jsquery where v @@ '$ is numeric'; --select count(*) from test_jsquery where v @@ '$ is array'; --select count(*) from test_jsquery where v @@ '$ is object'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; --select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; --select count(*) from test_jsquery where v @@ '$ > 2'; --select count(*) from test_jsquery where v @@ '$ = false'; --select count(*) from test_jsquery where v @@ 't'; --select count(*) from test_jsquery where v @@ '$'; --select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; --select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; --select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; -- --explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; --explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; -- --select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; --select v from test_jsquery where v @@ 'array && [2,3]' order by v; --select v from test_jsquery where v @@ 'array @> [2,3]' order by v; --select v from test_jsquery where v @@ 'array = [2,3]' order by v; -+explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+ -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND -+ v @@ 'review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; -+select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; -+select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; -+select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't = *'::jsquery; -+select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ 't is string'::jsquery; -+select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 't is array'::jsquery; -+select count(*) from test_jsquery where v @@ 't is object'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is string'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is array'::jsquery; -+select count(*) from test_jsquery where v @@ '$ is object'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; -+select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; -+select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; -+select count(*) from test_jsquery where v @@ '$ = false'::jsquery; -+select count(*) from test_jsquery where v @@ 't'::jsquery; -+select count(*) from test_jsquery where v @@ '$'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; -+select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; -+select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; -+ -+explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; -+ -+select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; -+select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; - - RESET enable_seqscan; diff -Nru jsquery-1.1.1/debian/patches/pg16 jsquery-1.2/debian/patches/pg16 --- jsquery-1.1.1/debian/patches/pg16 2023-07-31 09:35:13.000000000 +0000 +++ jsquery-1.2/debian/patches/pg16 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ ---- a/jsquery.h -+++ b/jsquery.h -@@ -25,7 +25,7 @@ typedef struct - int32 vl_len_; /* varlena header (do not touch directly!) */ - } JsQuery; - --#define DatumGetJsQueryP(d) ((JsQuery*)DatumGetPointer(PG_DETOAST_DATUM(d))) -+#define DatumGetJsQueryP(d) ((JsQuery*)(PG_DETOAST_DATUM(d))) - #define PG_GETARG_JSQUERY(x) DatumGetJsQueryP(PG_GETARG_DATUM(x)) - #define PG_RETURN_JSQUERY(p) PG_RETURN_POINTER(p) - diff -Nru jsquery-1.1.1/debian/patches/series jsquery-1.2/debian/patches/series --- jsquery-1.1.1/debian/patches/series 2023-07-31 09:35:01.000000000 +0000 +++ jsquery-1.2/debian/patches/series 2023-10-21 11:15:58.000000000 +0000 @@ -1,5 +1 @@ makefile -pg12 -bison3.7 -e45ff3833c4d022b8c055b90a7b254c1038d5f6b -pg16 diff -Nru jsquery-1.1.1/expected/jsquery.out jsquery-1.2/expected/jsquery.out --- jsquery-1.1.1/expected/jsquery.out 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/expected/jsquery.out 2023-10-18 11:42:31.000000000 +0000 @@ -530,343 +530,343 @@ "a"."b".#10203.* > 4 (1 row) -select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'; +select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'; +select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'; +select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'; +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; ?column? ---------- f (1 row) -select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'; +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; ?column? ---------- f (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; ?column? ---------- f (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)' as "false"; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; false ------- f (1 row) -select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'; +select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; ?column? ---------- t (1 row) -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; ?column? ---------- t (1 row) -select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'; +select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; ?column? ---------- t (1 row) -select '{"a": 1}'::jsonb @@ 'a in (0,2)'; +select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; ?column? ---------- f (1 row) -select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'; +select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; ?column? ------------------------------------------------------ (("asd".# = 3 AND "zzz" = true) OR "xxx".# = "zero") (1 row) -select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; +select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; ?column? ------------------------------------------------------------------ (((NOT "asd".# = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) (1 row) -select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; +select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; ?column? ----------------------------------------------------------------------- (((NOT "asd".#3."f" = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) @@ -890,175 +890,175 @@ f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; ?column? ---------- t (1 row) -select '[1,2,3]'::jsonb @@ '# && [2]'; +select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; ?column? ---------- f (1 row) -select '[1,2,3]'::jsonb @@ '#($ && [2])'; +select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; ?column? ---------- f (1 row) -select '[1,2,3]'::jsonb @@ '$ && [2]'; +select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; ?column? ---------- t (1 row) -select '[1,2,3]'::jsonb @@ '$ ($ && [2])'; +select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; ?column? ---------- t (1 row) -select '[1,2,3]'::jsonb @@ '$ = 2'; +select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; ?column? ---------- f (1 row) -select '[1,2,3]'::jsonb @@ '# = 2'; +select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; ?column? ---------- t (1 row) -select '[1,2,3]'::jsonb @@ '#.$ = 2'; +select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; ?column? ---------- t (1 row) -select '[1,2,3]'::jsonb @@ '#($ = 2)'; +select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; ?column? ---------- t (1 row) -select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'; +select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; ?column? ---------- t (1 row) -select '[3,4]'::jsonb @@ '# > 2 and # < 5'; +select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; ?column? ---------- t (1 row) -select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'; +select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; ?column? ---------- f (1 row) -select '[1,6]'::jsonb @@ '# > 2 and # < 5'; +select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; ?column? ---------- f (1 row) -select '"XXX"'::jsonb @@ '$="XXX"'; +select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; ?column? ---------- t (1 row) -select '"XXX"'::jsonb @@ '#.$="XXX"'; +select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; ?column? ---------- f @@ -1071,19 +1071,19 @@ "a\t" = "dollar $ character" (1 row) -select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'; +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; ?column? ---------- t (1 row) -select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'; +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; ?column? ---------- t (1 row) -select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'; +select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; ?column? ---------- t @@ -1471,157 +1471,157 @@ "a".$. ?(("b" > 0 AND "x".* = 0)) ."c"."k" (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; ?column? ---------- f (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; ?column? ---------- t (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; ?column? ---------- t (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; ?column? ---------- f (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; ?column? ---------- f (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'; +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; ?column? ---------- [1, 2] (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'; +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; ?column? ---------- [20] (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; ?column? ---------------------------------------- [{"a": 2, "b": 20}, {"a": 3, "b": 30}] (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; ?column? ---------- (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; ?column? ----------- [1, 2, 3] (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; ?column? ---------- [3] (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; ?column? ---------- [3] (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; ?column? ---------------------------- [{"a": 1, "b": 2, "c": 3}] (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; ?column? ---------------------------- [{"a": 1, "b": 2, "c": 3}] (1 row) -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; ?column? ---------- (1 row) -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; ?column? ----------------------------------------------------------- [{"a": 1, "b": 10}, {"a": 2, "b": 20}, {"a": 3, "b": 30}] (1 row) -select '[1,2,3]'::jsonb ~~ '#'; +select '[1,2,3]'::jsonb ~~ '#'::jsquery; ?column? ----------- [1, 2, 3] (1 row) -select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'; +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; ?column? ---------- [3] (1 row) -select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'; +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; ?column? ---------- [3] (1 row) -select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'; +select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; ?column? ------------- [[1, 2, 3]] (1 row) -select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'; +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; ?column? ---------- (1 row) -select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'; +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; ?column? ------------- [[1, 2, 3]] (1 row) -select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'; +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; ?column? ------------ [{"c": 1}] (1 row) -select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'; +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; ?column? -------------------------- [{"a": {"b": {"c": 1}}}] (1 row) -select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'; +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; ?column? ---------- ["NYC"] (1 row) -select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'; +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; ?column? ------------------ [["NYC", "CYN"]] @@ -1856,133 +1856,133 @@ t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; ?column? ---------- t (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; ?column? ---------- f (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; ?column? ---------- [1, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; ?column? ---------- (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; ?column? ---------- [1, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; ?column? ---------- [1, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; ?column? ----------- [1, 2, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; ?column? ---------- [1, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; ?column? ---------- [2, 3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; ?column? ---------- (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; ?column? ---------- [1] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; ?column? ---------- [3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; ?column? ---------- [3] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; ?column? ---------- [1, 2] (1 row) -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; ?column? ----------- [3, 1, 2] (1 row) -select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; +select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; ?column? ------------------- [3, [6, 5, 4], 2] @@ -2465,249 +2465,249 @@ 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; count ------- 654 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; count ------- 13 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; count ------- 985 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; count ------- 16 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; count ------- 988 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; count ------- 54 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'customer_id = null'; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'review_votes = true'; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'product_group = false'; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 't = *'; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ 't is boolean'; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is string'; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is numeric'; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is array'; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is object'; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is boolean'; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ is string'; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ '$ is numeric'; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; count ------- 5 (1 row) -select count(*) from test_jsquery where v @@ '$ is array'; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is object'; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; count ------- 1017 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; count ------- 51 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; count ------- 1001 (1 row) -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; count ------- 40 (1 row) -select count(*) from test_jsquery where v @@ '$ > 2'; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ = false'; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't'; +select count(*) from test_jsquery where v @@ 't'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ '$'; +select count(*) from test_jsquery where v @@ '$'::jsquery; count ------- 1034 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; count ------- 1001 (1 row) -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; count ------- 79 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; count ------- 3 (1 row) -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; v ------------------- {"array": [2]} {"array": [2, 3]} (2 rows) -select v from test_jsquery where v @@ 'array && [2,3]' order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; v ---------------------- {"array": [2]} @@ -2717,7 +2717,7 @@ {"array": [3, 4, 5]} (5 rows) -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; v ---------------------- {"array": [2, 3]} @@ -2725,7 +2725,7 @@ {"array": [2, 3, 4]} (3 rows) -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; v ------------------- {"array": [2, 3]} @@ -2733,7 +2733,7 @@ create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); set enable_seqscan = off; -explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; QUERY PLAN ------------------------------------------------------------------------ Aggregate @@ -2743,242 +2743,242 @@ Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) (5 rows) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; count ------- 654 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; count ------- 13 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; count ------- 985 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; count ------- 16 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; count ------- 988 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; count ------- 54 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'customer_id = null'; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'review_votes = true'; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'product_group = false'; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 't = *'; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ 't is boolean'; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is string'; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is numeric'; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is array'; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is object'; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is boolean'; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ is string'; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ '$ is numeric'; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; count ------- 5 (1 row) -select count(*) from test_jsquery where v @@ '$ is array'; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is object'; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; count ------- 1017 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; count ------- 51 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; count ------- 1001 (1 row) -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ '$ > 2'; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ = false'; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't'; +select count(*) from test_jsquery where v @@ 't'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ '$'; +select count(*) from test_jsquery where v @@ '$'::jsquery; count ------- 1034 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; count ------- 1001 (1 row) -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; count ------- 79 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; count ------- 3 (1 row) -explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -2989,7 +2989,7 @@ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -3000,7 +3000,7 @@ Index Cond: (v @@ '"array" && [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -3011,7 +3011,7 @@ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; QUERY PLAN -------------------------------------------------------------- Sort @@ -3022,14 +3022,14 @@ Index Cond: (v @@ '"array" = [2, 3]'::jsquery) (6 rows) -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; v ------------------- {"array": [2]} {"array": [2, 3]} (2 rows) -select v from test_jsquery where v @@ 'array && [2,3]' order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; v ---------------------- {"array": [2]} @@ -3039,7 +3039,7 @@ {"array": [3, 4, 5]} (5 rows) -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; v ---------------------- {"array": [2, 3]} @@ -3047,7 +3047,7 @@ {"array": [2, 3, 4]} (3 rows) -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; v ------------------- {"array": [2, 3]} @@ -3056,7 +3056,7 @@ drop index t_idx; create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); set enable_seqscan = off; -explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; QUERY PLAN ------------------------------------------------------------------------ Aggregate @@ -3066,242 +3066,242 @@ Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) (5 rows) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; count ------- 654 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; count ------- 13 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; count ------- 985 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; count ------- 16 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; count ------- 988 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; count ------- 8 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; count ------- 54 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ 'customer_id = null'; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'review_votes = true'; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 'product_group = false'; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; count ------- 1 (1 row) -select count(*) from test_jsquery where v @@ 't = *'; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ 't is boolean'; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is string'; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is numeric'; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is array'; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't is object'; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is boolean'; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ is string'; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; count ------- 4 (1 row) -select count(*) from test_jsquery where v @@ '$ is numeric'; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; count ------- 5 (1 row) -select count(*) from test_jsquery where v @@ '$ is array'; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ '$ is object'; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; count ------- 1017 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; count ------- 51 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; count ------- 1001 (1 row) -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; count ------- 7 (1 row) -select count(*) from test_jsquery where v @@ '$ > 2'; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; count ------- 3 (1 row) -select count(*) from test_jsquery where v @@ '$ = false'; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; count ------- 2 (1 row) -select count(*) from test_jsquery where v @@ 't'; +select count(*) from test_jsquery where v @@ 't'::jsquery; count ------- 10 (1 row) -select count(*) from test_jsquery where v @@ '$'; +select count(*) from test_jsquery where v @@ '$'::jsquery; count ------- 1034 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; count ------- 950 (1 row) -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; count ------- 79 (1 row) -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; count ------- 3 (1 row) -explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -3312,7 +3312,7 @@ Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -3323,7 +3323,7 @@ Index Cond: (v @@ '"array" && [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; QUERY PLAN --------------------------------------------------------------- Sort @@ -3334,7 +3334,7 @@ Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) (6 rows) -explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; QUERY PLAN -------------------------------------------------------------- Sort @@ -3345,14 +3345,14 @@ Index Cond: (v @@ '"array" = [2, 3]'::jsquery) (6 rows) -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; v ------------------- {"array": [2]} {"array": [2, 3]} (2 rows) -select v from test_jsquery where v @@ 'array && [2,3]' order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; v ---------------------- {"array": [2]} @@ -3362,7 +3362,7 @@ {"array": [3, 4, 5]} (5 rows) -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; v ---------------------- {"array": [2, 3]} @@ -3370,7 +3370,7 @@ {"array": [2, 3, 4]} (3 rows) -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; v ------------------- {"array": [2, 3]} diff -Nru jsquery-1.1.1/expected/jsquery_1.out jsquery-1.2/expected/jsquery_1.out --- jsquery-1.1.1/expected/jsquery_1.out 1970-01-01 00:00:00.000000000 +0000 +++ jsquery-1.2/expected/jsquery_1.out 2023-10-18 11:42:31.000000000 +0000 @@ -0,0 +1,3379 @@ +CREATE EXTENSION jsquery; +set escape_string_warning=off; +set standard_conforming_strings=on; +CREATE TABLE test_jsquery (v jsonb); +\copy test_jsquery from 'data/test_jsquery.data' +select 'asd.zzz = 13'::jsquery; + jsquery +------------------ + "asd"."zzz" = 13 +(1 row) + +select 'asd.zzz < 13'::jsquery; + jsquery +------------------ + "asd"."zzz" < 13 +(1 row) + +select 'asd(zzz < 13)'::jsquery; + jsquery +------------------ + "asd"."zzz" < 13 +(1 row) + +select 'asd(zzz < 13 AND x = true)'::jsquery; + jsquery +---------------------------------- + "asd"("zzz" < 13 AND "x" = true) +(1 row) + +select 'asd(zzz < 13 AND x = "true")'::jsquery; + jsquery +------------------------------------ + "asd"("zzz" < 13 AND "x" = "true") +(1 row) + +select 'asd(zzz < 13 AND x.zxc = "true")'::jsquery; + jsquery +------------------------------------------ + "asd"("zzz" < 13 AND "x"."zxc" = "true") +(1 row) + +select 'asd(zzz < 13 OR #.zxc = "true" /* test */)'::jsquery; + jsquery +--------------------------------------- + "asd"("zzz" < 13 OR #."zxc" = "true") +(1 row) + +select 'asd(* < 13 AND /* ttt */ #.zxc = "true")'::jsquery; + jsquery +------------------------------------ + "asd"(* < 13 AND #."zxc" = "true") +(1 row) + +select '(* < 13 AND #.zxc = "true")'::jsquery; + jsquery +------------------------------- + (* < 13 AND #."zxc" = "true") +(1 row) + +select '* < 13 AND #.zxc/* t2 */ = "true"'::jsquery; + jsquery +------------------------------- + (* < 13 AND #."zxc" = "true") +(1 row) + +select '* < 13 AND #.zxc"x" = "true"'::jsquery; +ERROR: bad jsquery representation +LINE 1: select '* < 13 AND #.zxc"x" = "true"'::jsquery; + ^ +DETAIL: syntax error, unexpected STRING_P, expecting end of file at or near """ +select 'a < 1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < -1'::jsquery; + jsquery +---------- + "a" < -1 +(1 row) + +select 'a < +1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < .1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < -.1'::jsquery; + jsquery +------------ + "a" < -0.1 +(1 row) + +select 'a < +.1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < 0.1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < -0.1'::jsquery; + jsquery +------------ + "a" < -0.1 +(1 row) + +select 'a < +0.1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < 10.1'::jsquery; + jsquery +------------ + "a" < 10.1 +(1 row) + +select 'a < -10.1'::jsquery; + jsquery +------------- + "a" < -10.1 +(1 row) + +select 'a < +10.1'::jsquery; + jsquery +------------ + "a" < 10.1 +(1 row) + +select 'a < 1e1'::jsquery; + jsquery +---------- + "a" < 10 +(1 row) + +select 'a < -1e1'::jsquery; + jsquery +----------- + "a" < -10 +(1 row) + +select 'a < +1e1'::jsquery; + jsquery +---------- + "a" < 10 +(1 row) + +select 'a < .1e1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < -.1e1'::jsquery; + jsquery +---------- + "a" < -1 +(1 row) + +select 'a < +.1e1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < 0.1e1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < -0.1e1'::jsquery; + jsquery +---------- + "a" < -1 +(1 row) + +select 'a < +0.1e1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < 10.1e1'::jsquery; + jsquery +----------- + "a" < 101 +(1 row) + +select 'a < -10.1e1'::jsquery; + jsquery +------------ + "a" < -101 +(1 row) + +select 'a < +10.1e1'::jsquery; + jsquery +----------- + "a" < 101 +(1 row) + +select 'a < 1e-1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < -1e-1'::jsquery; + jsquery +------------ + "a" < -0.1 +(1 row) + +select 'a < +1e-1'::jsquery; + jsquery +----------- + "a" < 0.1 +(1 row) + +select 'a < .1e-1'::jsquery; + jsquery +------------ + "a" < 0.01 +(1 row) + +select 'a < -.1e-1'::jsquery; + jsquery +------------- + "a" < -0.01 +(1 row) + +select 'a < +.1e-1'::jsquery; + jsquery +------------ + "a" < 0.01 +(1 row) + +select 'a < 0.1e-1'::jsquery; + jsquery +------------ + "a" < 0.01 +(1 row) + +select 'a < -0.1e-1'::jsquery; + jsquery +------------- + "a" < -0.01 +(1 row) + +select 'a < +0.1e-1'::jsquery; + jsquery +------------ + "a" < 0.01 +(1 row) + +select 'a < 10.1e-1'::jsquery; + jsquery +------------ + "a" < 1.01 +(1 row) + +select 'a < -10.1e-1'::jsquery; + jsquery +------------- + "a" < -1.01 +(1 row) + +select 'a < +10.1e-1'::jsquery; + jsquery +------------ + "a" < 1.01 +(1 row) + +select 'a < 1e+1'::jsquery; + jsquery +---------- + "a" < 10 +(1 row) + +select 'a < -1e+1'::jsquery; + jsquery +----------- + "a" < -10 +(1 row) + +select 'a < +1e+1'::jsquery; + jsquery +---------- + "a" < 10 +(1 row) + +select 'a < .1e+1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < -.1e+1'::jsquery; + jsquery +---------- + "a" < -1 +(1 row) + +select 'a < +.1e+1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < 0.1e+1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < -0.1e+1'::jsquery; + jsquery +---------- + "a" < -1 +(1 row) + +select 'a < +0.1e+1'::jsquery; + jsquery +--------- + "a" < 1 +(1 row) + +select 'a < 10.1e+1'::jsquery; + jsquery +----------- + "a" < 101 +(1 row) + +select 'a < -10.1e+1'::jsquery; + jsquery +------------ + "a" < -101 +(1 row) + +select 'a < +10.1e+1'::jsquery; + jsquery +----------- + "a" < 101 +(1 row) + +select 'a in (0,1,2)'::jsquery; + jsquery +------------------ + "a" IN (0, 1, 2) +(1 row) + +select 'a IN (0,null, "null", xxx, "zzz", 2)'::jsquery; + jsquery +------------------------------------------- + "a" IN (0, null, "null", "xxx", "zzz", 2) +(1 row) + +select 'not < 1'::jsquery; + jsquery +----------- + "not" < 1 +(1 row) + +select 'not not < 1'::jsquery; + jsquery +----------------- + (NOT "not" < 1) +(1 row) + +select 'not( not < 1)'::jsquery; + jsquery +----------------- + (NOT "not" < 1) +(1 row) + +select 'not.x < 1'::jsquery; + jsquery +--------------- + "not"."x" < 1 +(1 row) + +select 'x.not < 1'::jsquery; + jsquery +--------------- + "x"."not" < 1 +(1 row) + +select 'a.%(not x > 0 and not (y < 0 or z = 0))'::jsquery; + jsquery +----------------------------------------------------- + "a".%((NOT "x" > 0) AND (NOT ("y" < 0 OR "z" = 0))) +(1 row) + +select 'is < 1'::jsquery; + jsquery +---------- + "is" < 1 +(1 row) + +select 'in < 1'::jsquery; + jsquery +---------- + "in" < 1 +(1 row) + +select 'not is < 1'::jsquery; + jsquery +---------------- + (NOT "is" < 1) +(1 row) + +select 'not in < 1'::jsquery; + jsquery +---------------- + (NOT "in" < 1) +(1 row) + +select 'in in (1,2)'::jsquery; + jsquery +---------------- + "in" IN (1, 2) +(1 row) + +select 'is in (1,2)'::jsquery; + jsquery +---------------- + "is" IN (1, 2) +(1 row) + +select 'not in (1,2)'::jsquery; + jsquery +----------------- + "not" IN (1, 2) +(1 row) + +select 'in is numeric'::jsquery; + jsquery +----------------- + "in" IS NUMERIC +(1 row) + +select 'is is numeric'::jsquery; + jsquery +----------------- + "is" IS NUMERIC +(1 row) + +select 'not is numeric'::jsquery; + jsquery +------------------ + "not" IS NUMERIC +(1 row) + +select 'not.in < 1'::jsquery; + jsquery +---------------- + "not"."in" < 1 +(1 row) + +select 'not.is < 1'::jsquery; + jsquery +---------------- + "not"."is" < 1 +(1 row) + +select 'not.not < 1'::jsquery; + jsquery +----------------- + "not"."not" < 1 +(1 row) + +select 'in.in < 1'::jsquery; + jsquery +--------------- + "in"."in" < 1 +(1 row) + +select 'in.is < 1'::jsquery; + jsquery +--------------- + "in"."is" < 1 +(1 row) + +select 'in.not < 1'::jsquery; + jsquery +---------------- + "in"."not" < 1 +(1 row) + +select 'is.in < 1'::jsquery; + jsquery +--------------- + "is"."in" < 1 +(1 row) + +select 'is.is < 1'::jsquery; + jsquery +--------------- + "is"."is" < 1 +(1 row) + +select 'is.not < 1'::jsquery; + jsquery +---------------- + "is"."not" < 1 +(1 row) + +select 'a.b.#4 > 4'::jsquery; + jsquery +---------------- + "a"."b".#4 > 4 +(1 row) + +select 'a.b.#10203.* > 4'::jsquery; + jsquery +---------------------- + "a"."b".#10203.* > 4 +(1 row) + +select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; + false +------- + f +(1 row) + +select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; + ?column? +---------- + f +(1 row) + +select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; + ?column? +------------------------------------------------------ + (("asd".# = 3 AND "zzz" = true) OR "xxx".# = "zero") +(1 row) + +select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; + ?column? +------------------------------------------------------------------ + (((NOT "asd".# = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) +(1 row) + +select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; + ?column? +----------------------------------------------------------------------- + (((NOT "asd".#3."f" = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero")) +(1 row) + +select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; + ?column? +---------- + t +(1 row) + +select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; + ?column? +---------- + f +(1 row) + +--Unicode +select 'a\t = "dollar \u0024 character"'::jsquery; + jsquery +------------------------------ + "a\t" = "dollar $ character" +(1 row) + +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; + ?column? +---------- + t +(1 row) + +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; + ?column? +---------- + t +(1 row) + +select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; + ?column? +---------- + t +(1 row) + +select 'a\r = "\n\""'::jsquery; + jsquery +---------------- + "a\r" = "\n\"" +(1 row) + +select 'a\r = "\u0000"'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = "\u0000"'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = \u0000'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = \u0000'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = "\abcd"'::jsquery AS err; +ERROR: bad jsquery representation +LINE 1: select 'a\r = "\abcd"'::jsquery AS err; + ^ +DETAIL: Escape sequence is invalid at or near "\a" +select 'a\r = "\\abcd"'::jsquery; + jsquery +------------------ + "a\r" = "\\abcd" +(1 row) + +select 'a\r = "x\u0000"'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = "x\u0000"'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = x\u0000'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = x\u0000'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = "x\abcd"'::jsquery AS err; +ERROR: bad jsquery representation +LINE 1: select 'a\r = "x\abcd"'::jsquery AS err; + ^ +DETAIL: Escape sequence is invalid at or near "\a" +select 'a\r = "x\\abcd"'::jsquery; + jsquery +------------------- + "a\r" = "x\\abcd" +(1 row) + +select 'a\r = "x\u0000x"'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = "x\u0000x"'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = x\u0000x'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = x\u0000x'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = "x\abcdx"'::jsquery AS err; +ERROR: bad jsquery representation +LINE 1: select 'a\r = "x\abcdx"'::jsquery AS err; + ^ +DETAIL: Escape sequence is invalid at or near "\a" +select 'a\r = "x\\abcdx"'::jsquery; + jsquery +-------------------- + "a\r" = "x\\abcdx" +(1 row) + +select 'a\r = "\u0000x"'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = "\u0000x"'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = \u0000x'::jsquery; +ERROR: unsupported Unicode escape sequence +LINE 1: select 'a\r = \u0000x'::jsquery; + ^ +DETAIL: \u0000 cannot be converted to text. +select 'a\r = "\abcdx"'::jsquery AS err; +ERROR: bad jsquery representation +LINE 1: select 'a\r = "\abcdx"'::jsquery AS err; + ^ +DETAIL: Escape sequence is invalid at or near "\a" +select 'a\r = "\\abcdx"'::jsquery; + jsquery +------------------- + "a\r" = "\\abcdx" +(1 row) + +select 'a\r = x"\\abcd"'::jsquery AS err; +ERROR: bad jsquery representation +LINE 1: select 'a\r = x"\\abcd"'::jsquery AS err; + ^ +DETAIL: syntax error, unexpected STRING_P, expecting end of file at or near """ +--IS +select 'as IS boolean OR as is ARRAY OR as is ObJect OR as is Numeric OR as is string'::jsquery; + jsquery +------------------------------------------------------------------------------------------------- + (((("as" IS BOOLEAN OR "as" IS ARRAY) OR "as" IS OBJECT) OR "as" IS NUMERIC) OR "as" IS STRING) +(1 row) + +select '{"as": "xxx"}' @@ 'as IS string'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"as": "xxx"}' @@ 'as IS boolean OR as is ARRAY OR as is ObJect OR as is Numeric'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"as": 5}' @@ 'as is Numeric'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"as": true}' @@ 'as is boolean'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"as": false}' @@ 'as is boolean'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"as": "false"}' @@ 'as is boolean'::jsquery; + ?column? +---------- + f +(1 row) + +select '["xxx"]' @@ '$ IS array'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"as": false}' @@ '$ IS object'::jsquery; + ?column? +---------- + t +(1 row) + +select '"xxx"' @@ '$ IS string'::jsquery; + ?column? +---------- + t +(1 row) + +select '"xxx"' @@ '$ IS numeric'::jsquery; + ?column? +---------- + f +(1 row) + +--hint +select 'a /*-- noindex */ = 5'::jsquery; + jsquery +-------------------------- + "a" /*-- noindex */ = 5 +(1 row) + +select 'a /*-- index */ = 5'::jsquery; + jsquery +------------------------ + "a" /*-- index */ = 5 +(1 row) + +select 'asd.# = 3'::jsquery & 'zzz /*-- noindex */ = true' | 'xxx.# /*-- index */ = zero'; + ?column? +-------------------------------------------------------------------------------------- + (("asd".# = 3 AND "zzz" /*-- noindex */ = true) OR "xxx".# /*-- index */ = "zero") +(1 row) + +select 'a /*-- xxx */ = 5'::jsquery; + jsquery +--------- + "a" = 5 +(1 row) + +select 'a /* index */ = 5'::jsquery; + jsquery +--------- + "a" = 5 +(1 row) + +select 'a /* noindex */ = 5'::jsquery; + jsquery +--------- + "a" = 5 +(1 row) + +select 'a = /*-- noindex */ 5'::jsquery; +ERROR: bad jsquery representation +LINE 1: select 'a = /*-- noindex */ 5'::jsquery; + ^ +DETAIL: syntax error, unexpected HINT_P at or near "*/" +select 'a = /* noindex */ 5'::jsquery; + jsquery +--------- + "a" = 5 +(1 row) + +--LENGTH +select 'a.@# = 4'::jsquery; + jsquery +------------ + "a".@# = 4 +(1 row) + +select 'a.@#.$ = 4'::jsquery as noerror; + noerror +-------------- + "a".@#.$ = 4 +(1 row) + +select 'a.@#.a = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.a = 4'::jsquery as error; + ^ +select 'a.@#.* = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.* = 4'::jsquery as error; + ^ +select 'a.@#.% = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.% = 4'::jsquery as error; + ^ +select 'a.@#.# = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.# = 4'::jsquery as error; + ^ +select 'a.@#.*: = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.*: = 4'::jsquery as error; + ^ +select 'a.@#.%: = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.%: = 4'::jsquery as error; + ^ +select 'a.@#.#: = 4'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@#.#: = 4'::jsquery as error; + ^ +select 'a.@# (a = 5 or b = 6)'::jsquery as error; +ERROR: Array length should be last in path +LINE 1: select 'a.@# (a = 5 or b = 6)'::jsquery as error; + ^ +select '[]' @@ '@# = 0'::jsquery; + ?column? +---------- + t +(1 row) + +select '[]' @@ '@# < 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '[]' @@ '@# > 1'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1]' @@ '@# = 0'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1]' @@ '@# < 2'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1]' @@ '@# > 1'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2]' @@ '@# = 0'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2]' @@ '@# < 2'::jsquery; + ?column? +---------- + f +(1 row) + +select '[1,2]' @@ '@# > 1'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2]' @@ '@# in (1, 2)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[1,2]' @@ '@# in (1, 3)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":[1,2]}' @@ '@# in (2, 4)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":[1,2]}' @@ 'a.@# in (2, 4)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":[1,2]}' @@ '%.@# in (2, 4)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":[1,2]}' @@ '*.@# in (2, 4)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":[1,2]}' @@ '*.@# ($ = 4 or $ = 2)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":[1,2]}' @@ '@# = 1'::jsquery; + ?column? +---------- + t +(1 row) + +--filter +select '?( not b>0). x'::jsquery; + jsquery +------------------------ + ?((NOT "b" > 0)) ."x" +(1 row) + +select 'a.?(b>0 and x= 0 ) .c'::jsquery; + jsquery +------------------------------------ + "a". ?(("b" > 0 AND "x" = 0)) ."c" +(1 row) + +select 'a.$. ?(b>0 and x= 0 ) . c.k'::jsquery; + jsquery +------------------------------------------ + "a".$. ?(("b" > 0 AND "x" = 0)) ."c"."k" +(1 row) + +select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery; + jsquery +-------------------------------------------- + "a".$. ?(("b" > 0 AND "x".* = 0)) ."c"."k" +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; + ?column? +---------- + [1, 2] +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; + ?column? +---------- + [20] +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; + ?column? +---------------------------------------- + [{"a": 2, "b": 20}, {"a": 3, "b": 30}] +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; + ?column? +---------- + +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; + ?column? +----------- + [1, 2, 3] +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; + ?column? +---------------------------- + [{"a": 1, "b": 2, "c": 3}] +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; + ?column? +---------------------------- + [{"a": 1, "b": 2, "c": 3}] +(1 row) + +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; + ?column? +---------- + +(1 row) + +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; + ?column? +----------------------------------------------------------- + [{"a": 1, "b": 10}, {"a": 2, "b": 20}, {"a": 3, "b": 30}] +(1 row) + +select '[1,2,3]'::jsonb ~~ '#'::jsquery; + ?column? +----------- + [1, 2, 3] +(1 row) + +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; + ?column? +------------- + [[1, 2, 3]] +(1 row) + +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; + ?column? +---------- + +(1 row) + +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; + ?column? +------------- + [[1, 2, 3]] +(1 row) + +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; + ?column? +------------ + [{"c": 1}] +(1 row) + +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; + ?column? +-------------------------- + [{"a": {"b": {"c": 1}}}] +(1 row) + +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; + ?column? +---------- + ["NYC"] +(1 row) + +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; + ?column? +------------------ + [["NYC", "CYN"]] +(1 row) + +--ALL +select 'a.*: = 4'::jsquery; + jsquery +------------ + "a".*: = 4 +(1 row) + +select '%: = 4'::jsquery; + jsquery +--------- + %: = 4 +(1 row) + +select '#:.i = 4'::jsquery; + jsquery +------------ + #:."i" = 4 +(1 row) + +select '[]' @@ '#: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[2,3,4]' @@ '#: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[2,3,5]' @@ '#: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[2,3,5]' @@ '# ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '[2,3,"x"]' @@ '#: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{}' @@ '%: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{}' @@ '*: ($ is object)'::jsquery; + ?column? +---------- + t +(1 row) + +select '"a"' @@ '*: is string'::jsquery; + ?column? +---------- + t +(1 row) + +select '1' @@ '*: is string'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":2,"b":3,"c":4}' @@ '%: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":2,"b":3,"c":5}' @@ '%: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":2,"b":3,"c":5}' @@ '% ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":2,"b":3,"c":"x"}' @@ '%: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":2,"b":3,"c":4}' @@ '*: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":2,"b":3,"c":5}' @@ '*: ($ > 1 and $ < 5)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":2,"b":3,"c":4}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":2,"b":3,"c":5}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"b":{"ba":3, "bb":4}}' @@ '*: ($ is object OR ($ > 1 and $ < 5))'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR ($> 1 and $ < 5))'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":4}}' @@ '*: ($ is object OR ($ > 0 and $ < 5))'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR ($> 0 and $ < 5))'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '* ($ > 0 and $ < 5)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":{"ba":3, "bb":5}}' @@ '*: ($ is object OR $ is numeric)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":[5,6]}' @@ '*: ($ is object OR $ is numeric)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":[5,6]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":8}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":"x"}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1, "ab":2}, "b":[5,6, {"c":null}]}' @@ '*: ($ is object OR $ is array OR $ is numeric)'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}}' @@ '%:.aa is numeric'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1}, "b":{"aa":true, "bb":2}}' @@ '%:.aa is numeric'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}, "aa":16}' @@ '*: (not $ is object or $.aa is numeric)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a":{"aa":1}, "b":{"aa":1, "bb":2}}' @@ '*: (not $ is object or $.aa is numeric or % is object)'::jsquery; + ?column? +---------- + t +(1 row) + +SELECT 'test.# IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64)'::jsquery; + jsquery +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + "test".# IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64) +(1 row) + +select '[]' @@ '(@# > 0 and #: = 16)'::jsquery; + ?column? +---------- + f +(1 row) + +select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; + ?column? +---------- + t +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; + ?column? +---------- + f +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; + ?column? +---------- + [1, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; + ?column? +---------- + +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; + ?column? +---------- + [1, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; + ?column? +---------- + [1, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; + ?column? +----------- + [1, 2, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; + ?column? +---------- + [1, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; + ?column? +---------- + [2, 3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; + ?column? +---------- + +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; + ?column? +---------- + [1] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; + ?column? +---------- + [3] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; + ?column? +---------- + [1, 2] +(1 row) + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; + ?column? +----------- + [3, 1, 2] +(1 row) + +select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; + ?column? +------------------- + [3, [6, 5, 4], 2] +(1 row) + +--extract entries for index scan +SELECT gin_debug_query_path_value('NOT NOT NOT x(y(NOT (a=1) and NOT (b=2)) OR NOT NOT (c=3)) and z = 5'); + gin_debug_query_path_value +---------------------------- + AND + + z = 5 , entry 0 + + OR + + x.y.a = 1 , entry 1 + + x.y.b = 2 , entry 2 + + +(1 row) + +SELECT gin_debug_query_path_value('NOT #(x=1) and NOT *(y=1) and NOT %(z=1) '); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('#(NOT x=1) and *(NOT y=1) and %(NOT z=1) '); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('NOT #(NOT x=1) and NOT *(NOT y=1) and NOT %(NOT z=1) '); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('#(x = "a" and y > 0 and y < 1 and z > 0)'); + gin_debug_query_path_value +---------------------------- + #.x = "a" , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('#(x = "a" and y /*-- index */ >= 0 and y < 1 and z > 0)'); + gin_debug_query_path_value +----------------------------- + AND + + #.x = "a" , entry 0 + + #.y >= 0 , < 1 , entry 1 + + +(1 row) + +SELECT gin_debug_query_path_value('#(x /*-- noindex */ = "a" and y > 0 and y <= 1 and z /*-- index */ > 0)'); + gin_debug_query_path_value +----------------------------- + AND + + #.y > 0 , <= 1 , entry 0 + + #.z > 0 , entry 1 + + +(1 row) + +SELECT gin_debug_query_path_value('x = 1 and (y /*-- index */ > 0 and y < 1 OR z > 0)'); + gin_debug_query_path_value +---------------------------- + AND + + x = 1 , entry 0 + + OR + + y > 0 , < 1 , entry 1 + + z > 0 , entry 2 + + +(1 row) + +SELECT gin_debug_query_path_value('%.x = 1'); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('*.x = "b"'); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('x && [1,2,3]'); + gin_debug_query_path_value +---------------------------- + OR + + x.# = 1 , entry 0 + + x.# = 2 , entry 1 + + x.# = 3 , entry 2 + + +(1 row) + +SELECT gin_debug_query_path_value('x @> [1,2,3]'); + gin_debug_query_path_value +---------------------------- + AND + + x.# = 1 , entry 0 + + x.# = 2 , entry 1 + + x.# = 3 , entry 2 + + +(1 row) + +SELECT gin_debug_query_path_value('x <@ [1,2,3]'); + gin_debug_query_path_value +---------------------------- + OR + + x = [] , entry 0 + + x.# = 1 , entry 1 + + x.# = 2 , entry 2 + + x.# = 3 , entry 3 + + +(1 row) + +SELECT gin_debug_query_path_value('x = *'); + gin_debug_query_path_value +---------------------------- + x = * , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('x is boolean'); + gin_debug_query_path_value +---------------------------- + x IS boolean , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('x is string'); + gin_debug_query_path_value +---------------------------- + x IS string , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('x is numeric'); + gin_debug_query_path_value +---------------------------- + x IS numeric , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('x is array'); + gin_debug_query_path_value +---------------------------- + x IS array , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('x is object'); + gin_debug_query_path_value +---------------------------- + x IS object , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('#:(x=1) AND %:(y=1) AND *:(z=1)'); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)'); + gin_debug_query_path_value +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_path_value('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)'); + gin_debug_query_path_value +---------------------------- + #.x = 1 , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('$ = true'); + gin_debug_query_path_value +---------------------------- + $ = true , entry 0 + + +(1 row) + +SELECT gin_debug_query_path_value('$ . ? (review_votes > 10) . review_rating < 7'); + gin_debug_query_path_value +-------------------------------- + AND + + review_rating < 7 , entry 0 + + review_votes > 10 , entry 1 + + +(1 row) + +SELECT gin_debug_query_path_value('similar_product_ids . ? (# = "B0002W4TL2") . $'); + gin_debug_query_path_value +------------------------------------------------- + similar_product_ids.# = "B0002W4TL2" , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('NOT NOT NOT x(y(NOT (a=1) and NOT (b=2)) OR NOT NOT (c=3)) and z = 5'); + gin_debug_query_value_path +---------------------------- + AND + + z = 5 , entry 0 + + OR + + x.y.a = 1 , entry 1 + + x.y.b = 2 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('NOT #(x=1) and NOT *(y=1) and NOT %(z=1) '); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('#(NOT x=1) and *(NOT y=1) and %(NOT z=1) '); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('NOT #(NOT x=1) and NOT *(NOT y=1) and NOT %(NOT z=1) '); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('#(x = "a" and y > 0 and y < 1 and z > 0)'); + gin_debug_query_value_path +---------------------------- + #.x = "a" , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('#(x = "a" and y /*-- index */ >= 0 and y < 1 and z > 0)'); + gin_debug_query_value_path +----------------------------- + AND + + #.x = "a" , entry 0 + + #.y >= 0 , < 1 , entry 1 + + +(1 row) + +SELECT gin_debug_query_value_path('#(x /*-- noindex */ = "a" and y > 0 and y <= 1 and z /*-- index */ > 0)'); + gin_debug_query_value_path +----------------------------- + AND + + #.y > 0 , <= 1 , entry 0 + + #.z > 0 , entry 1 + + +(1 row) + +SELECT gin_debug_query_value_path('x = 1 and (y /*-- index */ > 0 and y < 1 OR z > 0)'); + gin_debug_query_value_path +---------------------------- + AND + + x = 1 , entry 0 + + OR + + y > 0 , < 1 , entry 1 + + z > 0 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('%.x = 1'); + gin_debug_query_value_path +---------------------------- + %.x = 1 , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('*.x = "b"'); + gin_debug_query_value_path +---------------------------- + *.x = "b" , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x && [1,2,3]'); + gin_debug_query_value_path +---------------------------- + OR + + x.# = 1 , entry 0 + + x.# = 2 , entry 1 + + x.# = 3 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('x @> [1,2,3]'); + gin_debug_query_value_path +---------------------------- + AND + + x.# = 1 , entry 0 + + x.# = 2 , entry 1 + + x.# = 3 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('x <@ [1,2,3]'); + gin_debug_query_value_path +---------------------------- + OR + + x = [] , entry 0 + + x.# = 1 , entry 1 + + x.# = 2 , entry 2 + + x.# = 3 , entry 3 + + +(1 row) + +SELECT gin_debug_query_value_path('x = [1,2,3]'); + gin_debug_query_value_path +---------------------------- + AND + + x.# = 1 , entry 0 + + x.# = 2 , entry 1 + + x.# = 3 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('x = *'); + gin_debug_query_value_path +---------------------------- + x = * , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x is boolean'); + gin_debug_query_value_path +---------------------------- + x IS boolean , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x is string'); + gin_debug_query_value_path +---------------------------- + x IS string , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x is numeric'); + gin_debug_query_value_path +---------------------------- + x IS numeric , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x is array'); + gin_debug_query_value_path +---------------------------- + x IS array , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('x is object'); + gin_debug_query_value_path +---------------------------- + x IS object , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('#:(x=1) AND %:(y=1) AND *:(z=1)'); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)'); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)'); + gin_debug_query_value_path +---------------------------- + AND + + #.x = 1 , entry 0 + + %.y = 1 , entry 1 + + *.z = 1 , entry 2 + + +(1 row) + +SELECT gin_debug_query_value_path('(@# > 0 and #: = 16)'); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)'); + gin_debug_query_value_path +---------------------------- + NULL + + +(1 row) + +SELECT gin_debug_query_value_path('tags.#.term. ? ( # = "NYC").x > 0'); + gin_debug_query_value_path +---------------------------------- + tags.#.term.# = "NYC" , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('$ = true'); + gin_debug_query_value_path +---------------------------- + $ = true , entry 0 + + +(1 row) + +SELECT gin_debug_query_value_path('$ . ? (review_votes > 10) . review_rating < 7'); + gin_debug_query_value_path +-------------------------------- + AND + + review_rating < 7 , entry 0 + + review_votes > 10 , entry 1 + + +(1 row) + +SELECT gin_debug_query_value_path('similar_product_ids . ? (# = "B0002W4TL2") . $'); + gin_debug_query_value_path +------------------------------------------------- + similar_product_ids.# = "B0002W4TL2" , entry 0 + + +(1 row) + +---table and index +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 0; + count +------- + 654 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 19; + count +------- + 13 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 < 19; + count +------- + 985 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 >= 19; + count +------- + 16 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 <= 19; + count +------- + 988 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 = 19; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 16 AND + (v->>'review_helpful_votes')::int4 < 20; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; + count +------- + 654 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; + count +------- + 13 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; + count +------- + 985 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; + count +------- + 16 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; + count +------- + 988 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; + count +------- + 54 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 't = *'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is string'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is object'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; + count +------- + 5 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; + count +------- + 1017 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; + count +------- + 51 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; + count +------- + 1001 +(1 row) + +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; + count +------- + 40 +(1 row) + +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ '$'::jsquery; + count +------- + 1034 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; + count +------- + 1001 +(1 row) + +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; + count +------- + 79 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + count +------- + 3 +(1 row) + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; + v +------------------- + {"array": [2]} + {"array": [2, 3]} +(2 rows) + +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2]} + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} + {"array": [3, 4, 5]} +(5 rows) + +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} +(3 rows) + +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + v +------------------- + {"array": [2, 3]} +(1 row) + +create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); +set enable_seqscan = off; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; + QUERY PLAN +------------------------------------------------------------------------ + Aggregate + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) +(5 rows) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; + count +------- + 654 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; + count +------- + 13 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; + count +------- + 985 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; + count +------- + 16 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; + count +------- + 988 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; + count +------- + 54 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 't = *'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is string'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is object'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; + count +------- + 5 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; + count +------- + 1017 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; + count +------- + 51 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; + count +------- + 1001 +(1 row) + +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ '$'::jsquery; + count +------- + 1034 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; + count +------- + 1001 +(1 row) + +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; + count +------- + 79 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + count +------- + 3 +(1 row) + +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" && [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + QUERY PLAN +-------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" = [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" = [2, 3]'::jsquery) +(6 rows) + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; + v +------------------- + {"array": [2]} + {"array": [2, 3]} +(2 rows) + +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2]} + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} + {"array": [3, 4, 5]} +(5 rows) + +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} +(3 rows) + +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + v +------------------- + {"array": [2, 3]} +(1 row) + +drop index t_idx; +create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); +set enable_seqscan = off; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; + QUERY PLAN +------------------------------------------------------------------------ + Aggregate + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"review_helpful_votes" > 0'::jsquery) +(5 rows) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; + count +------- + 654 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; + count +------- + 13 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; + count +------- + 985 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; + count +------- + 16 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; + count +------- + 988 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; + count +------- + 8 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; + count +------- + 54 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; + count +------- + 1 +(1 row) + +select count(*) from test_jsquery where v @@ 't = *'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is string'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't is object'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; + count +------- + 4 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; + count +------- + 5 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; + count +------- + 1017 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; + count +------- + 51 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; + count +------- + 1001 +(1 row) + +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; + count +------- + 7 +(1 row) + +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; + count +------- + 3 +(1 row) + +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; + count +------- + 2 +(1 row) + +select count(*) from test_jsquery where v @@ 't'::jsquery; + count +------- + 10 +(1 row) + +select count(*) from test_jsquery where v @@ '$'::jsquery; + count +------- + 1034 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; + count +------- + 950 +(1 row) + +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; + count +------- + 79 +(1 row) + +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + count +------- + 3 +(1 row) + +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" <@ [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" <@ [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" && [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" && [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; + QUERY PLAN +--------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" @> [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" @> [2, 3]'::jsquery) +(6 rows) + +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + QUERY PLAN +-------------------------------------------------------------- + Sort + Sort Key: v + -> Bitmap Heap Scan on test_jsquery + Recheck Cond: (v @@ '"array" = [2, 3]'::jsquery) + -> Bitmap Index Scan on t_idx + Index Cond: (v @@ '"array" = [2, 3]'::jsquery) +(6 rows) + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; + v +------------------- + {"array": [2]} + {"array": [2, 3]} +(2 rows) + +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2]} + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} + {"array": [3, 4, 5]} +(5 rows) + +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; + v +---------------------- + {"array": [2, 3]} + {"array": [1, 2, 3]} + {"array": [2, 3, 4]} +(3 rows) + +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + v +------------------- + {"array": [2, 3]} +(1 row) + +RESET enable_seqscan; diff -Nru jsquery-1.1.1/jsonb_gin_ops.c jsquery-1.2/jsonb_gin_ops.c --- jsquery-1.1.1/jsonb_gin_ops.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsonb_gin_ops.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Support GIN over jsonb with jsquery operation * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Alexander Korotkov * * IDENTIFICATION @@ -172,7 +173,6 @@ static uint32 get_path_bloom(PathHashStack *stack) { - int i = 0; uint32 res = 0, val; while (stack) @@ -182,7 +182,6 @@ val = get_bloom_value(hash); res |= val; - i++; stack = stack->parent; } return res; diff -Nru jsquery-1.1.1/jsquery--1.1.sql jsquery-1.2/jsquery--1.1.sql --- jsquery-1.1.1/jsquery--1.1.sql 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery--1.1.sql 2023-10-18 11:42:31.000000000 +0000 @@ -158,7 +158,7 @@ CREATE OPERATOR <> ( LEFTARG = jsquery, RIGHTARG = jsquery, - PROCEDURE = jsquery_eq, + PROCEDURE = jsquery_ne, COMMUTATOR = '<>', NEGATOR = '=', RESTRICT = neqsel, @@ -178,7 +178,7 @@ CREATE OPERATOR > ( LEFTARG = jsquery, RIGHTARG = jsquery, - PROCEDURE = jsquery_ge, + PROCEDURE = jsquery_gt, COMMUTATOR = '<', NEGATOR = '<=', RESTRICT = scalargtsel, diff -Nru jsquery-1.1.1/jsquery.h jsquery-1.2/jsquery.h --- jsquery-1.1.1/jsquery.h 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery.h 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Definitions of jsquery datatype * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION @@ -25,7 +26,7 @@ int32 vl_len_; /* varlena header (do not touch directly!) */ } JsQuery; -#define DatumGetJsQueryP(d) ((JsQuery*)DatumGetPointer(PG_DETOAST_DATUM(d))) +#define DatumGetJsQueryP(d) ((JsQuery*) PG_DETOAST_DATUM(d)) #define PG_GETARG_JSQUERY(x) DatumGetJsQueryP(PG_GETARG_DATUM(x)) #define PG_RETURN_JSQUERY(p) PG_RETURN_POINTER(p) diff -Nru jsquery-1.1.1/jsquery_constr.c jsquery-1.2/jsquery_constr.c --- jsquery-1.1.1/jsquery_constr.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_constr.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Functions and operations to manipulate jsquery * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION diff -Nru jsquery-1.1.1/jsquery_extract.c jsquery-1.2/jsquery_extract.c --- jsquery-1.1.1/jsquery_extract.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_extract.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Functions and operations to support jsquery in indexes * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Alexander Korotkov * * IDENTIFICATION @@ -178,6 +179,7 @@ *result->exactValue = e; return result; } + /* fall through */ /* jqiEqual with jqiArray follows */ case jqiIn: case jqiOverlap: diff -Nru jsquery-1.1.1/jsquery_gram.y jsquery-1.2/jsquery_gram.y --- jsquery-1.1.1/jsquery_gram.y 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_gram.y 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Grammar definitions for jsquery datatype * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION @@ -47,7 +48,7 @@ int len; int total; } string; -#include +#include "jsquery_gram.h" /* flex 2.5.4 doesn't bother with a decl for this */ int jsquery_yylex(YYSTYPE * yylval_param); @@ -70,7 +71,11 @@ { JsQueryParseItem* v = makeItemType(jqiIndexArray); +#if PG_VERSION_NUM >= 120000 + v->arrayIndex = pg_strtoint32(s->val); +#else v->arrayIndex = pg_atoi(s->val, 4, 0); +#endif return v; } @@ -249,7 +254,10 @@ %% result: - expr { *result = $1; } + expr { + *result = $1; + (void) yynerrs; /* suppress compiler warning */ + } | /* EMPTY */ { *result = NULL; } ; diff -Nru jsquery-1.1.1/jsquery_io.c jsquery-1.2/jsquery_io.c --- jsquery-1.1.1/jsquery_io.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_io.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * I/O functions for jsquery datatype * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2016-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION @@ -44,6 +45,7 @@ case jqiKey: if (onlyCurrentInPath) elog(ERROR,"Array length should be last in path"); + /* fall through */ case jqiString: appendBinaryStringInfo(buf, (char*)&item->string.len, sizeof(item->string.len)); appendBinaryStringInfo(buf, item->string.val, item->string.len); @@ -117,6 +119,7 @@ case jqiIndexArray: appendBinaryStringInfo(buf, (char*)&item->arrayIndex, sizeof(item->arrayIndex)); + /* FALLTHROUGH */ /* keep svace quiet */ case jqiAny: case jqiAnyArray: case jqiAnyKey: @@ -238,6 +241,7 @@ case jqiKey: if (inKey) appendStringInfoChar(buf, '.'); + /* fall through */ /* follow next */ case jqiString: escape_json(buf, jsqGetString(v, NULL)); diff -Nru jsquery-1.1.1/jsquery_op.c jsquery-1.2/jsquery_op.c --- jsquery-1.1.1/jsquery_op.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_op.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Functions and operations over jsquery/jsonb datatypes * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION @@ -542,7 +543,7 @@ else if (JsonbType(jb) == jbvScalar) { JsonbIterator *it; - int32 r; + int32 r PG_USED_FOR_ASSERTS_ONLY; JsonbValue v; it = JsonbIteratorInit(jb->val.binary.data); @@ -729,7 +730,7 @@ if (JsonbType(jb) == jbvScalar) { JsonbIterator *it; - int32 r; + int32 r PG_USED_FOR_ASSERTS_ONLY; JsonbValue v; it = JsonbIteratorInit(jb->val.binary.data); diff -Nru jsquery-1.1.1/jsquery_scan.l jsquery-1.2/jsquery_scan.l --- jsquery-1.1.1/jsquery_scan.l 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_scan.l 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Lexical parser for jsquery datatype * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION diff -Nru jsquery-1.1.1/jsquery_support.c jsquery-1.2/jsquery_support.c --- jsquery-1.1.1/jsquery_support.c 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/jsquery_support.c 2023-10-18 11:42:31.000000000 +0000 @@ -4,6 +4,7 @@ * Functions and operations to support jsquery * * Copyright (c) 2014, PostgreSQL Global Development Group + * Portions Copyright (c) 2017-2021, Postgres Professional * Author: Teodor Sigaev * * IDENTIFICATION @@ -33,10 +34,13 @@ { case 3: appendStringInfoCharMacro(buf, 0); + /* fall through */ case 2: appendStringInfoCharMacro(buf, 0); + /* fall through */ case 1: appendStringInfoCharMacro(buf, 0); + /* fall through */ default: break; } @@ -60,9 +64,9 @@ switch(INTALIGN(pos) - pos) { - case 3: pos++; - case 2: pos++; - case 1: pos++; + case 3: pos++; /* fall through */ + case 2: pos++; /* fall through */ + case 1: pos++; /* fall through */ default: break; } @@ -86,6 +90,7 @@ case jqiKey: case jqiString: read_int32(v->value.datalen, base, pos); + /* fall through */ /* follow next */ case jqiNumeric: case jqiBool: @@ -209,7 +214,7 @@ int32 jsqGetIsType(JsQueryItem *v) { - Assert(v->type = jqiIs); + Assert(v->type == jqiIs); return (int32)*v->value.data; } @@ -256,7 +261,7 @@ jsqIterateDestroy(JsQueryItem *v) { Assert(v->type == jqiArray); - Assert(v->array.current <= v->array.current); + Assert(v->array.current <= v->array.nelems); v->array.current++; } diff -Nru jsquery-1.1.1/sql/jsquery.sql jsquery-1.2/sql/jsquery.sql --- jsquery-1.1.1/sql/jsquery.sql 2018-10-11 13:49:00.000000000 +0000 +++ jsquery-1.2/sql/jsquery.sql 2023-10-18 11:42:31.000000000 +0000 @@ -105,124 +105,124 @@ select 'a.b.#4 > 4'::jsquery; select 'a.b.#10203.* > 4'::jsquery; -select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'; -select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'; -select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'; -select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'; -select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'; -select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'; - - -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'; - -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'; - -select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'; - -select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; -select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; -select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'; - -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'; - -select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'; -select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'; - -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'; - -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)' as "false"; -select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'; - -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'; -select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'; - -select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'; -select '{"a": 1}'::jsonb @@ 'a in (0,2)'; - -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'; - -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'; - -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'; - -select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'; -select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; -select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = 1'::jsquery; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = null'::jsquery; +select '{"a": {"b": null}}'::jsonb @@ 'a.b = false'::jsquery; +select '{"a": {"b": false}}'::jsonb @@ 'a.b = false'::jsquery; +select '{"a": {"b": false}}'::jsonb @@ 'a.b = true'::jsquery; +select '{"a": {"b": true}}'::jsonb @@ 'a.b = true'::jsquery; + + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 1'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 1'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 1'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 1'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 1'::jsquery; + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 2'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 2'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 2'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 2'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 2'::jsquery; + +select '{"a": {"b": 1}}'::jsonb @@ 'a.b = 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b < 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b <= 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b >= 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.b > 0'::jsquery; + +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ '*.b > 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; +select '{"a": {"b": 1}}'::jsonb @@ 'a.* > 0'::jsquery; + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 1 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b @> [ 1,2,3,4 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b <@ [ 1,2,3,4 ]'::jsquery; + +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 4'::jsquery; +select '[{"a": 2}, {"a": 3}]'::jsonb @@ '*.a = 3'::jsquery; + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a = 4'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a = 4'::jsquery; + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 1 OR a=3)'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 OR a=1)'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=1)'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#(a = 3 and a=2)'::jsquery as "false"; +select '[{"a": 2, "b":3}, {"a": 3, "b": 1}]'::jsonb @@ '#(b = 1 and a=3)'::jsquery; + +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.a.a = 4'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.a.a = 4'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '*.#.a.a = 4'::jsquery; +select '[{"a": 2}, {"a": 3}, {"a": {"a":4}}]'::jsonb @@ '#.*.a.a = 4'::jsquery; + +select '{"a": 1}'::jsonb @@ 'a in (0,1,2)'::jsquery; +select '{"a": 1}'::jsonb @@ 'a in (0,2)'::jsquery; + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#=2'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 5 ]'::jsquery; + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a=*'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b=*'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.c=*'::jsquery; + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b = [1,2,3]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# = [1,2,3]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b && [1,2,3]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]'::jsquery; + +select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero'::jsquery; +select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; +select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero'::jsquery; select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery; select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery; select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'; - -select '[1,2,3]'::jsonb @@ '# && [2]'; -select '[1,2,3]'::jsonb @@ '#($ && [2])'; -select '[1,2,3]'::jsonb @@ '$ && [2]'; -select '[1,2,3]'::jsonb @@ '$ ($ && [2])'; -select '[1,2,3]'::jsonb @@ '$ = 2'; -select '[1,2,3]'::jsonb @@ '# = 2'; -select '[1,2,3]'::jsonb @@ '#.$ = 2'; -select '[1,2,3]'::jsonb @@ '#($ = 2)'; - -select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'; -select '[3,4]'::jsonb @@ '# > 2 and # < 5'; -select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'; -select '[1,6]'::jsonb @@ '# > 2 and # < 5'; - -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'; -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'; -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'; -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'; -select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'; - -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'; -select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'; -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'; -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'; -select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])'::jsquery; + +select '[1,2,3]'::jsonb @@ '# && [2]'::jsquery; +select '[1,2,3]'::jsonb @@ '#($ && [2])'::jsquery; +select '[1,2,3]'::jsonb @@ '$ && [2]'::jsquery; +select '[1,2,3]'::jsonb @@ '$ ($ && [2])'::jsquery; +select '[1,2,3]'::jsonb @@ '$ = 2'::jsquery; +select '[1,2,3]'::jsonb @@ '# = 2'::jsquery; +select '[1,2,3]'::jsonb @@ '#.$ = 2'::jsquery; +select '[1,2,3]'::jsonb @@ '#($ = 2)'::jsquery; + +select '[3,4]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; +select '[3,4]'::jsonb @@ '# > 2 and # < 5'::jsquery; +select '[1,6]'::jsonb @@ '#($ > 2 and $ < 5)'::jsquery; +select '[1,6]'::jsonb @@ '# > 2 and # < 5'::jsquery; + +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.b=3'::jsquery; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ 'a.%=3'::jsquery; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%.%="hey"'::jsquery; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%="hey"'::jsquery; +select '{"a": {"b": 3, "c": "hey"}, "x": [5,6]}'::jsonb @@ '%=[5,6]'::jsquery; + +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#1 = 2'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#2 = 2'::jsquery; +select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.#3 = 2'::jsquery; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#1.x = 2'::jsquery; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#2.x = 2'::jsquery; +select '{"a": {"b": [{"x":1},{"x":2},{"x":3}]}}'::jsonb @@ 'a.b.#3.x = 2'::jsquery; -select '"XXX"'::jsonb @@ '$="XXX"'; -select '"XXX"'::jsonb @@ '#.$="XXX"'; +select '"XXX"'::jsonb @@ '$="XXX"'::jsquery; +select '"XXX"'::jsonb @@ '#.$="XXX"'::jsquery; --Unicode select 'a\t = "dollar \u0024 character"'::jsquery; -select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'; -select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'; -select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'; +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; +select '{ "a": "dollar \u0024 character" }'::jsonb @@ '* = "dollar $ character"'::jsquery; +select '{ "a": "dollar $ character" }'::jsonb @@ '* = "dollar \u0024 character"'::jsquery; select 'a\r = "\n\""'::jsquery; select 'a\r = "\u0000"'::jsquery; select 'a\r = \u0000'::jsquery; @@ -301,32 +301,32 @@ select 'a.?(b>0 and x= 0 ) .c'::jsquery; select 'a.$. ?(b>0 and x= 0 ) . c.k'::jsquery; select 'a.$.? (b>0 and x.*= 0 ).c.k'::jsquery; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'; -select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'; -select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'; -select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'; -select '[1,2,3]'::jsonb ~~ '#'; -select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'; -select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'; -select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'; -select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'; -select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'; -select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'; -select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'; -select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'; -select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a < 0) (b=20)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 0) (b=20)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 1) (b=20)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 2) (b=20)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb @@ '#. ?(a > 3) (b=20)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#.a'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}]'::jsonb ~~ '#. ?(a > 1). b'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '# . ?(a > 1)'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '%'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '%'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 )'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '% . ? ( $ > 2 ).$'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( % > 2 )'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 0 )'::jsquery; +select '{"a":1, "b":2, "c":3}'::jsonb ~~ '? ( %: > 2 )'::jsquery; +select '[{"a":1, "b":10}, {"a":2, "b":20}, {"a":3, "b":30}]'::jsonb ~~ '#'::jsquery; +select '[1,2,3]'::jsonb ~~ '#'::jsquery; +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2)'::jsquery; +select '[1,2,3]'::jsonb ~~ '#. ?($ > 2).$'::jsquery; +select '[1,2,3]'::jsonb ~~ ' ?(#.$ > 2).$'::jsquery; +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 2).$'::jsquery; +select '[1,2,3]'::jsonb ~~ ' ?(#:.$ > 0).$'::jsquery; +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '*.?(c >0)'::jsquery; +select '{"a": {"b": {"c": 1}}}'::jsonb ~~ '?(*.c >0)'::jsquery; +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term.#. ? ( $ = "NYC")'::jsquery; +select '{"tags":[{"term":["NYC", "CYN"]}, {"term":["1NYC", "1CYN"]} ]}'::jsonb ~~ 'tags.#.term. ? ( # = "NYC")'::jsquery; --ALL select 'a.*: = 4'::jsquery; @@ -369,29 +369,29 @@ select '[]' @@ '(@# > 0 and #: = 16)'::jsquery; select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'; - -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'; -select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; -select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d'::jsquery; + +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and b.c'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.d or b.c)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and (b.c or b.d)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b and a.c and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.b or a.c) and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.c) and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ '(a.e or a.g) and b.d'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'a.b or (b.d or b.c)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b or a.c)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d or (a.b and a.c)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.f or (a.b and a.c)'::jsquery; +select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; +select '{"a": {"b": [6,5,4], "c": 2}, "b": {"d":3}}'::jsonb ~~ 'b.d and (a.b and a.c)'::jsquery; --extract entries for index scan @@ -463,164 +463,164 @@ (v->>'review_helpful_votes')::int4 < 20; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -select count(*) from test_jsquery where v @@ 'customer_id = null'; -select count(*) from test_jsquery where v @@ 'review_votes = true'; -select count(*) from test_jsquery where v @@ 'product_group = false'; -select count(*) from test_jsquery where v @@ 't = *'; -select count(*) from test_jsquery where v @@ 't is boolean'; -select count(*) from test_jsquery where v @@ 't is string'; -select count(*) from test_jsquery where v @@ 't is numeric'; -select count(*) from test_jsquery where v @@ 't is array'; -select count(*) from test_jsquery where v @@ 't is object'; -select count(*) from test_jsquery where v @@ '$ is boolean'; -select count(*) from test_jsquery where v @@ '$ is string'; -select count(*) from test_jsquery where v @@ '$ is numeric'; -select count(*) from test_jsquery where v @@ '$ is array'; -select count(*) from test_jsquery where v @@ '$ is object'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -select count(*) from test_jsquery where v @@ '$ > 2'; -select count(*) from test_jsquery where v @@ '$ = false'; -select count(*) from test_jsquery where v @@ 't'; -select count(*) from test_jsquery where v @@ '$'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; - -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -select v from test_jsquery where v @@ 'array && [2,3]' order by v; -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; +select count(*) from test_jsquery where v @@ 't'::jsquery; +select count(*) from test_jsquery where v @@ '$'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; create index t_idx on test_jsquery using gin (v jsonb_value_path_ops); set enable_seqscan = off; -explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -select count(*) from test_jsquery where v @@ 'customer_id = null'; -select count(*) from test_jsquery where v @@ 'review_votes = true'; -select count(*) from test_jsquery where v @@ 'product_group = false'; -select count(*) from test_jsquery where v @@ 't = *'; -select count(*) from test_jsquery where v @@ 't is boolean'; -select count(*) from test_jsquery where v @@ 't is string'; -select count(*) from test_jsquery where v @@ 't is numeric'; -select count(*) from test_jsquery where v @@ 't is array'; -select count(*) from test_jsquery where v @@ 't is object'; -select count(*) from test_jsquery where v @@ '$ is boolean'; -select count(*) from test_jsquery where v @@ '$ is string'; -select count(*) from test_jsquery where v @@ '$ is numeric'; -select count(*) from test_jsquery where v @@ '$ is array'; -select count(*) from test_jsquery where v @@ '$ is object'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -select count(*) from test_jsquery where v @@ '$ > 2'; -select count(*) from test_jsquery where v @@ '$ = false'; -select count(*) from test_jsquery where v @@ 't'; -select count(*) from test_jsquery where v @@ '$'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; - -explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; - -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -select v from test_jsquery where v @@ 'array && [2,3]' order by v; -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; +select count(*) from test_jsquery where v @@ 't'::jsquery; +select count(*) from test_jsquery where v @@ '$'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; drop index t_idx; create index t_idx on test_jsquery using gin (v jsonb_path_value_ops); set enable_seqscan = off; -explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; +explain (costs off) select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16' AND - v @@ 'review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'; -select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '; -select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'; -select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'; -select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'; -select count(*) from test_jsquery where v @@ 'customer_id = null'; -select count(*) from test_jsquery where v @@ 'review_votes = true'; -select count(*) from test_jsquery where v @@ 'product_group = false'; -select count(*) from test_jsquery where v @@ 't = *'; -select count(*) from test_jsquery where v @@ 't is boolean'; -select count(*) from test_jsquery where v @@ 't is string'; -select count(*) from test_jsquery where v @@ 't is numeric'; -select count(*) from test_jsquery where v @@ 't is array'; -select count(*) from test_jsquery where v @@ 't is object'; -select count(*) from test_jsquery where v @@ '$ is boolean'; -select count(*) from test_jsquery where v @@ '$ is string'; -select count(*) from test_jsquery where v @@ '$ is numeric'; -select count(*) from test_jsquery where v @@ '$ is array'; -select count(*) from test_jsquery where v @@ '$ is object'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'; -select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'; -select count(*) from test_jsquery where v @@ '$ > 2'; -select count(*) from test_jsquery where v @@ '$ = false'; -select count(*) from test_jsquery where v @@ 't'; -select count(*) from test_jsquery where v @@ '$'; -select count(*) from test_jsquery where v @@ 'similar_product_ids.#'; -select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'; -select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'; - -explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]' order by v; - -select v from test_jsquery where v @@ 'array <@ [2,3]' order by v; -select v from test_jsquery where v @@ 'array && [2,3]' order by v; -select v from test_jsquery where v @@ 'array @> [2,3]' order by v; -select v from test_jsquery where v @@ 'array = [2,3]' order by v; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 0'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes < 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes >= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes <= 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes = 19'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16'::jsquery AND + v @@ 'review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes > 16 and review_helpful_votes < 20'::jsquery; +select count(*) from test_jsquery where v @@ 'review_helpful_votes ($ > 16 and $ < 20)'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids(# = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#($ = "0440180295") '::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids && ["0440180295"] and product_sales_rank > 300000'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]'::jsquery; +select count(*) from test_jsquery where v @@ 'customer_id = null'::jsquery; +select count(*) from test_jsquery where v @@ 'review_votes = true'::jsquery; +select count(*) from test_jsquery where v @@ 'product_group = false'::jsquery; +select count(*) from test_jsquery where v @@ 't = *'::jsquery; +select count(*) from test_jsquery where v @@ 't is boolean'::jsquery; +select count(*) from test_jsquery where v @@ 't is string'::jsquery; +select count(*) from test_jsquery where v @@ 't is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 't is array'::jsquery; +select count(*) from test_jsquery where v @@ 't is object'::jsquery; +select count(*) from test_jsquery where v @@ '$ is boolean'::jsquery; +select count(*) from test_jsquery where v @@ '$ is string'::jsquery; +select count(*) from test_jsquery where v @@ '$ is numeric'::jsquery; +select count(*) from test_jsquery where v @@ '$ is array'::jsquery; +select count(*) from test_jsquery where v @@ '$ is object'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is numeric'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#: is string'::jsquery; +select count(*) from test_jsquery where v @@ 'NOT similar_product_ids.#: (NOT $ = "0440180295")'::jsquery; +select count(*) from test_jsquery where v @@ '$ > 2'::jsquery; +select count(*) from test_jsquery where v @@ '$ = false'::jsquery; +select count(*) from test_jsquery where v @@ 't'::jsquery; +select count(*) from test_jsquery where v @@ '$'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids.#'::jsquery; +select count(*) from test_jsquery where v @@ '$ . ? (review_votes > 10) . review_rating < 7'::jsquery; +select count(*) from test_jsquery where v @@ 'similar_product_ids . ? (# = "B0002W4TL2") . $'::jsquery; + +explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; +explain (costs off) select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; + +select v from test_jsquery where v @@ 'array <@ [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array && [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array @> [2,3]'::jsquery order by v; +select v from test_jsquery where v @@ 'array = [2,3]'::jsquery order by v; RESET enable_seqscan;