Commit 7732d49c authored by Noah Misch's avatar Noah Misch

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.
parent f20b2696
...@@ -455,8 +455,8 @@ JsonbToCStringWorker(StringInfo out, JsonbContainer *in, int estimated_len, bool ...@@ -455,8 +455,8 @@ JsonbToCStringWorker(StringInfo out, JsonbContainer *in, int estimated_len, bool
{ {
bool first = true; bool first = true;
JsonbIterator *it; JsonbIterator *it;
JsonbIteratorToken type = WJB_DONE;
JsonbValue v; JsonbValue v;
JsonbIteratorToken type = WJB_DONE;
int level = 0; int level = 0;
bool redo_switch = false; bool redo_switch = false;
...@@ -899,7 +899,6 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, ...@@ -899,7 +899,6 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result,
case JSONBTYPE_JSONB: case JSONBTYPE_JSONB:
{ {
Jsonb *jsonb = DatumGetJsonb(val); Jsonb *jsonb = DatumGetJsonb(val);
JsonbIteratorToken type;
JsonbIterator *it; JsonbIterator *it;
it = JsonbIteratorInit(&jsonb->root); it = JsonbIteratorInit(&jsonb->root);
...@@ -913,6 +912,8 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, ...@@ -913,6 +912,8 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result,
} }
else else
{ {
JsonbIteratorToken type;
while ((type = JsonbIteratorNext(&it, &jb, false)) while ((type = JsonbIteratorNext(&it, &jb, false))
!= WJB_DONE) != WJB_DONE)
{ {
......
...@@ -70,8 +70,8 @@ gin_extract_jsonb(PG_FUNCTION_ARGS) ...@@ -70,8 +70,8 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
int total = 2 * JB_ROOT_COUNT(jb); int total = 2 * JB_ROOT_COUNT(jb);
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
int i = 0, JsonbIteratorToken r;
r; int i = 0;
Datum *entries; Datum *entries;
/* If the root level is empty, we certainly have no keys */ /* If the root level is empty, we certainly have no keys */
...@@ -333,10 +333,10 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS) ...@@ -333,10 +333,10 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
int total = 2 * JB_ROOT_COUNT(jb); int total = 2 * JB_ROOT_COUNT(jb);
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
JsonbIteratorToken r;
PathHashStack tail; PathHashStack tail;
PathHashStack *stack; PathHashStack *stack;
int i = 0, int i = 0;
r;
Datum *entries; Datum *entries;
/* If the root level is empty, we certainly have no keys */ /* If the root level is empty, we certainly have no keys */
...@@ -429,7 +429,7 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS) ...@@ -429,7 +429,7 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
stack = parent; stack = parent;
break; break;
default: default:
elog(ERROR, "invalid JsonbIteratorNext rc: %d", r); elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
} }
} }
......
...@@ -254,8 +254,8 @@ jsonb_hash(PG_FUNCTION_ARGS) ...@@ -254,8 +254,8 @@ jsonb_hash(PG_FUNCTION_ARGS)
{ {
Jsonb *jb = PG_GETARG_JSONB(0); Jsonb *jb = PG_GETARG_JSONB(0);
JsonbIterator *it; JsonbIterator *it;
int32 r;
JsonbValue v; JsonbValue v;
JsonbIteratorToken r;
uint32 hash = 0; uint32 hash = 0;
if (JB_ROOT_COUNT(jb) == 0) if (JB_ROOT_COUNT(jb) == 0)
...@@ -283,7 +283,7 @@ jsonb_hash(PG_FUNCTION_ARGS) ...@@ -283,7 +283,7 @@ jsonb_hash(PG_FUNCTION_ARGS)
case WJB_END_OBJECT: case WJB_END_OBJECT:
break; break;
default: default:
elog(ERROR, "invalid JsonbIteratorNext rc: %d", r); elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
} }
} }
......
...@@ -187,7 +187,7 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b) ...@@ -187,7 +187,7 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
{ {
JsonbValue va, JsonbValue va,
vb; vb;
int ra, JsonbIteratorToken ra,
rb; rb;
ra = JsonbIteratorNext(&ita, &va, false); ra = JsonbIteratorNext(&ita, &va, false);
...@@ -961,10 +961,10 @@ freeAndGetParent(JsonbIterator *it) ...@@ -961,10 +961,10 @@ freeAndGetParent(JsonbIterator *it)
bool bool
JsonbDeepContains(JsonbIterator **val, JsonbIterator **mContained) JsonbDeepContains(JsonbIterator **val, JsonbIterator **mContained)
{ {
uint32 rval,
rcont;
JsonbValue vval, JsonbValue vval,
vcontained; vcontained;
JsonbIteratorToken rval,
rcont;
/* /*
* Guard against stack overflow due to overly complex Jsonb. * Guard against stack overflow due to overly complex Jsonb.
......
...@@ -288,7 +288,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS) ...@@ -288,7 +288,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
bool skipNested = false; bool skipNested = false;
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
int r; JsonbIteratorToken r;
if (JB_ROOT_IS_SCALAR(jb)) if (JB_ROOT_IS_SCALAR(jb))
ereport(ERROR, ereport(ERROR,
...@@ -1283,7 +1283,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) ...@@ -1283,7 +1283,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
if (jbvp->type == jbvBinary) if (jbvp->type == jbvBinary)
{ {
JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data); JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data);
int r; JsonbIteratorToken r;
r = JsonbIteratorNext(&it, &tv, true); r = JsonbIteratorNext(&it, &tv, true);
container = (JsonbContainer *) jbvp->val.binary.data; container = (JsonbContainer *) jbvp->val.binary.data;
...@@ -1456,7 +1456,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text) ...@@ -1456,7 +1456,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
bool skipNested = false; bool skipNested = false;
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
int r; JsonbIteratorToken r;
if (!JB_ROOT_IS_OBJECT(jb)) if (!JB_ROOT_IS_OBJECT(jb))
ereport(ERROR, ereport(ERROR,
...@@ -1775,7 +1775,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, ...@@ -1775,7 +1775,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
bool skipNested = false; bool skipNested = false;
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
int r; JsonbIteratorToken r;
if (JB_ROOT_IS_SCALAR(jb)) if (JB_ROOT_IS_SCALAR(jb))
ereport(ERROR, ereport(ERROR,
...@@ -2792,7 +2792,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, ...@@ -2792,7 +2792,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
bool skipNested = false; bool skipNested = false;
int r; JsonbIteratorToken r;
Assert(jtype == JSONBOID); Assert(jtype == JSONBOID);
...@@ -3230,9 +3230,9 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS) ...@@ -3230,9 +3230,9 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
JsonbIterator *it; JsonbIterator *it;
JsonbParseState *parseState = NULL; JsonbParseState *parseState = NULL;
JsonbValue *res = NULL; JsonbValue *res = NULL;
int type;
JsonbValue v, JsonbValue v,
k; k;
JsonbIteratorToken type;
bool last_was_key = false; bool last_was_key = false;
if (JB_ROOT_IS_SCALAR(jb)) if (JB_ROOT_IS_SCALAR(jb))
...@@ -3290,8 +3290,8 @@ addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb) ...@@ -3290,8 +3290,8 @@ addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
{ {
JsonbIterator *it; JsonbIterator *it;
JsonbValue *o = &(*jbps)->contVal; JsonbValue *o = &(*jbps)->contVal;
int type;
JsonbValue v; JsonbValue v;
JsonbIteratorToken type;
it = JsonbIteratorInit(&jb->root); it = JsonbIteratorInit(&jb->root);
...@@ -3398,10 +3398,10 @@ jsonb_delete(PG_FUNCTION_ARGS) ...@@ -3398,10 +3398,10 @@ jsonb_delete(PG_FUNCTION_ARGS)
int keylen = VARSIZE_ANY_EXHDR(key); int keylen = VARSIZE_ANY_EXHDR(key);
JsonbParseState *state = NULL; JsonbParseState *state = NULL;
JsonbIterator *it; JsonbIterator *it;
uint32 r;
JsonbValue v, JsonbValue v,
*res = NULL; *res = NULL;
bool skipNested = false; bool skipNested = false;
JsonbIteratorToken r;
if (JB_ROOT_IS_SCALAR(in)) if (JB_ROOT_IS_SCALAR(in))
ereport(ERROR, ereport(ERROR,
...@@ -3450,11 +3450,11 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) ...@@ -3450,11 +3450,11 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
int idx = PG_GETARG_INT32(1); int idx = PG_GETARG_INT32(1);
JsonbParseState *state = NULL; JsonbParseState *state = NULL;
JsonbIterator *it; JsonbIterator *it;
uint32 r, uint32 i = 0,
i = 0,
n; n;
JsonbValue v, JsonbValue v,
*res = NULL; *res = NULL;
JsonbIteratorToken r;
if (JB_ROOT_IS_SCALAR(in)) if (JB_ROOT_IS_SCALAR(in))
ereport(ERROR, ereport(ERROR,
...@@ -3606,13 +3606,13 @@ static JsonbValue * ...@@ -3606,13 +3606,13 @@ static JsonbValue *
IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
JsonbParseState **state) JsonbParseState **state)
{ {
uint32 r1,
r2,
rk1,
rk2;
JsonbValue v1, JsonbValue v1,
v2, v2,
*res = NULL; *res = NULL;
JsonbIteratorToken r1,
r2,
rk1,
rk2;
r1 = rk1 = JsonbIteratorNext(it1, &v1, false); r1 = rk1 = JsonbIteratorNext(it1, &v1, false);
r2 = rk2 = JsonbIteratorNext(it2, &v2, false); r2 = rk2 = JsonbIteratorNext(it2, &v2, false);
...@@ -3721,8 +3721,8 @@ setPath(JsonbIterator **it, Datum *path_elems, ...@@ -3721,8 +3721,8 @@ setPath(JsonbIterator **it, Datum *path_elems,
JsonbParseState **st, int level, Jsonb *newval, bool create) JsonbParseState **st, int level, Jsonb *newval, bool create)
{ {
JsonbValue v; JsonbValue v;
JsonbIteratorToken r;
JsonbValue *res = NULL; JsonbValue *res = NULL;
int r;
check_stack_depth(); check_stack_depth();
...@@ -3793,7 +3793,7 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls, ...@@ -3793,7 +3793,7 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
for (i = 0; i < npairs; i++) for (i = 0; i < npairs; i++)
{ {
int r = JsonbIteratorNext(it, &k, true); JsonbIteratorToken r = JsonbIteratorNext(it, &k, true);
Assert(r == WJB_KEY); Assert(r == WJB_KEY);
...@@ -3914,7 +3914,7 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls, ...@@ -3914,7 +3914,7 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
/* iterate over the array elements */ /* iterate over the array elements */
for (i = 0; i < nelems; i++) for (i = 0; i < nelems; i++)
{ {
int r; JsonbIteratorToken r;
if (i == idx && level < path_len) if (i == idx && level < path_len)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment