Update jsonb_1.out with recent tests previously missed
authorPeter Geoghegan <[email protected]>
Sun, 9 Mar 2014 04:27:55 +0000 (20:27 -0800)
committerPeter Geoghegan <[email protected]>
Sun, 9 Mar 2014 04:27:55 +0000 (20:27 -0800)
src/test/regress/expected/jsonb_1.out

index 7e821ed9b273d31b833e14253c84c04d41d91979..eea86d4b8293022744a9dbd68c022357e65e877d 100644 (file)
@@ -424,6 +424,8 @@ SELECT '{"x":"y"}'::jsonb <> '{"x":"z"}'::jsonb;
  t
 (1 row)
 
+CREATE TABLE testjsonb (j jsonb);
+\copy testjsonb FROM 'data/jsonb.data'
 -- containment
 SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b"}');
  jsonb_contains 
@@ -737,6 +739,13 @@ SELECT jsonb '{"a":"null", "b":"qq"}' ? 'a';
  t
 (1 row)
 
+-- array exists - array elements should behave as keys
+SELECT 1 from testjsonb  WHERE j->'array' ? 'bar';
+ ?column? 
+----------
+        1
+(1 row)
+
 SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['a','b']);
  jsonb_exists_any 
 ------------------
@@ -1324,8 +1333,6 @@ SELECT jsonb '{ "a":  "null \u0000 escape" }' ->> 'a' AS not_unescaped;
 (1 row)
 
 -- indexing
-CREATE TABLE testjsonb (j jsonb);
-\copy testjsonb FROM 'data/jsonb.data'
 SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}';
  count 
 -------
@@ -1424,8 +1431,17 @@ SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'];
     42
 (1 row)
 
+-- array exists - array elements should behave as keys (for GiST index scans too)
+CREATE INDEX jidx_array ON testjsonb USING gist((j->'array'));
+SELECT 1 from testjsonb  WHERE j->'array' ? 'bar';
+ ?column? 
+----------
+        1
+(1 row)
+
 RESET enable_seqscan;
 DROP INDEX jidx;
+DROP INDEX jidx_array;
 CREATE INDEX jidx ON testjsonb USING gin (j);
 SET enable_seqscan = off;
 SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}';
@@ -1476,11 +1492,19 @@ SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'];
     42
 (1 row)
 
+-- array exists - array elements should behave as keys (for GIN index scans too)
+CREATE INDEX jidx_array ON testjsonb USING gin((j->'array'));
+SELECT 1 from testjsonb  WHERE j->'array' ? 'bar';
+ ?column? 
+----------
+        1
+(1 row)
+
 RESET enable_seqscan;
 SELECT count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow;
  count 
 -------
-  4783
+  4784
 (1 row)
 
 SELECT key, count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow GROUP BY key ORDER BY count DESC, key;
@@ -1509,20 +1533,21 @@ SELECT key, count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow GRO
  auth      |   168
  abstract  |   161
  age       |     2
-(23 rows)
+ array     |     1
+(24 rows)
 
 -- sort/hash
 SELECT count(distinct j) FROM testjsonb;
  count 
 -------
-   886
+   887
 (1 row)
 
 SET enable_hashagg = off;
 SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2;
  count 
 -------
-   886
+   887
 (1 row)
 
 SET enable_hashagg = on;
@@ -1530,7 +1555,7 @@ SET enable_sort = off;
 SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2;
  count 
 -------
-   886
+   887
 (1 row)
 
 SELECT distinct * FROM (values (jsonb '{}' || ''),('{}')) v(j);
@@ -1542,8 +1567,9 @@ SELECT distinct * FROM (values (jsonb '{}' || ''),('{}')) v(j);
 SET enable_sort = on;
 RESET enable_hashagg;
 RESET enable_sort;
--- btree
 DROP INDEX jidx;
+DROP INDEX jidx_array;
+-- btree
 CREATE INDEX jidx ON testjsonb USING btree (j);
 SET enable_seqscan = off;
 SELECT count(*) FROM testjsonb WHERE j > '{"p":1}';