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

Commita0478b6

Browse files
committed
Revert4178d8b
As it was agreed to worsen the code readability.Discussion:https://postgr.es/m/ecfcfb5f-3233-eaa9-0c83-07056fb49a83%402ndquadrant.com
1 parent8b938d3 commita0478b6

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

‎src/backend/utils/adt/jsonpath_exec.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ typedef struct JsonLikeRegexContext
126126
intcflags;
127127
}JsonLikeRegexContext;
128128

129-
#defineEmptyJsonLikeRegexContext{NULL, 0}
130-
131129
/* Result of jsonpath predicate evaluation */
132130
typedefenumJsonPathBool
133131
{
@@ -155,8 +153,6 @@ typedef struct JsonValueList
155153
List*list;
156154
}JsonValueList;
157155

158-
#defineEmptyJsonValueList{NULL, NIL}
159-
160156
typedefstructJsonValueListIterator
161157
{
162158
JsonbValue*value;
@@ -325,7 +321,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
325321
Jsonb*jb=PG_GETARG_JSONB_P(0);
326322
JsonPath*jp=PG_GETARG_JSONPATH_P(1);
327323
JsonbValue*jbv;
328-
JsonValueListfound=EmptyJsonValueList;
324+
JsonValueListfound={0};
329325
Jsonb*vars=NULL;
330326
boolsilent= true;
331327

@@ -383,7 +379,7 @@ jsonb_path_query(PG_FUNCTION_ARGS)
383379
MemoryContextoldcontext;
384380
Jsonb*vars;
385381
boolsilent;
386-
JsonValueListfound=EmptyJsonValueList;
382+
JsonValueListfound={0};
387383

388384
funcctx=SRF_FIRSTCALL_INIT();
389385
oldcontext=MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@@ -424,7 +420,7 @@ jsonb_path_query_array(FunctionCallInfo fcinfo)
424420
{
425421
Jsonb*jb=PG_GETARG_JSONB_P(0);
426422
JsonPath*jp=PG_GETARG_JSONPATH_P(1);
427-
JsonValueListfound=EmptyJsonValueList;
423+
JsonValueListfound={0};
428424
Jsonb*vars=PG_GETARG_JSONB_P(2);
429425
boolsilent=PG_GETARG_BOOL(3);
430426

@@ -443,7 +439,7 @@ jsonb_path_query_first(FunctionCallInfo fcinfo)
443439
{
444440
Jsonb*jb=PG_GETARG_JSONB_P(0);
445441
JsonPath*jp=PG_GETARG_JSONPATH_P(1);
446-
JsonValueListfound=EmptyJsonValueList;
442+
JsonValueListfound={0};
447443
Jsonb*vars=PG_GETARG_JSONB_P(2);
448444
boolsilent=PG_GETARG_BOOL(3);
449445

@@ -514,7 +510,7 @@ executeJsonPath(JsonPath *path, Jsonb *vars, Jsonb *json, bool throwErrors,
514510
* In strict mode we must get a complete list of values to check that
515511
* there are no errors at all.
516512
*/
517-
JsonValueListvals=EmptyJsonValueList;
513+
JsonValueListvals={0};
518514

519515
res=executeItem(&cxt,&jsp,&jbv,&vals);
520516

@@ -1138,7 +1134,7 @@ executeItemOptUnwrapResult(JsonPathExecContext *cxt, JsonPathItem *jsp,
11381134
{
11391135
if (unwrap&&jspAutoUnwrap(cxt))
11401136
{
1141-
JsonValueListseq=EmptyJsonValueList;
1137+
JsonValueListseq={0};
11421138
JsonValueListIteratorit;
11431139
JsonPathExecResultres=executeItem(cxt,jsp,jb,&seq);
11441140
JsonbValue*item;
@@ -1266,7 +1262,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
12661262
* regexes, but we use Postgres regexes here. 'flags' is a
12671263
* string literal converted to integer flags at compile-time.
12681264
*/
1269-
JsonLikeRegexContextlrcxt=EmptyJsonLikeRegexContext;
1265+
JsonLikeRegexContextlrcxt={0};
12701266

12711267
jspInitByBuffer(&larg,jsp->base,
12721268
jsp->content.like_regex.expr);
@@ -1284,7 +1280,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
12841280
* In strict mode we must get a complete list of values to
12851281
* check that there are no errors at all.
12861282
*/
1287-
JsonValueListvals=EmptyJsonValueList;
1283+
JsonValueListvals={0};
12881284
JsonPathExecResultres=
12891285
executeItemOptUnwrapResultNoThrow(cxt,&larg,jb,
12901286
false,&vals);
@@ -1436,8 +1432,8 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem *pred,
14361432
{
14371433
JsonPathExecResultres;
14381434
JsonValueListIteratorlseqit;
1439-
JsonValueListlseq=EmptyJsonValueList;
1440-
JsonValueListrseq=EmptyJsonValueList;
1435+
JsonValueListlseq={0};
1436+
JsonValueListrseq={0};
14411437
JsonbValue*lval;
14421438
boolerror= false;
14431439
boolfound= false;
@@ -1515,8 +1511,8 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15151511
{
15161512
JsonPathExecResultjper;
15171513
JsonPathItemelem;
1518-
JsonValueListlseq=EmptyJsonValueList;
1519-
JsonValueListrseq=EmptyJsonValueList;
1514+
JsonValueListlseq={0};
1515+
JsonValueListrseq={0};
15201516
JsonbValue*lval;
15211517
JsonbValue*rval;
15221518
Numericres;
@@ -1590,7 +1586,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15901586
JsonPathExecResultjper;
15911587
JsonPathExecResultjper2;
15921588
JsonPathItemelem;
1593-
JsonValueListseq=EmptyJsonValueList;
1589+
JsonValueListseq={0};
15941590
JsonValueListIteratorit;
15951591
JsonbValue*val;
15961592
boolhasNext;
@@ -2128,7 +2124,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
21282124
int32*index)
21292125
{
21302126
JsonbValue*jbv;
2131-
JsonValueListfound=EmptyJsonValueList;
2127+
JsonValueListfound={0};
21322128
JsonPathExecResultres=executeItem(cxt,jsp,jb,&found);
21332129
Datumnumeric_index;
21342130
boolhave_error= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp