Skip to content

Commit 3d0a93f

Browse files
author
Nikita Glukhov
committed
Extract JsonValueFromCString()
1 parent 118dd93 commit 3d0a93f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/backend/utils/adt/jsonb.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,8 @@ jsonb_typeof(PG_FUNCTION_ARGS)
251251
PG_RETURN_TEXT_P(cstring_to_text(result));
252252
}
253253

254-
/*
255-
* jsonb_from_cstring
256-
*
257-
* Turns json string into a jsonb Datum.
258-
*
259-
* Uses the json parser (with hooks) to construct a jsonb.
260-
*/
261-
static inline Datum
262-
jsonb_from_cstring(char *json, int len)
254+
static JsonbValue *
255+
JsonValueFromCString(char *json, int len)
263256
{
264257
JsonLexContext *lex;
265258
JsonbInState state;
@@ -281,9 +274,21 @@ jsonb_from_cstring(char *json, int len)
281274
pg_parse_json_or_ereport(lex, &sem);
282275

283276
/* after parsing, the item member has the composed jsonb structure */
284-
PG_RETURN_JSONB_P(JsonbValueToJsonb(state.res));
277+
return state.res;
285278
}
286279

280+
/*
281+
* jsonb_from_cstring
282+
*
283+
* Turns json string into a jsonb Datum.
284+
*
285+
* Uses the json parser (with hooks) to construct a jsonb.
286+
*/
287+
static inline Datum
288+
jsonb_from_cstring(char *json, int len)
289+
{
290+
PG_RETURN_JSONB_P(JsonbValueToJsonb(JsonValueFromCString(json, len)));
291+
}
287292

288293
static void
289294
jsonb_in_object_start(void *pstate)

0 commit comments

Comments
 (0)