Skip to content

Commit ac957ef

Browse files
committed
Merge with jsquery 0.34
1 parent 9b03e21 commit ac957ef

13 files changed

+541
-107
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# contrib/jsquery/Makefile
22

33
MODULE_big = jsquery
4-
OBJS = jsquery_io.o jsquery_gram.o jsquery_op.o jsonb_gin_ops.o jsquery_extract.o
4+
OBJS = jsquery_io.o jsquery_gram.o jsquery_op.o \
5+
jsquery_constr.o jsquery_extract.o jsonb_gin_ops.o
56

67
EXTENSION = jsquery
78
DATA = jsquery--1.0.sql

expected/jsquery.out

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,105 @@ select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]';
684684
f
685685
(1 row)
686686

687+
select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero';
688+
?column?
689+
---------------------------------------------------
690+
(("asd".# = 3 & "zzz" = true) | "xxx".# = "zero")
691+
(1 row)
692+
693+
select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero';
694+
?column?
695+
---------------------------------------------------------
696+
((!("asd".# = 3) & "zzz" = true) | !("xxx".# = "zero"))
697+
(1 row)
698+
699+
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery;
700+
?column?
701+
----------
702+
t
703+
(1 row)
704+
705+
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery;
706+
?column?
707+
----------
708+
t
709+
(1 row)
710+
711+
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,3]'::jsquery;
712+
?column?
713+
----------
714+
f
715+
(1 row)
716+
717+
select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b && [ 2 ]';
718+
?column?
719+
----------
720+
t
721+
(1 row)
722+
723+
select '{"a": {"b": [1,2,3]}}'::jsonb @@ '*.b($ && [ 2 ])';
724+
?column?
725+
----------
726+
t
727+
(1 row)
728+
729+
select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b && [ 2 ]';
730+
?column?
731+
----------
732+
t
733+
(1 row)
734+
735+
select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.$.b ($ && [ 2 ])';
736+
?column?
737+
----------
738+
t
739+
(1 row)
740+
741+
select '[1,2,3]'::jsonb @@ '# && [2]';
742+
?column?
743+
----------
744+
f
745+
(1 row)
746+
747+
select '[1,2,3]'::jsonb @@ '#($ && [2])';
748+
?column?
749+
----------
750+
f
751+
(1 row)
752+
753+
select '[1,2,3]'::jsonb @@ '$ && [2]';
754+
?column?
755+
----------
756+
t
757+
(1 row)
758+
759+
select '[1,2,3]'::jsonb @@ '$ ($ && [2])';
760+
?column?
761+
----------
762+
t
763+
(1 row)
764+
765+
select '[1,2,3]'::jsonb @@ '$ = 2';
766+
?column?
767+
----------
768+
f
769+
(1 row)
770+
771+
select '[1,2,3]'::jsonb @@ '# = 2';
772+
?column?
773+
----------
774+
t
775+
(1 row)
776+
777+
select '[1,2,3]'::jsonb @@ '#.$ = 2';
778+
?column?
779+
----------
780+
t
781+
(1 row)
782+
783+
select '[1,2,3]'::jsonb @@ '#($ = 2)';
784+
?column?
785+
----------
786+
t
787+
(1 row)
788+

jsonb_gin_ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ gin_extract_jsonb_bloom_value_internal(Jsonb *jb, int32 *nentries, uint32 **bloo
529529
if (bloom)
530530
(*bloom) = (uint32 *) palloc(sizeof(uint32) * total);
531531

532-
it = JsonbIteratorInit(VARDATA(jb));
532+
it = JsonbIteratorInit(&jb->root);
533533

534534
stack = NULL;
535535

@@ -936,7 +936,7 @@ gin_extract_jsonb_hash_value_internal(Jsonb *jb, int32 *nentries)
936936

937937
entries = (Datum *) palloc(sizeof(Datum) * total);
938938

939-
it = JsonbIteratorInit(VARDATA(jb));
939+
it = JsonbIteratorInit(&jb->root);
940940

941941
tail.parent = NULL;
942942
tail.hash = 0;

jsquery--1.0.sql

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,40 @@ CREATE OPERATOR @@ (
4848
JOIN = contjoinsel
4949
);
5050

51+
CREATE FUNCTION jsquery_join_and(jsquery, jsquery)
52+
RETURNS jsquery
53+
AS 'MODULE_PATHNAME'
54+
LANGUAGE C STRICT IMMUTABLE;
55+
56+
CREATE OPERATOR & (
57+
LEFTARG = jsquery,
58+
RIGHTARG = jsquery,
59+
PROCEDURE = jsquery_join_and,
60+
COMMUTATOR = '&'
61+
);
62+
63+
CREATE FUNCTION jsquery_join_or(jsquery, jsquery)
64+
RETURNS jsquery
65+
AS 'MODULE_PATHNAME'
66+
LANGUAGE C STRICT IMMUTABLE;
67+
68+
CREATE OPERATOR | (
69+
LEFTARG = jsquery,
70+
RIGHTARG = jsquery,
71+
PROCEDURE = jsquery_join_or,
72+
COMMUTATOR = '|'
73+
);
74+
75+
CREATE FUNCTION jsquery_not(jsquery)
76+
RETURNS jsquery
77+
AS 'MODULE_PATHNAME'
78+
LANGUAGE C STRICT IMMUTABLE;
79+
80+
CREATE OPERATOR ! (
81+
RIGHTARG = jsquery,
82+
PROCEDURE = jsquery_not
83+
);
84+
5185
CREATE FUNCTION jsquery_lt(jsquery, jsquery)
5286
RETURNS bool
5387
AS 'MODULE_PATHNAME'
@@ -246,4 +280,4 @@ CREATE OPERATOR CLASS jsonb_hash_value_ops
246280
FUNCTION 4 gin_consistent_jsonb_hash_value(internal, smallint, anyarray, integer, internal, internal, internal, internal),
247281
FUNCTION 5 gin_compare_partial_jsonb_hash_value(bytea, bytea, smallint, internal),
248282
FUNCTION 6 gin_triconsistent_jsonb_hash_value(internal, smallint, anyarray, integer, internal, internal, internal),
249-
STORAGE bytea;
283+
STORAGE bytea;

jsquery.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ struct JsQueryItem {
4848
jqiLessOrEqual = '{',
4949
jqiGreaterOrEqual = '}',
5050
jqiContains = '@',
51-
jqiContained = '$',
51+
jqiContained = '^',
5252
jqiOverlap = '%',
5353
jqiAny = '*',
5454
jqiAnyArray = '#',
5555
jqiKey = 'K',
56+
jqiCurrent = '$',
5657
jqiIn = 'I'
5758
} type;
5859

@@ -98,6 +99,7 @@ int32 readJsQueryHeader(char *base, int32 pos, int32 *type, int32 *nextPos);
9899
(p) += sizeof(int32); \
99100
} while(0) \
100101

102+
void alignStringInfoInt(StringInfo buf);
101103
#endif
102104

103105
/* jsquery_extract.c */

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