Commit 654809e7 authored by Alvaro Herrera's avatar Alvaro Herrera

Fix a couple of trivial issues in jsonb.c

Typo "aggreagate" appeared three times, and the return value of function
JsonbIteratorNext() was being assigned to an int variable in a bunch of
places.
parent 3f190f67
...@@ -424,7 +424,7 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len) ...@@ -424,7 +424,7 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
{ {
bool first = true; bool first = true;
JsonbIterator *it; JsonbIterator *it;
int type = 0; JsonbIteratorToken type;
JsonbValue v; JsonbValue v;
int level = 0; int level = 0;
bool redo_switch = false; bool redo_switch = false;
...@@ -506,7 +506,7 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len) ...@@ -506,7 +506,7 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
first = false; first = false;
break; break;
default: default:
elog(ERROR, "unknown flag of jsonb iterator"); elog(ERROR, "unknown jsonb iterator token type");
} }
} }
...@@ -824,7 +824,7 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, ...@@ -824,7 +824,7 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result,
case JSONBTYPE_JSONB: case JSONBTYPE_JSONB:
{ {
Jsonb *jsonb = DatumGetJsonb(val); Jsonb *jsonb = DatumGetJsonb(val);
int type; JsonbIteratorToken type;
JsonbIterator *it; JsonbIterator *it;
it = JsonbIteratorInit(&jsonb->root); it = JsonbIteratorInit(&jsonb->root);
...@@ -1519,7 +1519,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1519,7 +1519,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS)
JsonbIterator *it; JsonbIterator *it;
Jsonb *jbelem; Jsonb *jbelem;
JsonbValue v; JsonbValue v;
int type; JsonbIteratorToken type;
if (val_type == InvalidOid) if (val_type == InvalidOid)
ereport(ERROR, ereport(ERROR,
...@@ -1591,7 +1591,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1591,7 +1591,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS)
case WJB_VALUE: case WJB_VALUE:
if (v.type == jbvString) if (v.type == jbvString)
{ {
/* copy string values in the aggreagate context */ /* copy string values in the aggregate context */
char *buf = palloc(v.val.string.len + 1);; char *buf = palloc(v.val.string.len + 1);;
snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val); snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val);
v.val.string.val = buf; v.val.string.val = buf;
...@@ -1607,6 +1607,8 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1607,6 +1607,8 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS)
result->res = pushJsonbValue(&result->parseState, result->res = pushJsonbValue(&result->parseState,
type, &v); type, &v);
break; break;
default:
elog(ERROR, "unknown jsonb iterator token type");
} }
} }
...@@ -1667,7 +1669,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1667,7 +1669,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
Jsonb *jbkey, Jsonb *jbkey,
*jbval; *jbval;
JsonbValue v; JsonbValue v;
int type; JsonbIteratorToken type;
if (!AggCheckCallContext(fcinfo, &aggcontext)) if (!AggCheckCallContext(fcinfo, &aggcontext))
{ {
...@@ -1750,7 +1752,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1750,7 +1752,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
case WJB_ELEM: case WJB_ELEM:
if (v.type == jbvString) if (v.type == jbvString)
{ {
/* copy string values in the aggreagate context */ /* copy string values in the aggregate context */
char *buf = palloc(v.val.string.len + 1);; char *buf = palloc(v.val.string.len + 1);;
snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val); snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val);
v.val.string.val = buf; v.val.string.val = buf;
...@@ -1808,7 +1810,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1808,7 +1810,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
case WJB_VALUE: case WJB_VALUE:
if (v.type == jbvString) if (v.type == jbvString)
{ {
/* copy string values in the aggreagate context */ /* copy string values in the aggregate context */
char *buf = palloc(v.val.string.len + 1);; char *buf = palloc(v.val.string.len + 1);;
snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val); snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val);
v.val.string.val = buf; v.val.string.val = buf;
...@@ -1825,6 +1827,8 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS) ...@@ -1825,6 +1827,8 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
single_scalar ? WJB_VALUE : type, single_scalar ? WJB_VALUE : type,
&v); &v);
break; break;
default:
elog(ERROR, "unknown jsonb iterator token type");
} }
} }
......
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