diff options
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r-- | src/backend/utils/adt/jsonfuncs.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 2423b737c9e..6b1ce9b3a9f 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -104,11 +104,12 @@ static void populate_recordset_array_element_start(void *state, bool isnull); /* worker function for populate_recordset and to_recordset */ static inline Datum populate_recordset_worker(FunctionCallInfo fcinfo, bool have_record_arg); + /* Worker that takes care of common setup for us */ static JsonbValue *findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, - uint32 flags, - char *key, - uint32 keylen); + uint32 flags, + char *key, + uint32 keylen); /* search type classification for json_get* functions */ typedef enum @@ -235,8 +236,8 @@ typedef struct PopulateRecordsetState } PopulateRecordsetState; /* Turn a jsonb object into a record */ -static void make_row_from_rec_and_jsonb(Jsonb * element, - PopulateRecordsetState *state); +static void make_row_from_rec_and_jsonb(Jsonb *element, + PopulateRecordsetState *state); /* * SQL function json_object_keys @@ -791,7 +792,7 @@ get_path_all(FunctionCallInfo fcinfo, bool as_text) result = get_worker(json, NULL, -1, tpath, ipath, npath, as_text); if (result != NULL) - PG_RETURN_TEXT_P(result); + PG_RETURN_TEXT_P(result); else /* null is NULL, regardless */ PG_RETURN_NULL(); @@ -1178,7 +1179,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) jbvp = findJsonbValueFromSuperHeaderLen(superHeader, JB_FOBJECT, VARDATA_ANY(pathtext[i]), - VARSIZE_ANY_EXHDR(pathtext[i])); + VARSIZE_ANY_EXHDR(pathtext[i])); } else if (have_array) { @@ -1209,8 +1210,8 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) if (jbvp->type == jbvBinary) { - JsonbIterator *it = JsonbIteratorInit(jbvp->val.binary.data); - int r; + JsonbIterator *it = JsonbIteratorInit(jbvp->val.binary.data); + int r; r = JsonbIteratorNext(&it, &tv, true); superHeader = (JsonbSuperHeader) jbvp->val.binary.data; @@ -1932,7 +1933,7 @@ elements_array_element_end(void *state, bool isnull) text *val; HeapTuple tuple; Datum values[1]; - bool nulls[1] = {false}; + bool nulls[1] = {false}; /* skip over nested objects */ if (_state->lex->lex_level != 1) @@ -2035,7 +2036,7 @@ json_to_record(PG_FUNCTION_ARGS) static inline Datum populate_record_worker(FunctionCallInfo fcinfo, bool have_record_arg) { - int json_arg_num = have_record_arg ? 1 : 0; + int json_arg_num = have_record_arg ? 1 : 0; Oid jtype = get_fn_expr_argtype(fcinfo->flinfo, json_arg_num); text *json; Jsonb *jb = NULL; @@ -2060,7 +2061,7 @@ populate_record_worker(FunctionCallInfo fcinfo, bool have_record_arg) if (have_record_arg) { - Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); if (!type_is_rowtype(argtype)) ereport(ERROR, @@ -2275,7 +2276,7 @@ populate_record_worker(FunctionCallInfo fcinfo, bool have_record_arg) s = pnstrdup((v->val.boolean) ? "t" : "f", 1); else if (v->type == jbvNumeric) s = DatumGetCString(DirectFunctionCall1(numeric_out, - PointerGetDatum(v->val.numeric))); + PointerGetDatum(v->val.numeric))); else if (!use_json_as_text) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -2476,7 +2477,7 @@ json_to_recordset(PG_FUNCTION_ARGS) } static void -make_row_from_rec_and_jsonb(Jsonb * element, PopulateRecordsetState *state) +make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *state) { Datum *values; bool *nulls; @@ -2575,7 +2576,7 @@ make_row_from_rec_and_jsonb(Jsonb * element, PopulateRecordsetState *state) s = pnstrdup((v->val.boolean) ? "t" : "f", 1); else if (v->type == jbvNumeric) s = DatumGetCString(DirectFunctionCall1(numeric_out, - PointerGetDatum(v->val.numeric))); + PointerGetDatum(v->val.numeric))); else if (!state->use_json_as_text) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -2603,7 +2604,7 @@ make_row_from_rec_and_jsonb(Jsonb * element, PopulateRecordsetState *state) static inline Datum populate_recordset_worker(FunctionCallInfo fcinfo, bool have_record_arg) { - int json_arg_num = have_record_arg ? 1 : 0; + int json_arg_num = have_record_arg ? 1 : 0; Oid jtype = get_fn_expr_argtype(fcinfo->flinfo, json_arg_num); bool use_json_as_text; ReturnSetInfo *rsi; @@ -2620,7 +2621,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, bool have_record_arg) if (have_record_arg) { - Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); if (!type_is_rowtype(argtype)) ereport(ERROR, |