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

Commita7adffa

Browse files
committed
fix lack of support #N in construction of jsquery
1 parentd0166fb commita7adffa

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

‎expected/jsquery.out

Lines 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

Lines 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(StringInfobuf,JsQueryItem*jsq)
2424
{
2525
JsQueryItemelem;
26-
int32next,chld;
27-
int32resPos=buf->len-VARHDRSZ;/* position from begining of jsquery data */
26+
int32next,chld;
27+
int32resPos=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
casejqiKey:
4343
casejqiString:
4444
{
45-
int32len;
45+
int32len;
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+
casejqiIndexArray:
128+
appendBinaryStringInfo(buf, (char*)&jsq->arrayIndex,
129+
sizeof(jsq->arrayIndex));
130+
break;
127131
casejqiNull:
128132
casejqiCurrent:
129133
casejqiLength:
@@ -150,7 +154,7 @@ joinJsQuery(JsQueryItemType type, JsQuery *jq1, JsQuery *jq2)
150154
JsQuery*out;
151155
StringInfoDatabuf;
152156
int32left,right,chld;
153-
JsQueryItemv;
157+
JsQueryItemv;
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

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp