Skip to content

Commit be36d1d

Browse files
author
Nikita Glukhov
committed
Extract JsonValueFromCString()
1 parent e324ad7 commit be36d1d

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
@@ -230,15 +230,8 @@ jsonb_typeof(PG_FUNCTION_ARGS)
230230
PG_RETURN_TEXT_P(cstring_to_text(result));
231231
}
232232

233-
/*
234-
* jsonb_from_cstring
235-
*
236-
* Turns json string into a jsonb Datum.
237-
*
238-
* Uses the json parser (with hooks) to construct a jsonb.
239-
*/
240-
static inline Datum
241-
jsonb_from_cstring(char *json, int len, bool unique_keys)
233+
static JsonbValue *
234+
JsonValueFromCString(char *json, int len, bool unique_keys)
242235
{
243236
JsonLexContext *lex;
244237
JsonbInState state;
@@ -262,9 +255,21 @@ jsonb_from_cstring(char *json, int len, bool unique_keys)
262255
pg_parse_json_or_ereport(lex, &sem);
263256

264257
/* after parsing, the item member has the composed jsonb structure */
265-
PG_RETURN_JSONB_P(JsonbValueToJsonb(state.res));
258+
return state.res;
266259
}
267260

261+
/*
262+
* jsonb_from_cstring
263+
*
264+
* Turns json string into a jsonb Datum.
265+
*
266+
* Uses the json parser (with hooks) to construct a jsonb.
267+
*/
268+
static inline Datum
269+
jsonb_from_cstring(char *json, int len, bool unique_keys)
270+
{
271+
PG_RETURN_JSONB_P(JsonbValueToJsonb(JsonValueFromCString(json, len, unique_keys)));
272+
}
268273

269274
static void
270275
jsonb_in_object_start(void *pstate)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy