Skip to content

Commit f1f4dee

Browse files
committed
Tests and bugfixes.
1 parent ec72088 commit f1f4dee

File tree

5 files changed

+280
-3
lines changed

5 files changed

+280
-3
lines changed

data/test_jsquery.data

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,3 +1005,13 @@
10051005
{"array": [2,3]}
10061006
{"array": [2]}
10071007
{"array": [4,5]}
1008+
{"t": 1}
1009+
{"t": 99}
1010+
{"t": {}}
1011+
{"t": {"y": "z"}}
1012+
{"t": []}
1013+
{"t": [1]}
1014+
{"t": "x"}
1015+
{"t": "a"}
1016+
{"t": true}
1017+
{"t": false}

expected/jsquery.out

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,48 @@ SELECT gin_debug_query_path_value('x <@ [1,2,3]');
13601360

13611361
(1 row)
13621362

1363+
SELECT gin_debug_query_path_value('x = *');
1364+
gin_debug_query_path_value
1365+
----------------------------
1366+
x = * , entry 0 +
1367+
1368+
(1 row)
1369+
1370+
SELECT gin_debug_query_path_value('x is boolean');
1371+
gin_debug_query_path_value
1372+
----------------------------
1373+
x IS boolean , entry 0 +
1374+
1375+
(1 row)
1376+
1377+
SELECT gin_debug_query_path_value('x is string');
1378+
gin_debug_query_path_value
1379+
----------------------------
1380+
x IS string , entry 0 +
1381+
1382+
(1 row)
1383+
1384+
SELECT gin_debug_query_path_value('x is numeric');
1385+
gin_debug_query_path_value
1386+
----------------------------
1387+
x IS numeric , entry 0 +
1388+
1389+
(1 row)
1390+
1391+
SELECT gin_debug_query_path_value('x is array');
1392+
gin_debug_query_path_value
1393+
----------------------------
1394+
x IS array , entry 0 +
1395+
1396+
(1 row)
1397+
1398+
SELECT gin_debug_query_path_value('x is object');
1399+
gin_debug_query_path_value
1400+
----------------------------
1401+
x IS object , entry 0 +
1402+
1403+
(1 row)
1404+
13631405
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');
13641406
gin_debug_query_value_path
13651407
----------------------------
@@ -1483,6 +1525,48 @@ SELECT gin_debug_query_value_path('x = [1,2,3]');
14831525

14841526
(1 row)
14851527

1528+
SELECT gin_debug_query_value_path('x = *');
1529+
gin_debug_query_value_path
1530+
----------------------------
1531+
x = * , entry 0 +
1532+
1533+
(1 row)
1534+
1535+
SELECT gin_debug_query_value_path('x is boolean');
1536+
gin_debug_query_value_path
1537+
----------------------------
1538+
x IS boolean , entry 0 +
1539+
1540+
(1 row)
1541+
1542+
SELECT gin_debug_query_value_path('x is string');
1543+
gin_debug_query_value_path
1544+
----------------------------
1545+
x IS string , entry 0 +
1546+
1547+
(1 row)
1548+
1549+
SELECT gin_debug_query_value_path('x is numeric');
1550+
gin_debug_query_value_path
1551+
----------------------------
1552+
x IS numeric , entry 0 +
1553+
1554+
(1 row)
1555+
1556+
SELECT gin_debug_query_value_path('x is array');
1557+
gin_debug_query_value_path
1558+
----------------------------
1559+
x IS array , entry 0 +
1560+
1561+
(1 row)
1562+
1563+
SELECT gin_debug_query_value_path('x is object');
1564+
gin_debug_query_value_path
1565+
----------------------------
1566+
x IS object , entry 0 +
1567+
1568+
(1 row)
1569+
14861570
---table and index
14871571
select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 0;
14881572
count
@@ -1606,6 +1690,18 @@ select count(*) from test_jsquery where v @@ 'similar_product_ids && ["044018029
16061690
4
16071691
(1 row)
16081692

1693+
select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]';
1694+
count
1695+
-------
1696+
54
1697+
(1 row)
1698+
1699+
select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]';
1700+
count
1701+
-------
1702+
3
1703+
(1 row)
1704+
16091705
select count(*) from test_jsquery where v @@ 'customer_id = null';
16101706
count
16111707
-------
@@ -1624,6 +1720,42 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
16241720
1
16251721
(1 row)
16261722

1723+
select count(*) from test_jsquery where v @@ 't = *';
1724+
count
1725+
-------
1726+
10
1727+
(1 row)
1728+
1729+
select count(*) from test_jsquery where v @@ 't is boolean';
1730+
count
1731+
-------
1732+
2
1733+
(1 row)
1734+
1735+
select count(*) from test_jsquery where v @@ 't is string';
1736+
count
1737+
-------
1738+
2
1739+
(1 row)
1740+
1741+
select count(*) from test_jsquery where v @@ 't is numeric';
1742+
count
1743+
-------
1744+
2
1745+
(1 row)
1746+
1747+
select count(*) from test_jsquery where v @@ 't is array';
1748+
count
1749+
-------
1750+
2
1751+
(1 row)
1752+
1753+
select count(*) from test_jsquery where v @@ 't is object';
1754+
count
1755+
-------
1756+
2
1757+
(1 row)
1758+
16271759
select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
16281760
v
16291761
-------------------
@@ -1746,6 +1878,18 @@ select count(*) from test_jsquery where v @@ 'similar_product_ids && ["044018029
17461878
4
17471879
(1 row)
17481880

1881+
select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]';
1882+
count
1883+
-------
1884+
54
1885+
(1 row)
1886+
1887+
select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]';
1888+
count
1889+
-------
1890+
3
1891+
(1 row)
1892+
17491893
select count(*) from test_jsquery where v @@ 'customer_id = null';
17501894
count
17511895
-------
@@ -1764,6 +1908,42 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
17641908
1
17651909
(1 row)
17661910

1911+
select count(*) from test_jsquery where v @@ 't = *';
1912+
count
1913+
-------
1914+
10
1915+
(1 row)
1916+
1917+
select count(*) from test_jsquery where v @@ 't is boolean';
1918+
count
1919+
-------
1920+
2
1921+
(1 row)
1922+
1923+
select count(*) from test_jsquery where v @@ 't is string';
1924+
count
1925+
-------
1926+
2
1927+
(1 row)
1928+
1929+
select count(*) from test_jsquery where v @@ 't is numeric';
1930+
count
1931+
-------
1932+
2
1933+
(1 row)
1934+
1935+
select count(*) from test_jsquery where v @@ 't is array';
1936+
count
1937+
-------
1938+
2
1939+
(1 row)
1940+
1941+
select count(*) from test_jsquery where v @@ 't is object';
1942+
count
1943+
-------
1944+
2
1945+
(1 row)
1946+
17671947
explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
17681948
QUERY PLAN
17691949
---------------------------------------------------------------
@@ -1931,6 +2111,18 @@ select count(*) from test_jsquery where v @@ 'similar_product_ids && ["044018029
19312111
4
19322112
(1 row)
19332113

2114+
select count(*) from test_jsquery where v @@ 'similar_product_ids <@ ["B00000DG0U", "B00004SQXU", "B0001XAM18", "B00000FDBU", "B00000FDBV", "B000002H2H", "B000002H6C", "B000002H5E", "B000002H97", "B000002HMH"]';
2115+
count
2116+
-------
2117+
54
2118+
(1 row)
2119+
2120+
select count(*) from test_jsquery where v @@ 'similar_product_ids @> ["B000002H2H", "B000002H6C"]';
2121+
count
2122+
-------
2123+
3
2124+
(1 row)
2125+
19342126
select count(*) from test_jsquery where v @@ 'customer_id = null';
19352127
count
19362128
-------
@@ -1949,6 +2141,42 @@ select count(*) from test_jsquery where v @@ 'product_group = false';
19492141
1
19502142
(1 row)
19512143

2144+
select count(*) from test_jsquery where v @@ 't = *';
2145+
count
2146+
-------
2147+
10
2148+
(1 row)
2149+
2150+
select count(*) from test_jsquery where v @@ 't is boolean';
2151+
count
2152+
-------
2153+
2
2154+
(1 row)
2155+
2156+
select count(*) from test_jsquery where v @@ 't is string';
2157+
count
2158+
-------
2159+
2
2160+
(1 row)
2161+
2162+
select count(*) from test_jsquery where v @@ 't is numeric';
2163+
count
2164+
-------
2165+
2
2166+
(1 row)
2167+
2168+
select count(*) from test_jsquery where v @@ 't is array';
2169+
count
2170+
-------
2171+
2
2172+
(1 row)
2173+
2174+
select count(*) from test_jsquery where v @@ 't is object';
2175+
count
2176+
-------
2177+
2
2178+
(1 row)
2179+
19522180
explain (costs off) select v from test_jsquery where v @@ 'array <@ [2,3]' order by v;
19532181
QUERY PLAN
19542182
---------------------------------------------------------------

jsonb_gin_ops.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ gin_extract_jsonb_bloom_value_internal(Jsonb *jb, int32 *nentries, uint32 **bloo
680680

681681
switch (r)
682682
{
683+
case WJB_BEGIN_ARRAY:
684+
entries[i++] = PointerGetDatum(make_gin_key(&v, get_path_bloom(stack)));
685+
break;
683686
case WJB_BEGIN_OBJECT:
687+
entries[i++] = PointerGetDatum(make_gin_key(&v, get_path_bloom(stack)));
684688
tmp = stack;
685689
stack = (PathHashStack *) palloc(sizeof(PathHashStack));
686690
stack->parent = tmp;
@@ -709,7 +713,6 @@ gin_extract_jsonb_bloom_value_internal(Jsonb *jb, int32 *nentries, uint32 **bloo
709713
stack = tmp;
710714
break;
711715
case WJB_END_ARRAY:
712-
case WJB_BEGIN_ARRAY:
713716
break;
714717
default:
715718
elog(ERROR, "invalid JsonbIteratorNext rc: %d", r);

jsquery_extract.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ getTypeString(int32 type)
903903
case jbvNumeric:
904904
return "numeric";
905905
case jbvBool:
906-
return "bool";
906+
return "boolean";
907907
case jbvNull:
908908
return "null";
909909
default:
@@ -946,7 +946,7 @@ debugRecursive(StringInfo buf, ExtractedNode *node, int shift)
946946
appendStringInfo(buf, " = [] ,");
947947
break;
948948
case eIs:
949-
appendStringInfo(buf, " IS %s ,", getTypeString(node->type));
949+
appendStringInfo(buf, " IS %s ,", getTypeString(node->isType));
950950
break;
951951
case eInequality:
952952
if (node->bounds.leftBound)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy