diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index d253ae66fa8..bf2d5968774 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -598,6 +598,16 @@ JsonbToCStringWorker(StringInfo out, JsonbContainer *in, int estimated_len, bool return out->data; } +void +jsonb_get_value(Datum val, bool is_null, JsonbValue *json, Oid val_type) +{ + JsonbInState state; + memset(&state, 0, sizeof(JsonbInState)); + + add_jsonb(val, is_null, &state, val_type, false); + *json = *(state.res); +} + static void add_indent(StringInfo out, bool indent, int level) { @@ -2083,4 +2093,4 @@ jsonb_float8(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(in, 0); PG_RETURN_DATUM(retValue); -} +} \ No newline at end of file diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h index 40851595881..24aae3976f8 100644 --- a/src/include/utils/jsonb.h +++ b/src/include/utils/jsonb.h @@ -415,4 +415,5 @@ extern Datum jsonb_set_element(Jsonb *jb, Datum *path, int path_len, JsonbValue *newval); extern Datum jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text); -#endif /* __JSONB_H__ */ +extern void jsonb_get_value(Datum val, bool is_null, JsonbValue *json, Oid val_type); +#endif /* __JSONB_H__ */ \ No newline at end of file