Skip to content

Commit bf8884a

Browse files
committed
teach gin extract to ignore length of array
1 parent 94fe153 commit bf8884a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

expected/jsquery.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,20 @@ SELECT gin_debug_query_value_path('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *
19741974

19751975
(1 row)
19761976

1977+
SELECT gin_debug_query_value_path('(@# > 0 and #: = 16)');
1978+
gin_debug_query_value_path
1979+
----------------------------
1980+
NULL +
1981+
1982+
(1 row)
1983+
1984+
SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)');
1985+
gin_debug_query_value_path
1986+
----------------------------
1987+
NULL +
1988+
1989+
(1 row)
1990+
19771991
---table and index
19781992
select count(*) from test_jsquery where (v->>'review_helpful_votes')::int4 > 0;
19791993
count

jsquery_extract.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ recursiveExtract(JsQueryItem *jsq, bool not, bool indirect, PathItem *path)
5050

5151
check_stack_depth();
5252

53-
switch(jsq->type) {
53+
switch(jsq->type)
54+
{
5455
case jqiAnd:
5556
case jqiOr:
5657
type = ((jsq->type == jqiAnd) == not) ? eOr : eAnd;
@@ -240,9 +241,12 @@ recursiveExtract(JsQueryItem *jsq, bool not, bool indirect, PathItem *path)
240241
result->indirect = indirect;
241242
result->isType = jsqGetIsType(jsq);
242243
return result;
244+
case jqiLength:
245+
return NULL;
243246
default:
244247
elog(ERROR,"Wrong state: %d", jsq->type);
245248
}
249+
246250
return NULL;
247251
}
248252

sql/jsquery.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ SELECT gin_debug_query_value_path('x is object');
371371
SELECT gin_debug_query_value_path('#:(x=1) AND %:(y=1) AND *:(z=1)');
372372
SELECT gin_debug_query_value_path('#:(NOT x=1) AND %:(NOT y=1) AND *:(NOT z=1)');
373373
SELECT gin_debug_query_value_path('NOT #:(NOT x=1) AND NOT %:(NOT y=1) AND NOT *:(NOT z=1)');
374+
SELECT gin_debug_query_value_path('(@# > 0 and #: = 16)');
375+
SELECT gin_debug_query_value_path('*.@# ($ = 4 or $ = 2)');
374376

375377
---table and index
376378

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