33#include "utils/fmgroids.h"
44#define JB_PATH_CREATE 0x0001
45#define JB_PATH_DELETE 0x0002
46#define JB_PATH_REPLACE 0x0004
47#define JB_PATH_INSERT_BEFORE 0x0008
48#define JB_PATH_INSERT_AFTER 0x0010
49#define JB_PATH_CREATE_OR_INSERT \
50 (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE)
51#define JB_PATH_FILL_GAPS 0x0020
52#define JB_PATH_CONSISTENT_POSITION 0x0040
319#define JsValueIsNull(jsv) \
321 (!(jsv)->val.json.str || (jsv)->val.json.type == JSON_TOKEN_NULL) : \
322 (!(jsv)->val.jsonb || (jsv)->val.jsonb->type == jbvNull))
324#define JsValueIsString(jsv) \
325 ((jsv)->is_json ? (jsv)->val.json.type == JSON_TOKEN_STRING \
326 : ((jsv)->val.jsonb && (jsv)->val.jsonb->type == jbvString))
328#define JsObjectIsEmpty(jso) \
330 ? hash_get_num_entries((jso)->val.json_hash) == 0 \
331 : ((jso)->val.jsonb_cont == NULL || \
332 JsonContainerSize((jso)->val.jsonb_cont) == 0))
334#define JsObjectFree(jso) \
336 if ((jso)->is_json) \
337 hash_destroy((jso)->val.json_hash); \
361 bool normalize_results);
430 bool is_json,
bool have_record_arg);
432 bool is_json,
bool have_record_arg,
451 bool *isnull,
Node *escontext,
bool omit_quotes);
457 bool omit_scalar_quotes);
474 Node *escontext,
bool omit_quotes);
480 bool *path_nulls,
int path_len,
576 bool skipNested =
false;
583 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
584 errmsg(
"cannot call %s on a scalar",
585 "jsonb_object_keys")));
588 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
589 errmsg(
"cannot call %s on an array",
590 "jsonb_object_keys")));
598 state->result_count = 0;
599 state->sent_count = 0;
612 cstr =
palloc(v.
val.string.len + 1 *
sizeof(
char));
613 memcpy(cstr, v.
val.string.val, v.
val.string.len);
614 cstr[v.
val.string.len] =
'\0';
628 char *nxt =
state->result[
state->sent_count++];
647 (
errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
648 errmsg(
"unsupported Unicode escape sequence"),
655 elog(
ERROR,
"JSON semantic action function did not provide error information");
659 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
660 errmsg(
"invalid input syntax for type %s",
"json"),
678 const char *context_start;
679 const char *context_end;
680 const char *line_start;
688 context_start = line_start;
690 Assert(context_end >= context_start);
693 while (context_end - context_start >= 50)
697 context_start +=
pg_mblen(context_start);
707 if (context_start - line_start <= 3)
708 context_start = line_start;
711 ctxtlen = context_end - context_start;
712 ctxt =
palloc(ctxtlen + 1);
713 memcpy(ctxt, context_start, ctxtlen);
714 ctxt[ctxtlen] =
'\0';
720 prefix = (context_start > line_start) ?
"..." :
"";
723 *context_end !=
'\n' && *context_end !=
'\r') ?
"..." :
"";
725 return errcontext(
"JSON data, line %d: %s%s%s",
750 state->result_size = 256;
751 state->result_count = 0;
752 state->sent_count = 0;
776 char *nxt =
state->result[
state->sent_count++];
797 _state->
result = (
char **)
815 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
816 errmsg(
"cannot call %s on an array",
817 "json_object_keys")));
830 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
831 errmsg(
"cannot call %s on a scalar",
832 "json_object_keys")));
852 result =
get_worker(json, &fnamestr, NULL, 1,
false);
890 result =
get_worker(json, &fnamestr, NULL, 1,
true);
1047 tpath =
palloc(npath *
sizeof(
char *));
1048 ipath =
palloc(npath *
sizeof(
int));
1050 for (
i = 0;
i < npath;
i++)
1060 if (*tpath[
i] !=
'\0')
1067 if (endptr == tpath[
i] || *endptr !=
'\0' || errno != 0)
1076 result =
get_worker(json, tpath, ipath, npath, as_text);
1106 bool normalize_results)
1116 state->normalize_results = normalize_results;
1117 state->npath = npath;
1118 state->path_names = tpath;
1119 state->path_indexes = ipath;
1121 state->array_cur_index =
palloc(
sizeof(
int) * npath);
1124 state->pathok[0] =
true;
1155 return state->tresult;
1164 if (lex_level == 0 && _state->
npath == 0)
1183 if (lex_level == 0 && _state->
npath == 0)
1199 bool get_next =
false;
1202 if (lex_level <= _state->npath &&
1203 _state->
pathok[lex_level - 1] &&
1206 strcmp(fname, _state->
path_names[lex_level - 1]) == 0)
1208 if (lex_level < _state->npath)
1211 _state->
pathok[lex_level] =
true;
1246 bool get_last =
false;
1250 if (lex_level <= _state->npath &&
1251 _state->
pathok[lex_level - 1] &&
1254 strcmp(fname, _state->
path_names[lex_level - 1]) == 0)
1256 if (lex_level < _state->npath)
1259 _state->
pathok[lex_level] =
false;
1299 if (lex_level < _state->npath)
1320 else if (lex_level == 0 && _state->
npath == 0)
1339 if (lex_level == 0 && _state->
npath == 0)
1355 bool get_next =
false;
1359 if (lex_level <= _state->npath)
1362 if (lex_level <= _state->npath &&
1363 _state->
pathok[lex_level - 1] &&
1367 if (lex_level < _state->npath)
1370 _state->
pathok[lex_level] =
true;
1403 bool get_last =
false;
1407 if (lex_level <= _state->npath &&
1408 _state->
pathok[lex_level - 1] &&
1412 if (lex_level < _state->npath)
1415 _state->
pathok[lex_level] =
false;
1450 if (lex_level == 0 && _state->
npath == 0)
1535 bool have_object =
false,
1561 if (npath <= 0 && jbvp == NULL)
1576 for (
i = 0;
i < npath;
i++)
1587 else if (have_array)
1595 lindex =
strtoint(indextext, &endptr, 10);
1596 if (endptr == indextext || *endptr !=
'\0' || errno != 0)
1617 if (lindex == INT_MIN || -lindex > nelements)
1623 index = nelements + lindex;
1640 else if (
i == npath - 1)
1645 container = jbvp->
val.binary.data;
1653 have_object =
false;
1684 bool *path_nulls =
palloc0(path_len *
sizeof(
bool));
1737 for (
int i = level + 1;
i < path_len;
i++)
1753 if (badp ==
c || *badp !=
'\0' || errno != 0)
1757 newkey.
val.string.val =
c;
1758 newkey.
val.string.len = strlen(
c);
1777 if (tpath[(path_len - level) - 1] ==
jbvArray)
1788 for (
int i = path_len - 1;
i > level;
i--)
1812 return v->
val.boolean ?
1883 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1884 errmsg(
"cannot get array length of a scalar")));
1887 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1888 errmsg(
"cannot get array length of a non-array")));
1906 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1907 errmsg(
"cannot get array length of a non-array")));
1920 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1921 errmsg(
"cannot get array length of a scalar")));
1979 bool skipNested =
false;
1986 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1987 errmsg(
"cannot call %s on a non-object",
1994 "jsonb_each temporary cxt",
2007 bool nulls[2] = {
false,
false};
2080 state->normalize_results = as_text;
2081 state->next_scalar =
false;
2084 "json_each temporary cxt",
2127 bool nulls[2] = {
false,
false};
2174 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2175 errmsg(
"cannot deconstruct an array as an object")));
2188 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2189 errmsg(
"cannot deconstruct a scalar")));
2226 bool skipNested =
false;
2233 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2234 errmsg(
"cannot extract elements from a scalar")));
2237 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2238 errmsg(
"cannot extract elements from an object")));
2245 "jsonb_array_elements temporary cxt",
2257 bool nulls[1] = {
false};
2333 state->normalize_results = as_text;
2334 state->next_scalar =
false;
2337 "json_array_elements temporary cxt",
2379 bool nulls[1] = {
false};
2424 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2425 errmsg(
"cannot call %s on a non-array",
2439 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2440 errmsg(
"cannot call %s on a scalar",
2481 false,
true, (
Node *) &escontext);
2490 false,
false, NULL);
2515 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2516 errmsg(
"expected JSON array"),
2520 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2521 errmsg(
"expected JSON array")));
2533 for (
i = 0;
i < ndim;
i++)
2538 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2539 errmsg(
"expected JSON array"),
2540 errhint(
"See the array element %s of key \"%s\".",
2544 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2545 errmsg(
"expected JSON array"),
2546 errhint(
"See the array element %s.",
2577 for (
i = 0;
i < ndims;
i++)
2591 int dim = ctx->
sizes[ndim];
2593 if (ctx->
dims[ndim] == -1)
2594 ctx->
dims[ndim] = dim;
2595 else if (ctx->
dims[ndim] != dim)
2597 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
2598 errmsg(
"malformed JSON array"),
2599 errdetail(
"Multidimensional arrays must have "
2600 "sub-arrays with matching dimensions.")));
2603 ctx->
sizes[ndim] = 0;
2607 ctx->
sizes[ndim - 1]++;
2620 bool element_isnull;
2637 ctx->
sizes[ndim - 1]++;
2647 int ndim =
state->lex->lex_level;
2649 if (
state->ctx->ndims <= 0)
2654 else if (ndim < state->ctx->ndims)
2671 int ndim =
state->lex->lex_level;
2673 if (ctx->
ndims <= 0)
2679 if (ndim < ctx->ndims)
2694 int ndim =
state->lex->lex_level;
2696 if (
state->ctx->ndims <= 0 || ndim ==
state->ctx->ndims)
2699 state->element_start =
state->lex->token_start;
2700 state->element_type =
state->lex->token_type;
2701 state->element_scalar = NULL;
2713 int ndim =
state->lex->lex_level;
2717 if (ndim == ctx->
ndims)
2730 else if (
state->element_scalar)
2739 state->element_start) *
sizeof(
char);
2756 int ndim =
state->lex->lex_level;
2758 if (ctx->
ndims <= 0)
2763 else if (ndim < ctx->ndims)
2771 if (ndim == ctx->
ndims)
2797 memset(&
sem, 0,
sizeof(
sem));
2858 if (ctx->
ndims <= 0 &&
2915 const char *colname,
2993 "populate_composite",
3014 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3016 ?
errmsg(
"cannot call %s on a scalar",
3017 "populate_composite")
3018 :
errmsg(
"cannot call %s on an array",
3019 "populate_composite")));
3059 const char *colname,
3087 defaultval, mcxt, &jso, escontext);
3104 if (typid != io->
base_typid && typid != RECORDOID)
3125 bool *isnull,
Node *escontext,
bool omit_quotes)
3129 const char *json = NULL;
3139 if ((typid == JSONOID || typid == JSONBOID) &&
3170 else if (typid == JSONBOID)
3196 jbv->
val.binary.len);
3198 elog(
ERROR,
"unrecognized jsonb type: %d", (
int) jbv->
type);
3218 const char *colname,
3234 jsv, isnull, escontext, omit_quotes);
3259 column->
typid = typid;
3264 elog(
ERROR,
"cache lookup failed for type %u", typid);
3268 if (
type->typtype == TYPTYPE_DOMAIN)
3275 int32 base_typmod = typmod;
3299 else if (
type->typtype == TYPTYPE_COMPOSITE || typid == RECORDOID)
3308 else if (IsTrueArrayType(
type))
3347 bool *isnull,
bool omit_quotes,
3353 jsv.
is_json = json_type == JSONOID;
3383 jbv.
val.string.len = strlen(
str);
3384 jbv.
val.string.val =
str;
3390 jbv.
val.binary.data = &jsonb->
root;
3400 escontext, omit_quotes);
3408 const char *colname,
3414 bool omit_scalar_quotes)
3448 isnull, escontext, omit_scalar_quotes);
3466 jsv, isnull, escontext, omit_scalar_quotes);
3469 elog(
ERROR,
"unrecognized type category '%c'", typcat);
3483 data->record_typmod = 0;
3484 data->ncolumns = ncolumns;
3505 return hashentry != NULL;
3530 int ncolumns = tupdesc->
natts;
3542 if (record == NULL ||
3558 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
3568 tuple.
t_data = defaultval;
3575 for (
i = 0;
i < ncolumns; ++
i)
3582 for (
i = 0;
i < ncolumns; ++
i)
3585 char *colname =
NameStr(att->attname);
3590 if (att->attisdropped)
3606 if (defaultval && !found)
3646 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3648 errmsg(
"first argument of %s must be a row type",
3670 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3672 errmsg(
"could not determine row type for result of %s",
3674 errhint(
"Provide a non-null record argument, "
3675 "or call the function in the FROM clause "
3676 "using a column definition list.")));
3699 bool is_json,
bool have_record_arg,
3702 int json_arg_num = have_record_arg ? 1 : 0;
3722 if (have_record_arg)
3729 if (!have_record_arg)
3739 if (cache->
argtype == RECORDOID)
3753 if (cache->
argtype == RECORDOID)
3789 jbv.
val.binary.data = &jb->
root;
3795 NULL, fnmcxt, rec, &jsv, &isnull,
3935 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3948 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4041 bool is_json,
bool have_record_arg)
4043 int json_arg_num = have_record_arg ? 1 : 0;
4054 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4055 errmsg(
"set-valued function called in context that cannot accept a set")));
4059 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4060 errmsg(
"materialize mode required, but it is not allowed in this context")));
4075 if (have_record_arg)
4082 if (!have_record_arg)
4092 if (cache->
argtype == RECORDOID)
4106 if (cache->
argtype == RECORDOID)
4134 state->cache = cache;
4168 bool skipNested =
false;
4173 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4174 errmsg(
"cannot call %s on a non-array",
4190 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4191 errmsg(
"argument of %s must be an array of objects",
4223 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4224 errmsg(
"cannot call %s on an object",
4274 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4275 errmsg(
"argument of %s must be an array of objects",
4295 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4296 errmsg(
"cannot call %s on a scalar",
4505 state->skip_next_null =
false;
4519 state->strval->len));
4535 bool last_was_key =
false;
4550 last_was_key =
true;
4557 last_was_key =
false;
4651 bool skipNested =
false;
4656 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4657 errmsg(
"cannot delete from scalar")));
4670 memcmp(keyptr, v.
val.string.val, keylen) == 0))
4705 bool skipNested =
false;
4710 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
4711 errmsg(
"wrong number of array subscripts")));
4715 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4716 errmsg(
"cannot delete from scalar")));
4737 for (
i = 0;
i < keys_len;
i++)
4748 if (keylen == v.
val.string.len &&
4749 memcmp(keyptr, v.
val.string.val, keylen) == 0)
4795 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4796 errmsg(
"cannot delete from scalar")));
4800 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4801 errmsg(
"cannot delete from object using integer index")));
4810 n = v.
val.array.nElems;
4863 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
4864 errmsg(
"wrong number of array subscripts")));
4868 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4869 errmsg(
"cannot set path in scalar")));
4881 res =
setPath(&it, path_elems, path_nulls, path_len, &st,
4909 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4910 errmsg(
"null_value_treatment must be \"delete_key\", \"return_target\", \"use_json_null\", or \"raise_exception\"")));
4919 if (strcmp(handle_val,
"raise_exception") == 0)
4922 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
4923 errmsg(
"JSON value must not be null"),
4924 errdetail(
"Exception was raised because null_value_treatment is \"raise_exception\"."),
4925 errhint(
"To avoid, either change the null_value_treatment argument or ensure that an SQL NULL is not passed.")));
4928 else if (strcmp(handle_val,
"use_json_null") == 0)
4934 fcinfo->args[2].value =
newval;
4935 fcinfo->args[2].isnull =
false;
4938 else if (strcmp(handle_val,
"delete_key") == 0)
4942 else if (strcmp(handle_val,
"return_target") == 0)
4951 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4952 errmsg(
"null_value_treatment must be \"delete_key\", \"return_target\", \"use_json_null\", or \"raise_exception\"")));
4974 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
4975 errmsg(
"wrong number of array subscripts")));
4979 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4980 errmsg(
"cannot delete path in scalar")));
4992 res =
setPath(&it, path_elems, path_nulls, path_len, &st,
5022 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
5023 errmsg(
"wrong number of array subscripts")));
5027 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5028 errmsg(
"cannot set path in scalar")));
5182 bool *path_nulls,
int path_len,
5191 if (path_nulls[level])
5193 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
5194 errmsg(
"path element at position %d is null",
5210 v.
val.array.rawScalar)
5212 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5213 errmsg(
"cannot replace existing key"),
5214 errdetail(
"The path assumes key is a composite object, "
5215 "but it is a scalar value.")));
5218 setPathArray(it, path_elems, path_nulls, path_len, st, level,
5226 setPathObject(it, path_elems, path_nulls, path_len, st, level,
5243 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5244 errmsg(
"cannot replace existing key"),
5245 errdetail(
"The path assumes key is a composite object, "
5246 "but it is a scalar value.")));
5251 elog(
ERROR,
"unrecognized iterator result: %d", (
int) r);
5267 text *pathelem = NULL;
5273 if (level >= path_len || path_nulls[level])
5283 (level == path_len - 1))
5295 for (
i = 0;
i < npairs;
i++)
5304 k.
val.string.len) == 0)
5308 if (level == path_len - 1)
5316 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5317 errmsg(
"cannot replace existing key"),
5318 errhint(
"Try using the function jsonb_set "
5319 "to replace key value.")));
5331 setPath(it, path_elems, path_nulls, path_len,
5332 st, level + 1,
newval, op_type);
5338 level == path_len - 1 &&
i == npairs - 1)
5355 int walking_level = 1;
5357 while (walking_level != 0)
5391 (void)
push_path(st, level, path_elems, path_nulls,
5412 if (level < path_len && !path_nulls[level])
5419 if (badp ==
c || *badp !=
'\0' || errno != 0)
5421 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
5422 errmsg(
"path element at position %d is not an integer: \"%s\"",
5438 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5439 errmsg(
"path element at position %d is out of range: %d",
5454 if (
idx > 0 &&
idx > nelems)
5463 if ((
idx == INT_MIN || nelems == 0) && (level == path_len - 1) &&
5477 for (
i = 0;
i < nelems;
i++)
5481 if (
i ==
idx && level < path_len)
5485 if (level == path_len - 1)
5504 (
void)
setPath(it, path_elems, path_nulls, path_len,
5505 st, level + 1,
newval, op_type);
5515 int walking_level = 1;
5517 while (walking_level != 0)
5560 (void)
push_path(st, level, path_elems, path_nulls,
5591 errmsg(
"wrong flag type, only arrays and scalars are allowed")));
5597 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5598 errmsg(
"flag array element is not a string"),
5599 errhint(
"Possible values are: \"string\", \"numeric\", \"boolean\", \"key\", and \"all\".")));
5601 if (v.
val.string.len == 3 &&
5604 else if (v.
val.string.len == 3 &&
5607 else if (v.
val.string.len == 6 &&
5610 else if (v.
val.string.len == 7 &&
5613 else if (v.
val.string.len == 7 &&
5618 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5619 errmsg(
"wrong flag in flag array: \"%s\"",
5621 errhint(
"Possible values are: \"string\", \"numeric\", \"boolean\", \"key\", and \"all\".")));
5626 elog(
ERROR,
"unexpected end of flag array");
5631 elog(
ERROR,
"unexpected end of flag array");
5718 state->action_state = action_state;
5719 state->flags = flags;
5792 bool is_scalar =
false;
5801 out = transform_action(action_state, v.
val.string.val, v.
val.string.len);
5817 res->val.array.rawScalar = is_scalar;
5839 state->action = transform_action;
5840 state->action_state = action_state;
5989 *outfuncoid = F_BOOLOUT;
6004 *outfuncoid = F_DATE_OUT;
6009 *outfuncoid = F_TIMESTAMP_OUT;
6013 case TIMESTAMPTZOID:
6014 *outfuncoid = F_TIMESTAMPTZ_OUT;
6031 || typoid == ANYCOMPATIBLEARRAYOID || typoid == RECORDARRAYOID)
6033 *outfuncoid = F_ARRAY_OUT;
6038 *outfuncoid = F_RECORD_OUT;
6059 *outfuncoid = castfunc;
Datum idx(PG_FUNCTION_ARGS)
#define PG_GETARG_ARRAYTYPE_P(n)
bool array_contains_nulls(ArrayType *array)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Datum makeMdArrayResult(ArrayBuildState *astate, int ndims, int *dims, int *lbs, MemoryContext rcontext, bool release)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
ArrayBuildState * initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
Datum numeric_out(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define unconstify(underlying_type, expr)
#define IS_HIGHBIT_SET(ch)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
#define OidIsValid(objectId)
static void PGresult * res
bool domain_check_safe(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt, Node *escontext)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void hash_destroy(HTAB *hashp)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define errsave(context,...)
#define ereport(elevel,...)
Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple)
@ SFRM_Materialize_Random
struct varlena * pg_detoast_datum_packed(struct varlena *datum)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod, fmNodePtr escontext, Datum *result)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define PG_GETARG_TEXT_PP(n)
#define DatumGetHeapTupleHeader(X)
#define DatumGetTextPP(X)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_HEAPTUPLEHEADER(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_GETARG_TEXT_P(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
#define MAT_SRF_USE_EXPECTED_DESC
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
#define HeapTupleIsValid(tuple)
#define HeapTupleHeaderGetTypMod(tup)
#define HeapTupleHeaderGetTypeId(tup)
#define HeapTupleHeaderGetDatumLength(tup)
static uint32 pg_abs_s32(int32 a)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
void escape_json_text(StringInfo buf, const text *txt)
void escape_json_with_len(StringInfo buf, const char *str, int len)
void escape_json(StringInfo buf, const char *str)
JsonParseErrorType pg_parse_json(JsonLexContext *lex, const JsonSemAction *sem)
JsonLexContext * makeJsonLexContextCstringLen(JsonLexContext *lex, const char *json, size_t len, int encoding, bool need_escapes)
JsonParseErrorType json_lex(JsonLexContext *lex)
char * json_errdetail(JsonParseErrorType error, JsonLexContext *lex)
JsonParseErrorType json_count_array_elements(JsonLexContext *lex, int *elements)
void freeJsonLexContext(JsonLexContext *lex)
@ JSON_UNICODE_CODE_POINT_ZERO
@ JSON_UNICODE_UNTRANSLATABLE
@ JSON_UNICODE_HIGH_ESCAPE
@ JSON_TOKEN_OBJECT_START
char * JsonbUnquote(Jsonb *jb)
Datum jsonb_in(PG_FUNCTION_ARGS)
char * JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
char * JsonbToCStringIndent(StringInfo out, JsonbContainer *in, int estimated_len)
#define JsonContainerIsScalar(jc)
#define JsonContainerIsArray(jc)
#define JsonContainerSize(jc)
#define JB_ROOT_IS_OBJECT(jbp_)
static Datum JsonbPGetDatum(const Jsonb *p)
#define IsAJsonbScalar(jsonbval)
#define PG_RETURN_JSONB_P(x)
#define JB_ROOT_IS_ARRAY(jbp_)
#define PG_GETARG_JSONB_P(x)
#define JsonContainerIsObject(jc)
static Jsonb * DatumGetJsonbP(Datum d)
#define JB_ROOT_IS_SCALAR(jbp_)
#define JB_ROOT_COUNT(jbp_)
JsonbValue * getKeyJsonValueFromContainer(JsonbContainer *container, const char *keyVal, int keyLen, JsonbValue *res)
JsonbValue * pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq, JsonbValue *jbval)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
void JsonbToJsonbValue(Jsonb *jsonb, JsonbValue *val)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
JsonbValue * getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
Jsonb * JsonbValueToJsonb(JsonbValue *val)
Datum jsonb_populate_recordset(PG_FUNCTION_ARGS)
JsonLexContext * makeJsonLexContext(JsonLexContext *lex, text *json, bool need_escapes)
static JsonParseErrorType get_array_element_end(void *state, bool isnull)
static Datum elements_worker(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
static JsonParseErrorType hash_array_start(void *state)
Datum jsonb_object_keys(PG_FUNCTION_ARGS)
static JsonParseErrorType populate_recordset_array_start(void *state)
static JsonParseErrorType transform_string_values_array_start(void *state)
static JsonParseErrorType get_object_field_start(void *state, char *fname, bool isnull)
static JsonParseErrorType elements_object_start(void *state)
static JsonParseErrorType transform_string_values_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_array_elements(PG_FUNCTION_ARGS)
static JsonParseErrorType iterate_values_object_field_start(void *state, char *fname, bool isnull)
struct PopulateArrayContext PopulateArrayContext
static JsonbValue * IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, JsonbParseState **state)
Datum json_each_text(PG_FUNCTION_ARGS)
Datum json_populate_recordset(PG_FUNCTION_ARGS)
static JsonParseErrorType populate_array_scalar(void *_state, char *token, JsonTokenType tokentype)
text * transform_json_string_values(text *json, void *action_state, JsonTransformStringValuesAction transform_action)
Datum jsonb_delete(PG_FUNCTION_ARGS)
struct TransformJsonStringValuesState TransformJsonStringValuesState
Datum json_populate_type(Datum json_val, Oid json_type, Oid typid, int32 typmod, void **cache, MemoryContext mcxt, bool *isnull, bool omit_quotes, Node *escontext)
Datum jsonb_delete_array(PG_FUNCTION_ARGS)
static JsonbValue * setPath(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, JsonbValue *newval, int op_type)
Datum jsonb_pretty(PG_FUNCTION_ARGS)
struct DomainIOData DomainIOData
static JsonParseErrorType transform_string_values_array_end(void *state)
static JsonParseErrorType populate_recordset_object_start(void *state)
static RecordIOData * allocate_record_info(MemoryContext mcxt, int ncolumns)
static JsonParseErrorType iterate_values_scalar(void *state, char *token, JsonTokenType tokentype)
static text * JsonbValueAsText(JsonbValue *v)
Datum jsonb_insert(PG_FUNCTION_ARGS)
static JsonParseErrorType get_object_start(void *state)
static JsonParseErrorType populate_recordset_object_field_start(void *state, char *fname, bool isnull)
static JsonParseErrorType populate_recordset_object_field_end(void *state, char *fname, bool isnull)
static JsonParseErrorType populate_array_object_start(void *_state)
#define JsObjectIsEmpty(jso)
static void get_record_type_from_argument(FunctionCallInfo fcinfo, const char *funcname, PopulateRecordCache *cache)
Datum json_array_element(PG_FUNCTION_ARGS)
Datum jsonb_delete_idx(PG_FUNCTION_ARGS)
static JsonParseErrorType sn_object_end(void *state)
#define JB_PATH_CREATE_OR_INSERT
Datum jsonb_populate_record_valid(PG_FUNCTION_ARGS)
Datum json_array_elements_text(PG_FUNCTION_ARGS)
struct EachState EachState
static JsonParseErrorType hash_scalar(void *state, char *token, JsonTokenType tokentype)
static JsonParseErrorType sn_array_element_start(void *state, bool isnull)
static Datum populate_record_worker(FunctionCallInfo fcinfo, const char *funcname, bool is_json, bool have_record_arg, Node *escontext)
static HTAB * get_json_object_as_hash(const char *json, int len, const char *funcname, Node *escontext)
static bool populate_array_json(PopulateArrayContext *ctx, const char *json, int len)
struct StripnullState StripnullState
static void setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, JsonbValue *newval, uint32 nelems, int op_type)
struct IterateJsonStringValuesState IterateJsonStringValuesState
#define JsValueIsString(jsv)
static JsonParseErrorType populate_recordset_object_end(void *state)
static Datum populate_record_field(ColumnIOData *col, Oid typid, int32 typmod, const char *colname, MemoryContext mcxt, Datum defaultval, JsValue *jsv, bool *isnull, Node *escontext, bool omit_scalar_quotes)
Datum jsonb_delete_path(PG_FUNCTION_ARGS)
struct CompositeIOData CompositeIOData
static JsonParseErrorType each_object_field_end(void *state, char *fname, bool isnull)
Datum jsonb_object_field_text(PG_FUNCTION_ARGS)
static Datum each_worker(FunctionCallInfo fcinfo, bool as_text)
static JsonParseErrorType get_array_start(void *state)
static JsonParseErrorType each_scalar(void *state, char *token, JsonTokenType tokentype)
static int report_json_context(JsonLexContext *lex)
Datum json_strip_nulls(PG_FUNCTION_ARGS)
static void push_path(JsonbParseState **st, int level, Datum *path_elems, bool *path_nulls, int path_len, JsonbValue *newval)
struct JsonHashEntry JsonHashEntry
Datum jsonb_set_element(Jsonb *jb, Datum *path, int path_len, JsonbValue *newval)
Datum json_array_elements(PG_FUNCTION_ARGS)
Datum jsonb_concat(PG_FUNCTION_ARGS)
struct ArrayIOData ArrayIOData
static JsonParseErrorType okeys_array_start(void *state)
Datum json_object_field_text(PG_FUNCTION_ARGS)
uint32 parse_jsonb_index_flags(Jsonb *jb)
Datum jsonb_extract_path_text(PG_FUNCTION_ARGS)
Datum json_each(PG_FUNCTION_ARGS)
static JsonParseErrorType alen_scalar(void *state, char *token, JsonTokenType tokentype)
static JsonParseErrorType sn_object_start(void *state)
static JsonParseErrorType sn_array_start(void *state)
static bool populate_array_check_dimension(PopulateArrayContext *ctx, int ndim)
Datum jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text)
static Datum each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
static JsonParseErrorType sn_array_end(void *state)
Datum json_to_recordset(PG_FUNCTION_ARGS)
static JsonParseErrorType get_scalar(void *state, char *token, JsonTokenType tokentype)
#define JB_PATH_CONSISTENT_POSITION
static bool populate_array_assign_ndims(PopulateArrayContext *ctx, int ndims)
JsonTokenType json_get_first_token(text *json, bool throw_error)
Datum jsonb_set(PG_FUNCTION_ARGS)
#define JsValueIsNull(jsv)
static void update_cached_tupdesc(CompositeIOData *io, MemoryContext mcxt)
struct ColumnIOData ColumnIOData
void iterate_jsonb_values(Jsonb *jb, uint32 flags, void *state, JsonIterateStringValuesAction action)
static JsonParseErrorType populate_array_element_end(void *_state, bool isnull)
Datum jsonb_set_lax(PG_FUNCTION_ARGS)
static JsonParseErrorType elements_array_element_end(void *state, bool isnull)
static JsonParseErrorType sn_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_each_text(PG_FUNCTION_ARGS)
static JsonParseErrorType elements_scalar(void *state, char *token, JsonTokenType tokentype)
struct ScalarIOData ScalarIOData
static JsonParseErrorType each_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_strip_nulls(PG_FUNCTION_ARGS)
struct OkeysState OkeysState
struct PopulateArrayState PopulateArrayState
struct PopulateRecordCache PopulateRecordCache
Datum jsonb_extract_path(PG_FUNCTION_ARGS)
static void push_null_elements(JsonbParseState **ps, int num)
void json_categorize_type(Oid typoid, bool is_jsonb, JsonTypeCategory *tcategory, Oid *outfuncoid)
static Datum populate_array(ArrayIOData *aio, const char *colname, MemoryContext mcxt, JsValue *jsv, bool *isnull, Node *escontext)
static JsonParseErrorType okeys_object_field_start(void *state, char *fname, bool isnull)
Datum json_array_length(PG_FUNCTION_ARGS)
struct JHashState JHashState
void json_errsave_error(JsonParseErrorType error, JsonLexContext *lex, Node *escontext)
struct ElementsState ElementsState
Datum jsonb_array_length(PG_FUNCTION_ARGS)
Datum jsonb_object_field(PG_FUNCTION_ARGS)
static Datum elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
void iterate_json_values(text *json, uint32 flags, void *action_state, JsonIterateStringValuesAction action)
Datum jsonb_populate_record(PG_FUNCTION_ARGS)
Datum json_extract_path(PG_FUNCTION_ARGS)
Datum json_extract_path_text(PG_FUNCTION_ARGS)
static JsonParseErrorType elements_array_element_start(void *state, bool isnull)
static void get_record_type_from_query(FunctionCallInfo fcinfo, const char *funcname, PopulateRecordCache *cache)
Datum json_populate_record(PG_FUNCTION_ARGS)
static JsonParseErrorType populate_recordset_array_element_start(void *state, bool isnull)
#define JB_PATH_FILL_GAPS
Jsonb * transform_jsonb_string_values(Jsonb *jsonb, void *action_state, JsonTransformStringValuesAction transform_action)
static JsonParseErrorType transform_string_values_object_end(void *state)
static bool JsValueToJsObject(JsValue *jsv, JsObject *jso, Node *escontext)
Datum json_object_field(PG_FUNCTION_ARGS)
static JsonParseErrorType okeys_scalar(void *state, char *token, JsonTokenType tokentype)
static Datum get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
static void populate_array_report_expected_array(PopulateArrayContext *ctx, int ndim)
static JsonParseErrorType get_object_end(void *state)
static Datum populate_composite(CompositeIOData *io, Oid typid, const char *colname, MemoryContext mcxt, HeapTupleHeader defaultval, JsValue *jsv, bool *isnull, Node *escontext)
Datum jsonb_to_record(PG_FUNCTION_ARGS)
Datum jsonb_array_element(PG_FUNCTION_ARGS)
Datum json_object_keys(PG_FUNCTION_ARGS)
struct AlenState AlenState
#define JB_PATH_INSERT_BEFORE
static JsonParseErrorType populate_recordset_scalar(void *state, char *token, JsonTokenType tokentype)
static JsonParseErrorType get_object_field_end(void *state, char *fname, bool isnull)
bool pg_parse_json_or_errsave(JsonLexContext *lex, const JsonSemAction *sem, Node *escontext)
static Datum get_path_all(FunctionCallInfo fcinfo, bool as_text)
static Datum populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, bool is_json, bool have_record_arg)
static HeapTupleHeader populate_record(TupleDesc tupdesc, RecordIOData **record_p, HeapTupleHeader defaultval, MemoryContext mcxt, JsObject *obj, Node *escontext)
static JsonParseErrorType alen_object_start(void *state)
static bool JsObjectGetField(JsObject *obj, char *field, JsValue *jsv)
static bool populate_array_element(PopulateArrayContext *ctx, int ndim, JsValue *jsv)
static JsonParseErrorType populate_array_element_start(void *_state, bool isnull)
static JsonParseErrorType populate_array_array_end(void *_state)
static void prepare_column_cache(ColumnIOData *column, Oid typid, int32 typmod, MemoryContext mcxt, bool need_scalar)
static JsonParseErrorType get_array_end(void *state)
Datum jsonb_to_recordset(PG_FUNCTION_ARGS)
static JsonParseErrorType sn_scalar(void *state, char *token, JsonTokenType tokentype)
#define JB_PATH_INSERT_AFTER
Datum jsonb_each(PG_FUNCTION_ARGS)
static JsonParseErrorType get_array_element_start(void *state, bool isnull)
static JsonParseErrorType hash_object_field_end(void *state, char *fname, bool isnull)
static void populate_recordset_record(PopulateRecordsetState *state, JsObject *obj)
#define JsObjectFree(jso)
struct PopulateRecordsetState PopulateRecordsetState
static JsonParseErrorType transform_string_values_object_start(void *state)
static JsonParseErrorType transform_string_values_array_element_start(void *state, bool isnull)
static JsonParseErrorType alen_array_element_start(void *state, bool isnull)
static Datum populate_scalar(ScalarIOData *io, Oid typid, int32 typmod, JsValue *jsv, bool *isnull, Node *escontext, bool omit_quotes)
static bool populate_array_dim_jsonb(PopulateArrayContext *ctx, JsonbValue *jbv, int ndim)
Datum jsonb_array_element_text(PG_FUNCTION_ARGS)
@ TYPECAT_COMPOSITE_DOMAIN
Datum json_to_record(PG_FUNCTION_ARGS)
static JsonParseErrorType each_array_start(void *state)
Datum json_array_element_text(PG_FUNCTION_ARGS)
static void setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls, int path_len, JsonbParseState **st, int level, JsonbValue *newval, uint32 npairs, int op_type)
static Datum populate_domain(DomainIOData *io, Oid typid, const char *colname, MemoryContext mcxt, JsValue *jsv, bool *isnull, Node *escontext, bool omit_quotes)
static JsonParseErrorType transform_string_values_scalar(void *state, char *token, JsonTokenType tokentype)
static JsonParseErrorType hash_object_field_start(void *state, char *fname, bool isnull)
Datum jsonb_array_elements_text(PG_FUNCTION_ARGS)
static text * get_worker(text *json, char **tpath, int *ipath, int npath, bool normalize_results)
#define pg_parse_json_or_ereport(lex, sem)
text *(* JsonTransformStringValuesAction)(void *state, char *elem_value, int elem_len)
void(* JsonIterateStringValuesAction)(void *state, char *elem_value, int elem_len)
Oid get_element_type(Oid typid)
bool type_is_rowtype(Oid typid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
char get_typtype(Oid typid)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Oid getBaseType(Oid typid)
int GetDatabaseEncoding(void)
int pg_mblen(const char *mbstr)
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextReset(MemoryContext context)
void * MemoryContextAllocZero(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
char * pnstrdup(const char *in, Size len)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define SOFT_ERROR_OCCURRED(escontext)
#define IsA(nodeptr, _type_)
static Datum NumericGetDatum(Numeric X)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
FormData_pg_attribute * Form_pg_attribute
FormData_pg_type * Form_pg_type
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *X)
MemoryContextSwitchTo(old_ctx)
static chr element(struct vars *v, const chr *startp, const chr *endp)
void check_stack_depth(void)
int strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
StringInfo makeStringInfo(void)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
#define appendStringInfoCharMacro(str, ch)
ColumnIOData * element_info
union ColumnIOData::@24 io
CompositeIOData composite
const char * result_start
Tuplestorestate * tuple_store
Tuplestorestate * tuple_store
const char * function_name
const char * result_start
MemoryContext ecxt_per_query_memory
MemoryContext multi_call_memory_ctx
const char * result_start
JsonIterateStringValuesAction action
const char * save_json_start
const char * function_name
JsonTokenType saved_token_type
JsonbContainer * jsonb_cont
struct JsValue::@25::@26 json
const char * prev_token_terminator
const char * token_terminator
json_struct_action array_end
json_struct_action object_start
json_ofield_action object_field_start
json_aelem_action array_element_start
json_scalar_action scalar
json_aelem_action array_element_end
json_struct_action array_start
json_struct_action object_end
json_ofield_action object_field_end
JsonTokenType element_type
PopulateArrayContext * ctx
const char * element_start
const char * save_json_start
const char * function_name
Tuplestorestate * tuple_store
PopulateRecordCache * cache
JsonTokenType saved_token_type
ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER]
SetFunctionReturnMode returnMode
Tuplestorestate * setResult
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define FirstNormalObjectId
void FreeTupleDesc(TupleDesc tupdesc)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
#define VARSIZE_ANY_EXHDR(PTR)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)