37 #define JB_PATH_NOOP 0x0000
38 #define JB_PATH_CREATE 0x0001
39 #define JB_PATH_DELETE 0x0002
40 #define JB_PATH_INSERT_BEFORE 0x0004
41 #define JB_PATH_INSERT_AFTER 0x0008
42 #define JB_PATH_CREATE_OR_INSERT \
43 (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE)
64 bool normalize_results);
100 bool have_record_arg);
128 bool have_record_arg);
140 bool *path_nulls,
int path_len,
297 bool skipNested =
false;
304 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
305 errmsg(
"cannot call %s on a scalar",
306 "jsonb_object_keys")));
309 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
310 errmsg(
"cannot call %s on an array",
311 "jsonb_object_keys")));
333 cstr =
palloc(v.
val.string.len + 1 *
sizeof(
char));
334 memcpy(cstr, v.
val.string.val, v.
val.string.len);
335 cstr[v.
val.string.len] =
'\0';
440 _state->
result = (
char **)
456 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
457 errmsg(
"cannot call %s on an array",
458 "json_object_keys")));
469 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
470 errmsg(
"cannot call %s on a scalar",
471 "json_object_keys")));
614 if (-element > nelements)
617 element += nelements;
657 if (-element > nelements)
660 element += nelements;
740 &pathtext, &pathnulls, &npath);
742 tpath =
palloc(npath *
sizeof(
char *));
743 ipath =
palloc(npath *
sizeof(
int));
745 for (i = 0; i < npath; i++)
755 if (*tpath[i] !=
'\0')
761 ind = strtol(tpath[i], &endptr, 10);
763 ipath[
i] = (int) ind;
771 result =
get_worker(json, tpath, ipath, npath, as_text);
801 bool normalize_results)
812 state->
npath = npath;
858 if (lex_level == 0 && _state->
npath == 0)
875 if (lex_level == 0 && _state->
npath == 0)
889 bool get_next =
false;
892 if (lex_level <= _state->npath &&
893 _state->
pathok[lex_level - 1] &&
896 strcmp(fname, _state->
path_names[lex_level - 1]) == 0)
898 if (lex_level < _state->npath)
901 _state->
pathok[lex_level] =
true;
934 bool get_last =
false;
938 if (lex_level <= _state->npath &&
939 _state->
pathok[lex_level - 1] &&
942 strcmp(fname, _state->
path_names[lex_level - 1]) == 0)
944 if (lex_level < _state->npath)
947 _state->
pathok[lex_level] =
false;
985 if (lex_level < _state->npath)
1001 else if (lex_level == 0 && _state->
npath == 0)
1018 if (lex_level == 0 && _state->
npath == 0)
1032 bool get_next =
false;
1036 if (lex_level <= _state->npath)
1039 if (lex_level <= _state->npath &&
1040 _state->
pathok[lex_level - 1] &&
1044 if (lex_level < _state->npath)
1047 _state->
pathok[lex_level] =
true;
1078 bool get_last =
false;
1082 if (lex_level <= _state->npath &&
1083 _state->
pathok[lex_level - 1] &&
1087 if (lex_level < _state->npath)
1090 _state->
pathok[lex_level] =
false;
1123 if (lex_level == 0 && _state->
npath == 0)
1179 bool have_object =
false,
1196 &pathtext, &pathnulls, &npath);
1199 container = &jb->
root;
1221 if (npath <= 0 && jbvp ==
NULL)
1236 for (i = 0; i < npath; i++)
1245 else if (have_array)
1253 lindex = strtol(indextext, &endptr, 10);
1254 if (endptr == indextext || *endptr !=
'\0' || errno != 0 ||
1255 lindex > INT_MAX || lindex < INT_MIN)
1273 if (-lindex > nelements)
1276 index = nelements + lindex;
1289 else if (i == npath - 1)
1292 if (jbvp->
type == jbvBinary)
1304 have_object = jbvp->
type == jbvObject;
1305 have_array = jbvp->
type == jbvArray;
1312 if (jbvp->
type == jbvString)
1314 jbvp->
val.string.len));
1315 if (jbvp->
type == jbvNull)
1372 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1373 errmsg(
"cannot get array length of a scalar")));
1376 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1377 errmsg(
"cannot get array length of a non-array")));
1395 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1396 errmsg(
"cannot get array length of a non-array")));
1407 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1408 errmsg(
"cannot get array length of a scalar")));
1465 bool skipNested =
false;
1472 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1473 errmsg(
"cannot call %s on a non-object",
1482 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1483 errmsg(
"set-valued function called in context that "
1484 "cannot accept a set")));
1490 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1491 errmsg(
"function returning record called in context "
1492 "that cannot accept type record")));
1505 "jsonb_each temporary cxt",
1521 bool nulls[2] = {
false,
false};
1538 if (v.
type == jbvNull)
1548 if (v.
type == jbvString)
1614 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1615 errmsg(
"set-valued function called in context that "
1616 "cannot accept a set")));
1643 "json_each temporary cxt",
1688 bool nulls[2] = {
false,
false};
1702 values[1] = (
Datum) 0;
1733 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1734 errmsg(
"cannot deconstruct an array as an object")));
1745 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1746 errmsg(
"cannot deconstruct a scalar")));
1784 bool skipNested =
false;
1791 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1792 errmsg(
"cannot extract elements from a scalar")));
1795 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1796 errmsg(
"cannot extract elements from an object")));
1804 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1805 errmsg(
"set-valued function called in context that "
1806 "cannot accept a set")));
1824 "jsonb_array_elements temporary cxt",
1839 bool nulls[1] = {
false};
1852 if (v.
type == jbvNull)
1862 if (v.
type == jbvString)
1933 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1934 errmsg(
"set-valued function called in context that "
1935 "cannot accept a set")));
1964 "json_array_elements temporary cxt",
2008 bool nulls[1] = {
false};
2051 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2052 errmsg(
"cannot call %s on a non-array",
2064 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2065 errmsg(
"cannot call %s on a scalar",
2111 bool have_record_arg)
2113 int json_arg_num = have_record_arg ? 1 : 0;
2120 int32 tupTypmod = -1;
2132 if (have_record_arg)
2138 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2139 errmsg(
"first argument of %s must be a row type",
2177 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2178 errmsg(
"function returning record called in context "
2179 "that cannot accept type record"),
2180 errhint(
"Try calling the function in the FROM clause "
2181 "using a column definition list.")));
2215 ncolumns = tupdesc->
natts;
2231 if (my_extra ==
NULL ||
2245 if (have_record_arg && (my_extra->
record_type != tupType ||
2257 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
2266 for (i = 0; i < ncolumns; ++
i)
2273 for (i = 0; i < ncolumns; ++
i)
2276 Oid column_type = tupdesc->
attrs[
i]->atttypid;
2281 if (tupdesc->
attrs[i]->attisdropped)
2334 tupdesc->
attrs[i]->atttypmod);
2348 if (v->
type == jbvString)
2350 else if (v->
type == jbvBool)
2352 else if (v->
type == jbvNumeric)
2355 else if (v->
type == jbvBinary)
2363 tupdesc->
attrs[i]->atttypmod);
2392 memset(&ctl, 0,
sizeof(ctl));
2470 hashentry->
isnull = isnull;
2474 char *
val =
palloc((len + 1) *
sizeof(
char));
2494 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2505 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2560 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
2577 for (i = 0; i < ncolumns; ++
i)
2584 for (i = 0; i < ncolumns; ++
i)
2587 Oid column_type = tupdesc->
attrs[
i]->atttypid;
2592 if (tupdesc->
attrs[i]->attisdropped)
2611 if (v ==
NULL && rec)
2626 if (v ==
NULL || v->
type == jbvNull)
2634 tupdesc->
attrs[i]->atttypmod);
2641 if (v->
type == jbvString)
2643 else if (v->
type == jbvBool)
2645 else if (v->
type == jbvNumeric)
2648 else if (v->
type == jbvBinary)
2655 tupdesc->
attrs[i]->atttypmod);
2670 bool have_record_arg)
2672 int json_arg_num = have_record_arg ? 1 : 0;
2684 if (have_record_arg)
2690 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2691 errmsg(
"first argument of %s must be a row type",
2701 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2702 errmsg(
"set-valued function called in context that "
2703 "cannot accept a set")));
2714 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2715 errmsg(
"function returning record called in context "
2716 "that cannot accept type record")));
2729 ncolumns = tupdesc->
natts;
2736 if (my_extra ==
NULL ||
2803 bool skipNested =
false;
2810 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2811 errmsg(
"cannot call %s on a non-array",
2826 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2827 errmsg(
"argument of %s must be an array of objects",
2850 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2851 errmsg(
"cannot call %s on an object",
2859 memset(&ctl, 0,
sizeof(ctl));
2890 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
2907 for (i = 0; i < ncolumns; ++
i)
2914 for (i = 0; i < ncolumns; ++
i)
2917 Oid column_type = tupdesc->
attrs[
i]->atttypid;
2921 if (tupdesc->
attrs[i]->attisdropped)
2939 if (hashentry ==
NULL && rec)
2962 tupdesc->
attrs[i]->atttypmod);
2967 value = hashentry->
val;
2971 tupdesc->
attrs[i]->atttypmod);
2993 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2994 errmsg(
"argument of %s must be an array of objects",
3011 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3012 errmsg(
"cannot call %s on a scalar",
3068 hashentry->
isnull = isnull;
3072 char *
val =
palloc((len + 1) *
sizeof(
char));
3090 char *key,
uint32 keylen)
3095 k.
val.string.val = key;
3096 k.
val.string.len = keylen;
3245 bool last_was_key =
false;
3260 last_was_key =
true;
3267 last_was_key =
false;
3323 elog(
ERROR,
"unexpected parent of nested structure");
3412 bool skipNested =
false;
3417 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3418 errmsg(
"cannot delete from scalar")));
3430 (v.
type == jbvString && keylen == v.
val.string.len &&
3431 memcmp(keyptr, v.
val.string.val, keylen) == 0))
3470 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3471 errmsg(
"cannot delete from scalar")));
3475 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3476 errmsg(
"cannot delete from object using integer index")));
3485 n = v.
val.array.nElems;
3536 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3537 errmsg(
"wrong number of array subscripts")));
3541 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3542 errmsg(
"cannot set path in scalar")));
3548 &path_elems, &path_nulls, &path_len);
3555 res =
setPath(&it, path_elems, path_nulls, path_len, &st,
3581 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3582 errmsg(
"wrong number of array subscripts")));
3586 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3587 errmsg(
"cannot delete path in scalar")));
3593 &path_elems, &path_nulls, &path_len);
3600 res =
setPath(&it, path_elems, path_nulls, path_len, &st,
3628 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3629 errmsg(
"wrong number of array subscripts")));
3633 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3634 errmsg(
"cannot set path in scalar")));
3637 &path_elems, &path_nulls, &path_len);
3644 res =
setPath(&it, path_elems, path_nulls, path_len, &st, 0, newval,
3756 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3757 errmsg(
"invalid concatenation of jsonb objects")));
3779 bool *path_nulls,
int path_len,
3788 if (path_nulls[level])
3790 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
3791 errmsg(
"path element at position %d is null",
3800 setPathArray(it, path_elems, path_nulls, path_len, st, level,
3801 newval, v.
val.array.nElems, op_type);
3808 setPathObject(it, path_elems, path_nulls, path_len, st, level,
3809 newval, v.
val.object.nPairs, op_type);
3819 elog(
ERROR,
"unrecognized iterator result: %d", (
int) r);
3840 if (level >= path_len || path_nulls[level])
3845 (level == path_len - 1))
3849 newkey.
type = jbvString;
3857 for (i = 0; i < npairs; i++)
3866 k.
val.string.len) == 0)
3868 if (level == path_len - 1)
3876 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3877 errmsg(
"cannot replace existing key"),
3878 errhint(
"Try using the function jsonb_set "
3879 "to replace key value.")));
3892 setPath(it, path_elems, path_nulls, path_len,
3893 st, level + 1, newval, op_type);
3898 if ((op_type & JB_PATH_CREATE_OR_INSERT) && !done &&
3899 level == path_len - 1 && i == npairs - 1)
3903 newkey.
type = jbvString;
3916 int walking_level = 1;
3918 while (walking_level != 0)
3948 if (level < path_len && !path_nulls[level])
3955 lindex = strtol(c, &badp, 10);
3956 if (errno != 0 || badp == c || *badp !=
'\0' || lindex > INT_MAX ||
3959 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
3960 errmsg(
"path element at position %d is not an integer: \"%s\"",
3975 if (idx > 0 && idx > nelems)
3984 if ((idx == INT_MIN || nelems == 0) && (level == path_len - 1) &&
3993 for (i = 0; i < nelems; i++)
3997 if (i == idx && level < path_len)
3999 if (level == path_len - 1)
4020 (
void)
setPath(it, path_elems, path_nulls, path_len,
4021 st, level + 1, newval, op_type);
4031 int walking_level = 1;
4033 while (walking_level != 0)
4046 if (op_type & JB_PATH_CREATE_OR_INSERT && !done &&
4047 level == path_len - 1 && i == nelems - 1)
json_struct_action array_end
static void get_array_end(void *state)
static Datum elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
#define PG_RETURN_POINTER(x)
static void populate_recordset_object_start(void *state)
Datum jsonb_array_elements(PG_FUNCTION_ARGS)
struct JhashState JHashState
#define PG_GETARG_INT32(n)
Datum jsonb_array_length(PG_FUNCTION_ARGS)
void hash_destroy(HTAB *hashp)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
#define IsA(nodeptr, _type_)
Tuplestorestate * tuple_store
void MemoryContextDelete(MemoryContext context)
#define JB_ROOT_IS_OBJECT(jbp_)
static void each_object_field_start(void *state, char *fname, bool isnull)
const char * function_name
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static void setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, Jsonb *newval, uint32 nelems, int op_type)
int errhint(const char *fmt,...)
char * pnstrdup(const char *in, Size len)
Jsonb * JsonbValueToJsonb(JsonbValue *val)
static void sn_object_start(void *state)
struct RecordIOData RecordIOData
static Datum populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, bool have_record_arg)
void escape_json(StringInfo buf, const char *str)
static void get_array_element_start(void *state, bool isnull)
static void elements_object_start(void *state)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
struct ColumnIOData ColumnIOData
json_struct_action object_end
Datum json_extract_path_text(PG_FUNCTION_ARGS)
static void sn_array_element_start(void *state, bool isnull)
Datum jsonb_object_keys(PG_FUNCTION_ARGS)
#define JB_PATH_CREATE_OR_INSERT
#define SRF_IS_FIRSTCALL()
static void get_object_start(void *state)
#define PointerGetDatum(X)
static JsonbValue * setPath(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, Jsonb *newval, int op_type)
char * pstrdup(const char *in)
static void sn_object_field_start(void *state, char *fname, bool isnull)
Datum json_each_text(PG_FUNCTION_ARGS)
StringInfo makeStringInfo(void)
const char * function_name
Form_pg_attribute * attrs
Datum numeric_out(PG_FUNCTION_ARGS)
json_struct_action object_start
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define PG_RETURN_INT32(x)
char * prev_token_terminator
#define JB_ROOT_COUNT(jbp_)
static void okeys_array_start(void *state)
static JsonbValue * findJsonbValueFromContainerLen(JsonbContainer *container, uint32 flags, char *key, uint32 keylen)
static void hash_object_field_end(void *state, char *fname, bool isnull)
int errcode(int sqlerrcode)
Datum json_strip_nulls(PG_FUNCTION_ARGS)
json_scalar_action scalar
#define MemSet(start, val, len)
Datum jsonb_strip_nulls(PG_FUNCTION_ARGS)
static void populate_recordset_scalar(void *state, char *token, JsonTokenType tokentype)
Datum idx(PG_FUNCTION_ARGS)
long hash_get_num_entries(HTAB *hashp)
void MemoryContextReset(MemoryContext context)
static void each_array_start(void *state)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_BOOL(n)
struct PopulateRecordsetState PopulateRecordsetState
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
#define JB_PATH_INSERT_BEFORE
#define JB_ROOT_IS_SCALAR(jbp_)
#define PG_GETARG_HEAPTUPLEHEADER(n)
struct ElementsState ElementsState
static void get_object_field_end(void *state, char *fname, bool isnull)
#define SRF_PERCALL_SETUP()
Datum jsonb_populate_recordset(PG_FUNCTION_ARGS)
#define ALLOCSET_DEFAULT_MINSIZE
char * JsonbToCStringIndent(StringInfo out, JsonbContainer *in, int estimated_len)
Datum json_array_element_text(PG_FUNCTION_ARGS)
#define PG_GETARG_TEXT_PP(n)
static void get_object_end(void *state)
struct StripnullState StripnullState
static void each_scalar(void *state, char *token, JsonTokenType tokentype)
#define HeapTupleHeaderGetTypMod(tup)
#define SRF_RETURN_NEXT(_funcctx, _result)
static void alen_scalar(void *state, char *token, JsonTokenType tokentype)
#define JB_PATH_INSERT_AFTER
JsonbValue * pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq, JsonbValue *jbval)
#define PG_GETARG_ARRAYTYPE_P(n)
#define appendStringInfoCharMacro(str, ch)
JsonLexContext * makeJsonLexContext(text *json, bool need_escapes)
void pfree(void *pointer)
Datum jsonb_array_elements_text(PG_FUNCTION_ARGS)
#define DatumGetCString(X)
#define PG_RETURN_JSONB(x)
Datum json_array_element(PG_FUNCTION_ARGS)
static void sn_array_start(void *state)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define JB_ROOT_IS_ARRAY(jbp_)
Datum jsonb_to_record(PG_FUNCTION_ARGS)
static Datum get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
void pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
static void populate_recordset_object_end(void *state)
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
void appendStringInfoString(StringInfo str, const char *s)
Datum jsonb_array_element_text(PG_FUNCTION_ARGS)
Datum json_array_elements(PG_FUNCTION_ARGS)
text * cstring_to_text_with_len(const char *s, int len)
Datum jsonb_object_field(PG_FUNCTION_ARGS)
void check_stack_depth(void)
Datum jsonb_populate_record(PG_FUNCTION_ARGS)
int json_count_array_elements(JsonLexContext *lex)
static void sn_object_end(void *state)
Datum jsonb_each_text(PG_FUNCTION_ARGS)
MemoryContext CurrentMemoryContext
Datum json_to_record(PG_FUNCTION_ARGS)
static void okeys_object_field_start(void *state, char *fname, bool isnull)
bool type_is_rowtype(Oid typid)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
#define ereport(elevel, rest)
json_ofield_action object_field_end
static void get_array_element_end(void *state, bool isnull)
static void elements_array_element_start(void *state, bool isnull)
static void hash_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_concat(PG_FUNCTION_ARGS)
Datum jsonb_array_element(PG_FUNCTION_ARGS)
ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER]
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
static void populate_recordset_object_field_end(void *state, char *fname, bool isnull)
static void get_scalar(void *state, char *token, JsonTokenType tokentype)
struct EachState EachState
#define TextDatumGetCString(d)
Datum jsonb_delete_path(PG_FUNCTION_ARGS)
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
static void elements_array_element_end(void *state, bool isnull)
void * palloc0(Size size)
static void elements_scalar(void *state, char *token, JsonTokenType tokentype)
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
#define PG_RETURN_DATUM(x)
static void get_array_start(void *state)
Datum json_object_field(PG_FUNCTION_ARGS)
json_aelem_action array_element_start
static void sn_scalar(void *state, char *token, JsonTokenType tokentype)
Tuplestorestate * tuple_store
#define HeapTupleHeaderGetTypeId(tup)
static void make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *state)
struct OkeysState OkeysState
Datum jsonb_each(PG_FUNCTION_ARGS)
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
static Datum get_path_all(FunctionCallInfo fcinfo, bool as_text)
static text * get_worker(text *json, char **tpath, int *ipath, int npath, bool normalize_results)
#define PG_RETURN_TEXT_P(x)
Datum json_object_field_text(PG_FUNCTION_ARGS)
SetFunctionReturnMode returnMode
Datum json_array_elements_text(PG_FUNCTION_ARGS)
text * cstring_to_text(const char *s)
JsonbValue * getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
Datum jsonb_object_field_text(PG_FUNCTION_ARGS)
#define Assert(condition)
Datum json_to_recordset(PG_FUNCTION_ARGS)
static Datum elements_worker(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
static Datum populate_record_worker(FunctionCallInfo fcinfo, const char *funcname, bool have_record_arg)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
json_struct_action array_start
Datum json_populate_record(PG_FUNCTION_ARGS)
MemoryContext multi_call_memory_ctx
char * JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
static void okeys_scalar(void *state, char *token, JsonTokenType tokentype)
Datum json_array_length(PG_FUNCTION_ARGS)
#define HeapTupleGetDatum(tuple)
MemoryContext ecxt_per_query_memory
void * repalloc(void *pointer, Size size)
struct JsonHashEntry JsonHashEntry
struct AlenState AlenState
Datum json_extract_path(PG_FUNCTION_ARGS)
Tuplestorestate * setResult
Tuplestorestate * tuple_store
Datum jsonb_extract_path_text(PG_FUNCTION_ARGS)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
static Datum values[MAXATTR]
char * text_to_cstring(const text *t)
#define PG_GETARG_JSONB(x)
#define ItemPointerSetInvalid(pointer)
Datum json_each(PG_FUNCTION_ARGS)
#define VARSIZE_ANY_EXHDR(PTR)
int errmsg(const char *fmt,...)
#define PG_GETARG_TEXT_P(n)
Datum jsonb_pretty(PG_FUNCTION_ARGS)
Datum jsonb_delete(PG_FUNCTION_ARGS)
void * MemoryContextAlloc(MemoryContext context, Size size)
Datum jsonb_to_recordset(PG_FUNCTION_ARGS)
Datum jsonb_delete_idx(PG_FUNCTION_ARGS)
#define ALLOCSET_DEFAULT_INITSIZE
static JsonbValue * IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, JsonbParseState **state)
static celt element(struct vars *v, const chr *startp, const chr *endp)
static void get_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_set(PG_FUNCTION_ARGS)
#define CStringGetTextDatum(s)
JsonbValue * findJsonbValueFromContainer(JsonbContainer *container, uint32 flags, JsonbValue *key)
static void alen_object_start(void *state)
static Datum each_worker(FunctionCallInfo fcinfo, bool as_text)
#define ALLOCSET_DEFAULT_MAXSIZE
static void hash_scalar(void *state, char *token, JsonTokenType tokentype)
json_ofield_action object_field_start
static void alen_array_element_start(void *state, bool isnull)
Datum jsonb_insert(PG_FUNCTION_ARGS)
Datum json_populate_recordset(PG_FUNCTION_ARGS)
static void sn_array_end(void *state)
static void populate_recordset_array_element_start(void *state, bool isnull)
static HTAB * get_json_object_as_hash(text *json, const char *funcname)
#define ReleaseTupleDesc(tupdesc)
bool array_contains_nulls(ArrayType *array)
Datum jsonb_extract_path(PG_FUNCTION_ARGS)
Datum json_object_keys(PG_FUNCTION_ARGS)
enum JsonbValue::@70 type
static void setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, Jsonb *newval, uint32 npairs, int op_type)
static void each_object_field_end(void *state, char *fname, bool isnull)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
json_aelem_action array_element_end
static void addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
#define offsetof(type, field)
static void populate_recordset_object_field_start(void *state, char *fname, bool isnull)
#define SRF_RETURN_DONE(_funcctx)
static Datum each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
#define HeapTupleHeaderGetDatumLength(tup)
static void populate_recordset_array_start(void *state)
static void hash_array_start(void *state)
#define SRF_FIRSTCALL_INIT()
const char * function_name