@@ -126,6 +126,8 @@ typedef struct JsonLikeRegexContext
126
126
int cflags ;
127
127
} JsonLikeRegexContext ;
128
128
129
+ #define EmptyJsonLikeRegexContext {NULL, 0}
130
+
129
131
/* Result of jsonpath predicate evaluation */
130
132
typedef enum JsonPathBool
131
133
{
@@ -153,6 +155,8 @@ typedef struct JsonValueList
153
155
List * list ;
154
156
} JsonValueList ;
155
157
158
+ #define EmptyJsonValueList {NULL, NIL}
159
+
156
160
typedef struct JsonValueListIterator
157
161
{
158
162
JsonbValue * value ;
@@ -321,7 +325,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
321
325
Jsonb * jb = PG_GETARG_JSONB_P (0 );
322
326
JsonPath * jp = PG_GETARG_JSONPATH_P (1 );
323
327
JsonbValue * jbv ;
324
- JsonValueList found = { 0 } ;
328
+ JsonValueList found = EmptyJsonValueList ;
325
329
Jsonb * vars = NULL ;
326
330
bool silent = true;
327
331
@@ -379,7 +383,7 @@ jsonb_path_query(PG_FUNCTION_ARGS)
379
383
MemoryContext oldcontext ;
380
384
Jsonb * vars ;
381
385
bool silent ;
382
- JsonValueList found = { 0 } ;
386
+ JsonValueList found = EmptyJsonValueList ;
383
387
384
388
funcctx = SRF_FIRSTCALL_INIT ();
385
389
oldcontext = MemoryContextSwitchTo (funcctx -> multi_call_memory_ctx );
@@ -420,7 +424,7 @@ jsonb_path_query_array(FunctionCallInfo fcinfo)
420
424
{
421
425
Jsonb * jb = PG_GETARG_JSONB_P (0 );
422
426
JsonPath * jp = PG_GETARG_JSONPATH_P (1 );
423
- JsonValueList found = { 0 } ;
427
+ JsonValueList found = EmptyJsonValueList ;
424
428
Jsonb * vars = PG_GETARG_JSONB_P (2 );
425
429
bool silent = PG_GETARG_BOOL (3 );
426
430
@@ -439,7 +443,7 @@ jsonb_path_query_first(FunctionCallInfo fcinfo)
439
443
{
440
444
Jsonb * jb = PG_GETARG_JSONB_P (0 );
441
445
JsonPath * jp = PG_GETARG_JSONPATH_P (1 );
442
- JsonValueList found = { 0 } ;
446
+ JsonValueList found = EmptyJsonValueList ;
443
447
Jsonb * vars = PG_GETARG_JSONB_P (2 );
444
448
bool silent = PG_GETARG_BOOL (3 );
445
449
@@ -510,7 +514,7 @@ executeJsonPath(JsonPath *path, Jsonb *vars, Jsonb *json, bool throwErrors,
510
514
* In strict mode we must get a complete list of values to check that
511
515
* there are no errors at all.
512
516
*/
513
- JsonValueList vals = { 0 } ;
517
+ JsonValueList vals = EmptyJsonValueList ;
514
518
515
519
res = executeItem (& cxt , & jsp , & jbv , & vals );
516
520
@@ -1134,7 +1138,7 @@ executeItemOptUnwrapResult(JsonPathExecContext *cxt, JsonPathItem *jsp,
1134
1138
{
1135
1139
if (unwrap && jspAutoUnwrap (cxt ))
1136
1140
{
1137
- JsonValueList seq = { 0 } ;
1141
+ JsonValueList seq = EmptyJsonValueList ;
1138
1142
JsonValueListIterator it ;
1139
1143
JsonPathExecResult res = executeItem (cxt , jsp , jb , & seq );
1140
1144
JsonbValue * item ;
@@ -1262,7 +1266,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
1262
1266
* regexes, but we use Postgres regexes here. 'flags' is a
1263
1267
* string literal converted to integer flags at compile-time.
1264
1268
*/
1265
- JsonLikeRegexContext lrcxt = { 0 } ;
1269
+ JsonLikeRegexContext lrcxt = EmptyJsonLikeRegexContext ;
1266
1270
1267
1271
jspInitByBuffer (& larg , jsp -> base ,
1268
1272
jsp -> content .like_regex .expr );
@@ -1280,7 +1284,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
1280
1284
* In strict mode we must get a complete list of values to
1281
1285
* check that there are no errors at all.
1282
1286
*/
1283
- JsonValueList vals = { 0 } ;
1287
+ JsonValueList vals = EmptyJsonValueList ;
1284
1288
JsonPathExecResult res =
1285
1289
executeItemOptUnwrapResultNoThrow (cxt , & larg , jb ,
1286
1290
false, & vals );
@@ -1432,8 +1436,8 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem *pred,
1432
1436
{
1433
1437
JsonPathExecResult res ;
1434
1438
JsonValueListIterator lseqit ;
1435
- JsonValueList lseq = { 0 } ;
1436
- JsonValueList rseq = { 0 } ;
1439
+ JsonValueList lseq = EmptyJsonValueList ;
1440
+ JsonValueList rseq = EmptyJsonValueList ;
1437
1441
JsonbValue * lval ;
1438
1442
bool error = false;
1439
1443
bool found = false;
@@ -1511,8 +1515,8 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
1511
1515
{
1512
1516
JsonPathExecResult jper ;
1513
1517
JsonPathItem elem ;
1514
- JsonValueList lseq = { 0 } ;
1515
- JsonValueList rseq = { 0 } ;
1518
+ JsonValueList lseq = EmptyJsonValueList ;
1519
+ JsonValueList rseq = EmptyJsonValueList ;
1516
1520
JsonbValue * lval ;
1517
1521
JsonbValue * rval ;
1518
1522
Numeric res ;
@@ -1586,7 +1590,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
1586
1590
JsonPathExecResult jper ;
1587
1591
JsonPathExecResult jper2 ;
1588
1592
JsonPathItem elem ;
1589
- JsonValueList seq = { 0 } ;
1593
+ JsonValueList seq = EmptyJsonValueList ;
1590
1594
JsonValueListIterator it ;
1591
1595
JsonbValue * val ;
1592
1596
bool hasNext ;
@@ -2124,7 +2128,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
2124
2128
int32 * index )
2125
2129
{
2126
2130
JsonbValue * jbv ;
2127
- JsonValueList found = { 0 } ;
2131
+ JsonValueList found = EmptyJsonValueList ;
2128
2132
JsonPathExecResult res = executeItem (cxt , jsp , jb , & found );
2129
2133
Datum numeric_index ;
2130
2134
bool have_error = false;
0 commit comments