Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2ed982

Browse files
committed
dummy support of filter in gin index (just ignore), fix support of path existing
1 parent4f82c4a commita2ed982

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

‎expected/jsquery.out

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ select '* < 13 AND #.zxc"x" = "true"'::jsquery;
6767
ERROR: bad jsquery representation
6868
LINE 1: select '* < 13 AND #.zxc"x" = "true"'::jsquery;
6969
^
70-
DETAIL: syntax error, unexpected STRING_P at or near """
70+
DETAIL: syntax error, unexpected STRING_P, expecting $end at or near """
7171
select 'a < 1'::jsquery;
7272
jsquery
7373
---------
@@ -1856,6 +1856,54 @@ select '[16]' @@ '(@# > 0 and #: = 16)'::jsquery;
18561856
t
18571857
(1 row)
18581858

1859+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b or b.d';
1860+
?column?
1861+
----------
1862+
t
1863+
(1 row)
1864+
1865+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c or b.d';
1866+
?column?
1867+
----------
1868+
t
1869+
(1 row)
1870+
1871+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.d';
1872+
?column?
1873+
----------
1874+
t
1875+
(1 row)
1876+
1877+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g or b.c';
1878+
?column?
1879+
----------
1880+
f
1881+
(1 row)
1882+
1883+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.b and b.d';
1884+
?column?
1885+
----------
1886+
t
1887+
(1 row)
1888+
1889+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.d';
1890+
?column?
1891+
----------
1892+
t
1893+
(1 row)
1894+
1895+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.c and b.b';
1896+
?column?
1897+
----------
1898+
f
1899+
(1 row)
1900+
1901+
select '{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@ 'a.g and b.d';
1902+
?column?
1903+
----------
1904+
f
1905+
(1 row)
1906+
18591907
--extract entries for index scan
18601908
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');
18611909
gin_debug_query_path_value
@@ -2236,6 +2284,13 @@ SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)');
22362284

22372285
(1 row)
22382286

2287+
SELECT gin_debug_query_value_path('tags.#.term. ? ( # = "NYC").x > 0');
2288+
gin_debug_query_value_path
2289+
------------------------------
2290+
tags.#.term.x > 0 , entry 0 +
2291+
2292+
(1 row)
2293+
22392294
---table and index
22402295
select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 0;
22412296
count

‎jsonb_gin_ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
33
* jsonb_gin_ops.c
4-
*Support GIN over jsonb with jsquery operation
4+
*Support GIN over jsonb with jsquery operation
55
*
66
* Copyright (c) 2014, PostgreSQL Global Development Group
77
* Author: Alexander Korotkov <aekorotkov@gmail.com>
88
*
99
* IDENTIFICATION
10-
*contrib/jsquery/jsonb_gin_ops.c
10+
*contrib/jsquery/jsonb_gin_ops.c
1111
*
1212
*-------------------------------------------------------------------------
1313
*/

‎jsquery_extract.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ recursiveExtract(JsQueryItem *jsq, bool not, bool indirect, PathItem *path)
130130
pathItem->parent=path;
131131
jsqGetNext(jsq,&elem);
132132
returnrecursiveExtract(&elem,not, true,pathItem);
133+
casejqiFilter:
134+
/* ignore filter for now */
133135
casejqiCurrent:
134136
jsqGetNext(jsq,&elem);
135137
returnrecursiveExtract(&elem,not,indirect,path);

‎jsquery_gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ makeItemList(List *list) {
250250

251251
result:
252252
expr{ *result =$1; }
253-
|path{ *result = makeItemList($1); }
254253
|/* EMPTY*/{ *result =NULL; }
255254
;
256255

@@ -307,7 +306,8 @@ right_expr:
307306
;
308307

309308
expr:
310-
pathright_expr{$$ = makeItemList(lappend($1,$2)); }
309+
path{$$ = makeItemList($1); }
310+
|pathright_expr{$$ = makeItemList(lappend($1,$2)); }
311311
|pathHINT_Pright_expr{$3->hint =$2;$$ = makeItemList(lappend($1,$3)); }
312312
|NOT_Pexpr{$$ = makeItemUnary(jqiNot,$2); }
313313
/*

‎sql/jsquery.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,15 @@ 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
369369
select'[]' @@'(@# > 0 and #: = 16)'::jsquery;
370370
select'[16]' @@'(@# > 0 and #: = 16)'::jsquery;
371371

372+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.b or b.d';
373+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.c or b.d';
374+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.g or b.d';
375+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.g or b.c';
376+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.b and b.d';
377+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.c and b.d';
378+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.c and b.b';
379+
select'{"a": {"b": 1, "c": 2}, "b": {"d":3}}'::jsonb @@'a.g and b.d';
380+
372381
--extract entries for index scan
373382

374383
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');
@@ -419,6 +428,7 @@ SELECT gin_debug_query_value_path('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)')
419428
SELECT gin_debug_query_value_path('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)');
420429
SELECT gin_debug_query_value_path('(@# > 0 and #: = 16)');
421430
SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)');
431+
SELECT gin_debug_query_value_path('tags.#.term. ? ( # = "NYC").x > 0');
422432

423433
---table and index
424434

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp