52 char **tpath,
int *ipath,
int npath,
53 bool normalize_results);
80 bool have_record_arg);
99 bool have_record_arg);
330 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
331 errmsg(
"cannot call json_object_keys on an array")));
342 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
343 errmsg(
"cannot call json_object_keys on a scalar")));
447 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
448 errmsg(
"cannot call function with null path elements")));
452 &pathtext, &pathnulls, &npath);
454 tpath =
palloc(npath *
sizeof(
char *));
455 ipath =
palloc(npath *
sizeof(
int));
458 for (i = 0; i < npath; i++)
461 if (*tpath[i] ==
'\0')
464 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
465 errmsg(
"cannot call function with empty path elements")));
472 ind = strtol(tpath[i], &endptr, 10);
474 ipath[
i] = (int) ind;
480 result =
get_worker(json,
NULL, -1, tpath, ipath, npath, as_text);
500 bool normalize_results)
522 else if (tpath !=
NULL)
527 state->
npath = npath;
576 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
577 errmsg(
"cannot extract array element from a non-array")));
584 bool get_next =
false;
596 lex_level <= _state->npath &&
598 strcmp(fname, _state->
path[lex_level - 1]) == 0)
608 if (lex_level < _state->npath)
609 _state->
pathok[lex_level] =
true;
612 if (lex_level == _state->
npath)
636 bool get_last =
false;
647 lex_level <= _state->npath &&
648 _state->
pathok[lex_level - 1] &&
649 strcmp(fname, _state->
path[lex_level - 1]) == 0)
652 if (lex_level < _state->npath)
653 _state->
pathok[lex_level] =
false;
655 if (lex_level == _state->
npath)
691 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
692 errmsg(
"cannot extract field from a non-object")));
699 lex_level < _state->npath)
707 bool get_next =
false;
718 lex_level <= _state->npath &&
719 _state->
pathok[lex_level - 1])
733 if (lex_level == _state->
npath)
741 _state->
pathok[lex_level] =
true;
766 bool get_last =
false;
777 lex_level <= _state->npath &&
778 _state->
pathok[lex_level - 1] &&
783 if (lex_level < _state->npath)
784 _state->
pathok[lex_level] =
false;
786 if (lex_level == _state->
npath)
807 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
808 errmsg(
"cannot extract element from a scalar")));
863 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
864 errmsg(
"cannot get array length of a non-array")));
875 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
876 errmsg(
"cannot get array length of a scalar")));
931 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
932 errmsg(
"set-valued function called in context that "
933 "cannot accept a set")));
962 "json_each temporary cxt",
1005 bool nulls[2] = {
false,
false};
1051 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1052 errmsg(
"cannot deconstruct an array as an object")));
1063 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1064 errmsg(
"cannot deconstruct a scalar")));
1100 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1101 errmsg(
"set-valued function called in context that "
1102 "cannot accept a set")));
1129 "json_array_elements temporary cxt",
1161 static bool nulls[1] = {
false};
1192 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1193 errmsg(
"cannot call json_array_elements on a non-array")));
1204 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1205 errmsg(
"cannot call json_array_elements on a scalar")));
1240 bool use_json_as_text;
1256 if (have_record_arg)
1264 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1265 errmsg(
"first argument of json_populate_record must be a row type")));
1311 if (have_record_arg)
1325 ncolumns = tupdesc->
natts;
1341 if (my_extra ==
NULL ||
1344 fcinfo->flinfo->fn_extra =
1353 if (have_record_arg && (my_extra->
record_type != tupType ||
1365 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1374 for (i = 0; i < ncolumns; ++
i)
1381 for (i = 0; i < ncolumns; ++
i)
1384 Oid column_type = tupdesc->
attrs[
i]->atttypid;
1388 if (tupdesc->
attrs[i]->attisdropped)
1406 if (hashentry ==
NULL && rec)
1429 tupdesc->
attrs[i]->atttypmod);
1434 value = hashentry->
val;
1438 tupdesc->
attrs[i]->atttypmod);
1470 memset(&ctl, 0,
sizeof(ctl));
1511 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1512 errmsg(
"cannot call %s on a nested object",
1548 hashentry->
isnull = isnull;
1552 char *
val =
palloc((len + 1) *
sizeof(
char));
1572 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1583 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1621 bool use_json_as_text;
1634 if (have_record_arg)
1642 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1643 errmsg(
"first argument of json_populate_recordset must be a row type")));
1658 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1659 errmsg(
"set-valued function called in context that "
1660 "cannot accept a set")));
1687 if (have_record_arg)
1711 ncolumns = tupdesc->
natts;
1720 if (my_extra ==
NULL ||
1723 fcinfo->flinfo->fn_extra =
1757 state->
fn_mcxt = fcinfo->flinfo->fn_mcxt;
1777 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1778 errmsg(
"cannot call json_populate_recordset on an object")));
1781 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1782 errmsg(
"cannot call json_populate_recordset with nested objects")));
1785 memset(&ctl, 0,
sizeof(ctl));
1815 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1832 for (i = 0; i < ncolumns; ++
i)
1839 for (i = 0; i < ncolumns; ++
i)
1842 Oid column_type = tupdesc->
attrs[
i]->atttypid;
1846 if (tupdesc->
attrs[i]->attisdropped)
1864 if (hashentry ==
NULL && rec)
1887 tupdesc->
attrs[i]->atttypmod);
1892 value = hashentry->
val;
1896 tupdesc->
attrs[i]->atttypmod);
1916 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1917 errmsg(
"must call json_populate_recordset on an array of objects")));
1927 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1928 errmsg(
"cannot call json_populate_recordset with nested arrays")));
1938 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1939 errmsg(
"cannot call json_populate_recordset on a scalar")));
1958 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1959 errmsg(
"cannot call json_populate_recordset on a nested object")));
1993 hashentry->
isnull = isnull;
1997 char *
val =
palloc((len + 1) *
sizeof(
char));