Skip to content

Commit a0478b6

Browse files
committed
Revert 4178d8b
As it was agreed to worsen the code readability. Discussion: https://postgr.es/m/ecfcfb5f-3233-eaa9-0c83-07056fb49a83%402ndquadrant.com
1 parent 8b938d3 commit a0478b6

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
int cflags;
127127
} JsonLikeRegexContext;
128128

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

158-
#define EmptyJsonValueList {NULL, NIL}
159-
160156
typedef struct JsonValueListIterator
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-
JsonValueList found = EmptyJsonValueList;
324+
JsonValueList found = {0};
329325
Jsonb *vars = NULL;
330326
bool silent = true;
331327

@@ -383,7 +379,7 @@ jsonb_path_query(PG_FUNCTION_ARGS)
383379
MemoryContext oldcontext;
384380
Jsonb *vars;
385381
bool silent;
386-
JsonValueList found = EmptyJsonValueList;
382+
JsonValueList found = {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-
JsonValueList found = EmptyJsonValueList;
423+
JsonValueList found = {0};
428424
Jsonb *vars = PG_GETARG_JSONB_P(2);
429425
bool silent = 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-
JsonValueList found = EmptyJsonValueList;
442+
JsonValueList found = {0};
447443
Jsonb *vars = PG_GETARG_JSONB_P(2);
448444
bool silent = 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-
JsonValueList vals = EmptyJsonValueList;
513+
JsonValueList vals = {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-
JsonValueList seq = EmptyJsonValueList;
1137+
JsonValueList seq = {0};
11421138
JsonValueListIterator it;
11431139
JsonPathExecResult res = 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-
JsonLikeRegexContext lrcxt = EmptyJsonLikeRegexContext;
1265+
JsonLikeRegexContext lrcxt = {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-
JsonValueList vals = EmptyJsonValueList;
1283+
JsonValueList vals = {0};
12881284
JsonPathExecResult res =
12891285
executeItemOptUnwrapResultNoThrow(cxt, &larg, jb,
12901286
false, &vals);
@@ -1436,8 +1432,8 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem *pred,
14361432
{
14371433
JsonPathExecResult res;
14381434
JsonValueListIterator lseqit;
1439-
JsonValueList lseq = EmptyJsonValueList;
1440-
JsonValueList rseq = EmptyJsonValueList;
1435+
JsonValueList lseq = {0};
1436+
JsonValueList rseq = {0};
14411437
JsonbValue *lval;
14421438
bool error = false;
14431439
bool found = false;
@@ -1515,8 +1511,8 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15151511
{
15161512
JsonPathExecResult jper;
15171513
JsonPathItem elem;
1518-
JsonValueList lseq = EmptyJsonValueList;
1519-
JsonValueList rseq = EmptyJsonValueList;
1514+
JsonValueList lseq = {0};
1515+
JsonValueList rseq = {0};
15201516
JsonbValue *lval;
15211517
JsonbValue *rval;
15221518
Numeric res;
@@ -1590,7 +1586,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15901586
JsonPathExecResult jper;
15911587
JsonPathExecResult jper2;
15921588
JsonPathItem elem;
1593-
JsonValueList seq = EmptyJsonValueList;
1589+
JsonValueList seq = {0};
15941590
JsonValueListIterator it;
15951591
JsonbValue *val;
15961592
bool hasNext;
@@ -2128,7 +2124,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
21282124
int32 *index)
21292125
{
21302126
JsonbValue *jbv;
2131-
JsonValueList found = EmptyJsonValueList;
2127+
JsonValueList found = {0};
21322128
JsonPathExecResult res = executeItem(cxt, jsp, jb, &found);
21332129
Datum numeric_index;
21342130
bool have_error = false;

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