Skip to content

Commit 22c5705

Browse files
committed
Use JsonbIteratorToken consistently in automatic variable declarations.
Many functions stored JsonbIteratorToken values in variables of other integer types. Also, standardize order relative to other declarations. Expect compilers to generate the same code before and after this change.
1 parent c9853e6 commit 22c5705

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/backend/utils/adt/jsonb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
372372
{
373373
bool first = true;
374374
JsonbIterator *it;
375-
JsonbIteratorToken type = WJB_DONE;
376375
JsonbValue v;
376+
JsonbIteratorToken type = WJB_DONE;
377377
int level = 0;
378378
bool redo_switch = false;
379379

src/backend/utils/adt/jsonb_gin.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
7070
int total = 2 * JB_ROOT_COUNT(jb);
7171
JsonbIterator *it;
7272
JsonbValue v;
73-
int i = 0,
74-
r;
73+
JsonbIteratorToken r;
74+
int i = 0;
7575
Datum *entries;
7676

7777
/* If the root level is empty, we certainly have no keys */
@@ -333,10 +333,10 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
333333
int total = 2 * JB_ROOT_COUNT(jb);
334334
JsonbIterator *it;
335335
JsonbValue v;
336+
JsonbIteratorToken r;
336337
PathHashStack tail;
337338
PathHashStack *stack;
338-
int i = 0,
339-
r;
339+
int i = 0;
340340
Datum *entries;
341341

342342
/* If the root level is empty, we certainly have no keys */
@@ -429,7 +429,7 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
429429
stack = parent;
430430
break;
431431
default:
432-
elog(ERROR, "invalid JsonbIteratorNext rc: %d", r);
432+
elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
433433
}
434434
}
435435

src/backend/utils/adt/jsonb_op.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ jsonb_hash(PG_FUNCTION_ARGS)
254254
{
255255
Jsonb *jb = PG_GETARG_JSONB(0);
256256
JsonbIterator *it;
257-
int32 r;
258257
JsonbValue v;
258+
JsonbIteratorToken r;
259259
uint32 hash = 0;
260260

261261
if (JB_ROOT_COUNT(jb) == 0)
@@ -283,7 +283,7 @@ jsonb_hash(PG_FUNCTION_ARGS)
283283
case WJB_END_OBJECT:
284284
break;
285285
default:
286-
elog(ERROR, "invalid JsonbIteratorNext rc: %d", r);
286+
elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
287287
}
288288
}
289289

src/backend/utils/adt/jsonb_util.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
187187
{
188188
JsonbValue va,
189189
vb;
190-
int ra,
190+
JsonbIteratorToken ra,
191191
rb;
192192

193193
ra = JsonbIteratorNext(&ita, &va, false);
@@ -961,10 +961,10 @@ freeAndGetParent(JsonbIterator *it)
961961
bool
962962
JsonbDeepContains(JsonbIterator **val, JsonbIterator **mContained)
963963
{
964-
uint32 rval,
965-
rcont;
966964
JsonbValue vval,
967965
vcontained;
966+
JsonbIteratorToken rval,
967+
rcont;
968968

969969
/*
970970
* Guard against stack overflow due to overly complex Jsonb.

src/backend/utils/adt/jsonfuncs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
255255
bool skipNested = false;
256256
JsonbIterator *it;
257257
JsonbValue v;
258-
int r;
258+
JsonbIteratorToken r;
259259

260260
if (JB_ROOT_IS_SCALAR(jb))
261261
ereport(ERROR,
@@ -1195,7 +1195,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
11951195
if (jbvp->type == jbvBinary)
11961196
{
11971197
JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data);
1198-
int r;
1198+
JsonbIteratorToken r;
11991199

12001200
r = JsonbIteratorNext(&it, &tv, true);
12011201
container = (JsonbContainer *) jbvp->val.binary.data;
@@ -1368,7 +1368,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
13681368
bool skipNested = false;
13691369
JsonbIterator *it;
13701370
JsonbValue v;
1371-
int r;
1371+
JsonbIteratorToken r;
13721372

13731373
if (!JB_ROOT_IS_OBJECT(jb))
13741374
ereport(ERROR,
@@ -1687,7 +1687,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
16871687
bool skipNested = false;
16881688
JsonbIterator *it;
16891689
JsonbValue v;
1690-
int r;
1690+
JsonbIteratorToken r;
16911691

16921692
if (JB_ROOT_IS_SCALAR(jb))
16931693
ereport(ERROR,
@@ -2704,7 +2704,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
27042704
JsonbIterator *it;
27052705
JsonbValue v;
27062706
bool skipNested = false;
2707-
int r;
2707+
JsonbIteratorToken r;
27082708

27092709
Assert(jtype == JSONBOID);
27102710

0 commit comments

Comments
 (0)