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

Appearance settings

Commit a7adffa

Browse filesBrowse files
committed
fix lack of support #N in construction of jsquery
1 parent d0166fb commit a7adffa
Copy full SHA for a7adffa

File tree

3 files changed

+24
-13
lines changed
Filter options

3 files changed

+24
-13
lines changed

‎expected/jsquery.out

Copy file name to clipboardExpand all lines: expected/jsquery.out
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,12 @@ select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero';
865865
(((NOT "asd".# = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero"))
866866
(1 row)
867867

868+
select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero';
869+
?column?
870+
-----------------------------------------------------------------------
871+
(((NOT "asd".#3."f" = 3) AND "zzz" = true) OR (NOT "xxx".# = "zero"))
872+
(1 row)
873+
868874
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery;
869875
?column?
870876
----------

‎jsquery_constr.c

Copy file name to clipboardExpand all lines: jsquery_constr.c
+17-13Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* jsquery_manipulation.c
4-
* Functions and operations to manipulate jsquery
3+
* jsquery_constr.c
4+
* Functions and operations to manipulate jsquery
55
*
66
* Copyright (c) 2014, PostgreSQL Global Development Group
77
* Author: Teodor Sigaev <teodor@sigaev.ru>
88
*
99
* IDENTIFICATION
10-
* contrib/jsquery/jsquery_manipulation.c
10+
* contrib/jsquery/jsquery_constr.c
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -23,8 +23,8 @@ static int32
2323
copyJsQuery(StringInfo buf, JsQueryItem *jsq)
2424
{
2525
JsQueryItem elem;
26-
int32 next, chld;
27-
int32 resPos = buf->len - VARHDRSZ; /* position from begining of jsquery data */
26+
int32 next, chld;
27+
int32 resPos = buf->len - VARHDRSZ; /* position from begining of jsquery data */
2828

2929
check_stack_depth();
3030

@@ -42,7 +42,7 @@ copyJsQuery(StringInfo buf, JsQueryItem *jsq)
4242
case jqiKey:
4343
case jqiString:
4444
{
45-
int32 len;
45+
int32 len;
4646
char *s;
4747

4848
s = jsqGetString(jsq, &len);
@@ -124,6 +124,10 @@ copyJsQuery(StringInfo buf, JsQueryItem *jsq)
124124
*(int32*)(buf->data + argOut) = chld;
125125
}
126126
break;
127+
case jqiIndexArray:
128+
appendBinaryStringInfo(buf, (char*)&jsq->arrayIndex,
129+
sizeof(jsq->arrayIndex));
130+
break;
127131
case jqiNull:
128132
case jqiCurrent:
129133
case jqiLength:
@@ -150,7 +154,7 @@ joinJsQuery(JsQueryItemType type, JsQuery *jq1, JsQuery *jq2)
150154
JsQuery *out;
151155
StringInfoData buf;
152156
int32 left, right, chld;
153-
JsQueryItem v;
157+
JsQueryItem v;
154158

155159
initStringInfo(&buf);
156160
enlargeStringInfo(&buf, VARSIZE_ANY(jq1) + VARSIZE_ANY(jq2) + 4 * sizeof(int32) + VARHDRSZ);
@@ -188,9 +192,9 @@ PG_FUNCTION_INFO_V1(jsquery_join_and);
188192
Datum
189193
jsquery_join_and(PG_FUNCTION_ARGS)
190194
{
191-
JsQuery *jq1 = PG_GETARG_JSQUERY(0);
192-
JsQuery *jq2 = PG_GETARG_JSQUERY(1);
193-
JsQuery *out;
195+
JsQuery *jq1 = PG_GETARG_JSQUERY(0);
196+
JsQuery *jq2 = PG_GETARG_JSQUERY(1);
197+
JsQuery *out;
194198

195199
out = joinJsQuery(jqiAnd, jq1, jq2);
196200

@@ -204,9 +208,9 @@ PG_FUNCTION_INFO_V1(jsquery_join_or);
204208
Datum
205209
jsquery_join_or(PG_FUNCTION_ARGS)
206210
{
207-
JsQuery *jq1 = PG_GETARG_JSQUERY(0);
208-
JsQuery *jq2 = PG_GETARG_JSQUERY(1);
209-
JsQuery *out;
211+
JsQuery *jq1 = PG_GETARG_JSQUERY(0);
212+
JsQuery *jq2 = PG_GETARG_JSQUERY(1);
213+
JsQuery *out;
210214

211215
out = joinJsQuery(jqiOr, jq1, jq2);
212216

‎sql/jsquery.sql

Copy file name to clipboardExpand all lines: sql/jsquery.sql
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ select '{"a": {"b": [1,2,3]}}'::jsonb @@ 'a.b.# && [1,2,3]';
175175

176176
select 'asd.# = 3'::jsquery & 'zzz = true' | 'xxx.# = zero';
177177
select !'asd.# = 3'::jsquery & 'zzz = true' | !'xxx.# = zero';
178+
select !'asd.#3.f = 3'::jsquery & 'zzz = true' | !'xxx.# = zero';
178179

179180
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0]'::jsquery;
180181
select '{"x":[0,1,1,2]}'::jsonb @@ 'x @> [1,0,1]'::jsquery;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.