90 typedef JsonbValue *(*JsonPathGetVarCallback) (
void *
vars,
char *varName,
int varNameLen,
143 #define jperIsError(jper) ((jper) == jperError)
220 #define JSON_TABLE_EXEC_CONTEXT_MAGIC 418352867
237 #define jspStrictAbsenceOfErrors(cxt) (!(cxt)->laxMode)
238 #define jspAutoUnwrap(cxt) ((cxt)->laxMode)
239 #define jspAutoWrap(cxt) ((cxt)->laxMode)
240 #define jspIgnoreStructuralErrors(cxt) ((cxt)->ignoreStructuralErrors)
241 #define jspThrowErrors(cxt) ((cxt)->throwErrors)
244 #define RETURN_ERROR(throw_error) \
246 if (jspThrowErrors(cxt)) \
261 Jsonb *json,
bool throwErrors,
285 bool ignoreStructuralErrors,
bool unwrapNext);
350 bool useTz,
bool *cast_error);
364 Oid typid,
int32 typmod,
bool *isnull);
375 .SetNamespace = NULL,
376 .SetRowFilter = NULL,
377 .SetColumnFilter = NULL,
414 jb, !silent, NULL, tz);
471 jb, !silent, &found, tz);
489 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
490 errmsg(
"single boolean result is expected")));
551 jb, !silent, &found, tz);
600 jb, !silent, &found, tz);
633 jb, !silent, &found, tz);
778 v = hasNext ? &vbuf :
palloc(
sizeof(*v));
849 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
850 errmsg(
"jsonpath wildcard array accessor can only be applied to an array"))));
862 (cxt, hasNext ? &elem : NULL,
863 jb->
val.binary.data, found, 1, 1, 1,
872 (
errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
873 errmsg(
"jsonpath wildcard member accessor can only be applied to an object"))));
883 bool singleton =
size < 0;
914 index_to = index_from;
918 index_from > index_to ||
921 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
922 errmsg(
"jsonpath array subscript is out of bounds"))));
927 if (index_to >=
size)
953 if (!hasNext && !found)
978 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
979 errmsg(
"jsonpath array accessor can only be applied to an array"))));
990 bool savedIgnoreStructuralErrors;
1004 (cxt, hasNext ? &elem : NULL,
1005 jb->
val.binary.data, found,
1042 (
errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
1043 errmsg(
"JSON object does not contain key \"%s\"",
1045 key.val.string.len))));
1054 (
errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
1055 errmsg(
"jsonpath member accessor can only be applied to an object"))));
1095 jbv->
val.string.len = strlen(jbv->
val.string.val);
1112 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
1113 errmsg(
"jsonpath item method .%s() can only be applied to an array",
1121 jb =
palloc(
sizeof(*jb));
1161 (
Node *) &escontext);
1165 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1166 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type double precision",
1168 if (isinf(
val) || isnan(
val))
1170 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1171 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1180 jb->
val.string.len);
1187 (
Node *) &escontext);
1191 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1192 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type double precision",
1194 if (isinf(
val) || isnan(
val))
1196 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1197 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1209 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1210 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1242 elog(
ERROR,
"evaluating jsonpath LAST outside of array subscript");
1244 if (!hasNext && !found)
1252 lastjbv = hasNext ? &tmpjbv :
palloc(
sizeof(*lastjbv));
1258 lastjbv, found, hasNext);
1279 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1280 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type bigint",
1292 jb->
val.string.len);
1298 (
Node *) &escontext,
1303 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1304 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type bigint",
1311 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1312 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1335 bval = jb->
val.boolean;
1350 (
Node *) &escontext,
1355 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1356 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type boolean",
1371 jb->
val.string.len);
1375 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1376 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type boolean",
1384 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1385 errmsg(
"jsonpath item method .%s() can only be applied to a bool, string, or numeric value",
1390 jb->
val.boolean = bval;
1401 char *numstr = NULL;
1409 num = jb->
val.numeric;
1412 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1413 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1432 (
Node *) &escontext,
1437 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1438 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type numeric",
1444 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1445 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1453 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1454 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1479 elog(
ERROR,
"invalid jsonpath item type for .decimal() precision");
1485 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1486 errmsg(
"precision of jsonpath item method .%s() is out of range for type integer",
1493 elog(
ERROR,
"invalid jsonpath item type for .decimal() scale");
1499 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1500 errmsg(
"scale of jsonpath item method .%s() is out of range for type integer",
1521 (
Node *) &escontext,
1526 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1527 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type numeric",
1536 jb->
val.numeric = num;
1559 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1560 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type integer",
1572 jb->
val.string.len);
1578 (
Node *) &escontext,
1583 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1584 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type integer",
1591 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1592 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1621 jb->
val.string.len);
1628 tmp = (jb->
val.boolean) ?
"true" :
"false";
1632 switch (jb->
val.datetime.typid)
1636 jb->
val.datetime.value));
1640 jb->
val.datetime.value));
1644 jb->
val.datetime.value));
1648 jb->
val.datetime.value));
1650 case TIMESTAMPTZOID:
1652 jb->
val.datetime.value));
1655 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
1656 jb->
val.datetime.typid);
1665 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1666 errmsg(
"jsonpath item method .%s() can only be applied to a bool, string, numeric, or datetime value",
1673 jb->
val.string.val = tmp;
1674 jb->
val.string.len = strlen(jb->
val.string.val);
1682 elog(
ERROR,
"unrecognized jsonpath item type: %d", jsp->
type);
1694 bool unwrapElements)
1699 elog(
ERROR,
"invalid jsonb array value type: %d", jb->
type);
1703 (cxt, jsp, jb->
val.binary.data, found, 1, 1, 1,
1704 false, unwrapElements);
1720 hasNext =
next != NULL;
1807 elog(
ERROR,
"boolean jsonpath item cannot have next item");
1921 elog(
ERROR,
"invalid boolean jsonpath item type: %d", jsp->
type);
1954 bool ignoreStructuralErrors,
bool unwrapNext)
1982 if (level >= first ||
1989 if (ignoreStructuralErrors)
1991 bool savedIgnoreStructuralErrors;
2016 (cxt, jsp, v.
val.binary.data, found,
2017 level + 1, first, last,
2018 ignoreStructuralErrors, unwrapNext);
2065 unwrapRightArg, &rseq);
2084 while (rarg ? (rval != NULL) : first)
2154 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
2155 errmsg(
"left operand of jsonpath operator %s is not a single numeric value",
2161 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
2162 errmsg(
"right operand of jsonpath operator %s is not a single numeric value",
2167 res = func(lval->
val.numeric, rval->
val.numeric, NULL);
2182 lval =
palloc(
sizeof(*lval));
2220 if (!found && !hasNext)
2225 if (!found && !hasNext)
2229 (
errcode(ERRCODE_SQL_JSON_NUMBER_NOT_FOUND),
2230 errmsg(
"operand of unary jsonpath operator %s is not a numeric value",
2270 if (whole->
val.string.len >= initial->
val.string.len &&
2271 !memcmp(whole->
val.string.val,
2272 initial->
val.string.val,
2273 initial->
val.string.len))
2304 str->val.string.len,
2305 cxt->
cflags, DEFAULT_COLLATION_OID, 0, NULL))
2328 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
2329 errmsg(
"jsonpath item method .%s() can only be applied to a numeric value",
2337 jb =
palloc(
sizeof(*jb));
2370 int32 time_precision = -1;
2374 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2375 errmsg(
"jsonpath item method .%s() can only be applied to a string",
2379 jb->
val.string.len);
2386 collid = DEFAULT_COLLATION_OID;
2402 elog(
ERROR,
"invalid jsonpath item type for .datetime() argument");
2410 &typid, &typmod, &tz,
2427 static const char *fmt_str[] =
2434 "yyyy-mm-dd HH24:MI:SS.USTZ",
2435 "yyyy-mm-dd HH24:MI:SSTZ",
2436 "yyyy-mm-dd\"T\"HH24:MI:SS.USTZ",
2437 "yyyy-mm-dd\"T\"HH24:MI:SSTZ",
2438 "yyyy-mm-dd HH24:MI:SS.US",
2439 "yyyy-mm-dd HH24:MI:SS",
2440 "yyyy-mm-dd\"T\"HH24:MI:SS.US",
2441 "yyyy-mm-dd\"T\"HH24:MI:SS"
2460 elog(
ERROR,
"invalid jsonpath item type for %s argument",
2467 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2468 errmsg(
"time precision of jsonpath item method .%s() is out of range for type integer",
2487 &typid, &typmod, &tz,
2488 (
Node *) &escontext);
2501 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2502 errmsg(
"%s format is not recognized: \"%s\"",
2504 errhint(
"Use a datetime template argument to specify the input data format."))));
2507 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2508 errmsg(
"%s format is not recognized: \"%s\"",
2534 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2535 errmsg(
"%s format is not recognized: \"%s\"",
2542 case TIMESTAMPTZOID:
2544 "timestamptz",
"date");
2549 elog(
ERROR,
"type with oid %u not supported", typid);
2562 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2563 errmsg(
"%s format is not recognized: \"%s\"",
2578 case TIMESTAMPTZOID:
2580 "timestamptz",
"time");
2585 elog(
ERROR,
"type with oid %u not supported", typid);
2589 if (time_precision != -1)
2601 typmod = time_precision;
2615 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2616 errmsg(
"%s format is not recognized: \"%s\"",
2627 case TIMESTAMPTZOID:
2632 elog(
ERROR,
"type with oid %u not supported", typid);
2636 if (time_precision != -1)
2648 typmod = time_precision;
2666 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2667 errmsg(
"%s format is not recognized: \"%s\"",
2672 case TIMESTAMPTZOID:
2674 "timestamptz",
"timestamp");
2679 elog(
ERROR,
"type with oid %u not supported", typid);
2683 if (time_precision != -1)
2693 (
Node *) &escontext);
2696 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2697 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2702 typmod = time_precision;
2705 typid = TIMESTAMPOID;
2715 "date",
"timestamptz");
2722 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2723 errmsg(
"%s format is not recognized: \"%s\"",
2728 "timestamp",
"timestamptz");
2732 case TIMESTAMPTZOID:
2735 elog(
ERROR,
"type with oid %u not supported", typid);
2739 if (time_precision != -1)
2749 (
Node *) &escontext);
2752 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2753 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2758 typmod = time_precision;
2761 typid = TIMESTAMPTZOID;
2765 elog(
ERROR,
"unrecognized jsonpath item type: %d", jsp->
type);
2775 if (!hasNext && !found)
2778 jb = hasNext ? &jbvbuf :
palloc(
sizeof(*jb));
2782 jb->
val.datetime.typid = typid;
2783 jb->
val.datetime.typmod = typmod;
2784 jb->
val.datetime.tz = tz;
2832 (
errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
2833 errmsg(
"jsonpath item method .%s() can only be applied to an object",
2836 jbc = jb->
val.binary.data;
2844 keystr.
val.string.val =
"key";
2845 keystr.
val.string.len = 3;
2848 valstr.
val.string.val =
"value";
2849 valstr.
val.string.len = 5;
2852 idstr.
val.string.val =
"id";
2853 idstr.
val.string.len = 2;
2858 id += (int64) cxt->
baseObject.
id * INT64CONST(10000000000);
2878 if (!hasNext && !found)
2970 &
value->val.string.len);
2976 elog(
ERROR,
"unexpected jsonpath item type");
2997 if (curvar->
namelen == varNameLen &&
2998 strncmp(curvar->
name, varName, varNameLen) == 0)
3022 *baseObject = *result;
3078 case TIMESTAMPTZOID:
3080 res->val.datetime.value =
val;
3081 res->val.datetime.typid = typid;
3082 res->val.datetime.typmod = typmod;
3083 res->val.datetime.tz = 0;
3116 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3117 errmsg(
"could not convert value of type %s to jsonpath",
3146 if (cxt->
vars == NULL ||
3147 (v = cxt->
getVar(cxt->
vars, varName, varNameLength,
3148 &baseObject, &baseObjectId)) == NULL)
3150 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3151 errmsg(
"could not find jsonpath variable \"%s\"",
3152 pnstrdup(varName, varNameLength))));
3154 if (baseObjectId > 0)
3174 tmp.
val.string.val = varName;
3175 tmp.
val.string.len = varNameLength;
3203 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3204 errmsg(
"\"vars\" argument is not an object"),
3205 errdetail(
"Jsonpath parameters should be encoded as key-value pairs of \"vars\" object."));
3209 return vars != NULL ? 1 : 0;
3247 const char *
s2,
int len2)
3259 return len1 < len2 ? -1 : 1;
3268 const char *mbstr2,
int mblen2)
3296 utf8len1 = (mbstr1 == utf8str1) ? mblen1 : strlen(utf8str1);
3297 utf8len2 = (mbstr2 == utf8str2) ? mblen2 : strlen(utf8str2);
3305 if (mbstr1 == utf8str1 && mbstr2 == utf8str2)
3309 if (mbstr1 != utf8str1)
3311 if (mbstr2 != utf8str2)
3359 cmp = jb1->
val.boolean == jb2->
val.boolean ? 0 :
3360 jb1->
val.boolean ? 1 : -1;
3367 return jb1->
val.string.len != jb2->
val.string.len ||
3368 memcmp(jb1->
val.string.val,
3369 jb2->
val.string.val,
3373 jb2->
val.string.val, jb2->
val.string.len);
3380 jb1->
val.datetime.typid,
3381 jb2->
val.datetime.value,
3382 jb2->
val.datetime.typid,
3421 elog(
ERROR,
"unrecognized jsonpath operation: %d", op);
3458 Datum numeric_index;
3459 bool have_error =
false;
3467 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
3468 errmsg(
"jsonpath array subscript is not a single numeric value"))));
3479 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
3480 errmsg(
"jsonpath array subscript is out of integer range"))));
3513 else if (!jvl->
list)
3597 jbv->
val.binary.data = &jb->
root;
3637 return scalar->
type ==
type ? scalar : NULL;
3663 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3664 errmsg(
"cannot convert value from %s to %s without time zone usage",
3666 errhint(
"Use *_tz() function for time zone support.")));
3717 bool useTz,
bool *cast_error)
3721 *cast_error =
false;
3738 case TIMESTAMPTZOID:
3749 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3770 case TIMESTAMPTZOID:
3775 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3796 case TIMESTAMPTZOID:
3801 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3819 case TIMESTAMPTZOID:
3830 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3835 case TIMESTAMPTZOID:
3848 case TIMESTAMPTZOID:
3859 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3865 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u", typid1);
3906 const char *column_name)
3928 if (singleton == NULL)
3941 elog(
ERROR,
"unrecognized json wrapper %d", (
int) wrapper);
3959 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3960 errmsg(
"JSON path expression for column \"%s\" should return single item without wrapper",
3962 errhint(
"Use WITH WRAPPER clause to wrap SQL/JSON items into array.")));
3965 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3966 errmsg(
"JSON path expression in JSON_QUERY should return single item without wrapper"),
3967 errhint(
"Use WITH WRAPPER clause to wrap SQL/JSON items into array.")));
3985 const char *column_name)
3994 !
error, &found,
true);
4007 *empty = (count == 0);
4023 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4024 errmsg(
"JSON path expression for column \"%s\" should return single scalar item",
4028 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4029 errmsg(
"JSON path expression in JSON_VALUE should return single scalar item")));
4047 (
errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4048 errmsg(
"JSON path expression for column \"%s\" should return single scalar item",
4052 (
errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4053 errmsg(
"JSON path expression in JSON_VALUE should return single scalar item")));
4074 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4077 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4107 if (
state->passingvalexprs)
4115 namelc, je->passing_names)
4147 state->opaque = cxt;
4163 state->opaque = NULL;
4179 planstate->
parent = parentstate;
4195 for (
i = scan->
colMin;
i >= 0 && i <= scan->colMax;
i++)
4279 elog(
ERROR,
"invalid JsonTablePlan %d", (
int) planstate->
plan->type);
4434 Oid typid,
int32 typmod,
bool *isnull)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
int32 numeric_int4_opt_error(Numeric num, bool *have_error)
Datum float8_numeric(PG_FUNCTION_ARGS)
Datum numeric_cmp(PG_FUNCTION_ARGS)
Numeric numeric_mod_opt_error(Numeric num1, Numeric num2, bool *have_error)
Numeric numeric_div_opt_error(Numeric num1, Numeric num2, bool *have_error)
Numeric int64_to_numeric(int64 val)
Datum float4_numeric(PG_FUNCTION_ARGS)
Datum int4_numeric(PG_FUNCTION_ARGS)
Datum numeric_uminus(PG_FUNCTION_ARGS)
Datum numeric_ceil(PG_FUNCTION_ARGS)
Datum numerictypmodin(PG_FUNCTION_ARGS)
Datum numeric_out(PG_FUNCTION_ARGS)
int64 numeric_int8_opt_error(Numeric num, bool *have_error)
Datum numeric_trunc(PG_FUNCTION_ARGS)
Datum numeric_in(PG_FUNCTION_ARGS)
bool numeric_is_nan(Numeric num)
Numeric numeric_sub_opt_error(Numeric num1, Numeric num2, bool *have_error)
Numeric numeric_mul_opt_error(Numeric num1, Numeric num2, bool *have_error)
Datum int2_numeric(PG_FUNCTION_ARGS)
Datum numeric_abs(PG_FUNCTION_ARGS)
Datum int8_numeric(PG_FUNCTION_ARGS)
Numeric numeric_add_opt_error(Numeric num1, Numeric num2, bool *have_error)
bool numeric_is_inf(Numeric num)
Datum numeric_floor(PG_FUNCTION_ARGS)
Datum timestamp_cmp(PG_FUNCTION_ARGS)
bool AdjustTimestampForTypmod(Timestamp *time, int32 typmod, Node *escontext)
Datum timestamp_timestamptz(PG_FUNCTION_ARGS)
int32 timestamp_cmp_timestamptz_internal(Timestamp timestampVal, TimestampTz dt2)
int32 anytimestamp_typmod_check(bool istz, int32 typmod)
Datum timestamptz_timestamp(PG_FUNCTION_ARGS)
Datum timestamptz_out(PG_FUNCTION_ARGS)
Datum timestamp_out(PG_FUNCTION_ARGS)
bool parse_bool(const char *value, bool *result)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
int32 date_cmp_timestamp_internal(DateADT dateVal, Timestamp dt2)
Datum date_cmp(PG_FUNCTION_ARGS)
Datum time_cmp(PG_FUNCTION_ARGS)
Datum timestamp_time(PG_FUNCTION_ARGS)
int32 anytime_typmod_check(bool istz, int32 typmod)
Datum date_timestamptz(PG_FUNCTION_ARGS)
Datum timetz_cmp(PG_FUNCTION_ARGS)
Datum date_out(PG_FUNCTION_ARGS)
Datum timetz_time(PG_FUNCTION_ARGS)
Datum time_timetz(PG_FUNCTION_ARGS)
Datum time_out(PG_FUNCTION_ARGS)
Datum timestamptz_timetz(PG_FUNCTION_ARGS)
void AdjustTimeForTypmod(TimeADT *time, int32 typmod)
Datum timestamptz_date(PG_FUNCTION_ARGS)
Datum timestamp_date(PG_FUNCTION_ARGS)
int32 date_cmp_timestamptz_internal(DateADT dateVal, TimestampTz dt2)
Datum timestamptz_time(PG_FUNCTION_ARGS)
Datum timetz_out(PG_FUNCTION_ARGS)
Datum date_timestamp(PG_FUNCTION_ARGS)
static DateADT DatumGetDateADT(Datum X)
static TimeADT DatumGetTimeADT(Datum X)
static Datum TimeTzADTPGetDatum(const TimeTzADT *X)
static TimeTzADT * DatumGetTimeTzADTP(Datum X)
static Datum TimeADTGetDatum(TimeADT X)
static void PGresult * res
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
float8 float8in_internal(char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)
Datum Int64GetDatum(int64 X)
Datum Float8GetDatum(float8 X)
bool DirectInputFunctionCallSafe(PGFunction func, char *str, Oid typioparam, int32 typmod, fmNodePtr escontext, Datum *result)
#define PG_FREE_IF_COPY(ptr, n)
#define DirectFunctionCall2(func, arg1, arg2)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_BOOL(n)
Datum(* PGFunction)(FunctionCallInfo fcinfo)
#define PG_RETURN_BOOL(x)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
Datum int8in(PG_FUNCTION_ARGS)
Datum int4in(PG_FUNCTION_ARGS)
if(TABLE==NULL||TABLE_index==NULL)
Datum jsonb_in(PG_FUNCTION_ARGS)
const char * JsonbTypeName(JsonbValue *val)
bool JsonbExtractScalar(JsonbContainer *jbc, JsonbValue *res)
#define JsonContainerIsScalar(jc)
#define JsonContainerIsArray(jc)
static Jsonb * DatumGetJsonbP(Datum d)
#define JsonContainerSize(jc)
#define PG_GETARG_JSONB_P_COPY(x)
static Datum JsonbPGetDatum(const Jsonb *p)
#define IsAJsonbScalar(jsonbval)
#define PG_RETURN_JSONB_P(x)
#define PG_GETARG_JSONB_P(x)
#define JsonContainerIsObject(jc)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
Jsonb * JsonbValueToJsonb(JsonbValue *val)
JsonbValue * getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
JsonbValue * pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq, JsonbValue *jbval)
JsonbValue * findJsonbValueFromContainer(JsonbContainer *container, uint32 flags, JsonbValue *key)
void jspGetLeftArg(JsonPathItem *v, JsonPathItem *a)
void jspGetArg(JsonPathItem *v, JsonPathItem *a)
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
bool jspGetBool(JsonPathItem *v)
void jspInit(JsonPathItem *v, JsonPath *js)
const char * jspOperationName(JsonPathItemType type)
Numeric jspGetNumeric(JsonPathItem *v)
bool jspGetArraySubscript(JsonPathItem *v, JsonPathItem *from, JsonPathItem *to, int i)
bool jspGetNext(JsonPathItem *v, JsonPathItem *a)
void jspGetRightArg(JsonPathItem *v, JsonPathItem *a)
char * jspGetString(JsonPathItem *v, int32 *len)
bool jspConvertRegexFlags(uint32 xflags, int *result, struct Node *escontext)
#define PG_GETARG_JSONPATH_P(x)
static JsonPath * DatumGetJsonPathP(Datum d)
#define PG_GETARG_JSONPATH_P_COPY(x)
static JsonPathBool executeComparison(JsonPathItem *cmp, JsonbValue *lv, JsonbValue *rv, void *p)
bool JsonPathExists(Datum jb, JsonPath *jp, bool *error, List *vars)
static Datum jsonb_path_query_first_internal(FunctionCallInfo fcinfo, bool tz)
static JsonPathExecResult executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found, bool unwrap)
Datum jsonb_path_query_tz(PG_FUNCTION_ARGS)
#define jspAutoUnwrap(cxt)
Datum jsonb_path_exists_opr(PG_FUNCTION_ARGS)
static int cmpDateToTimestamp(DateADT date1, Timestamp ts2, bool useTz)
static JsonPathBool executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, bool canHaveNext)
static int JsonbArraySize(JsonbValue *jb)
struct JsonBaseObjectInfo JsonBaseObjectInfo
Numeric(* BinaryArithmFunc)(Numeric num1, Numeric num2, bool *error)
static void JsonTableResetRowPattern(JsonTablePlanState *planstate, Datum item)
struct JsonTablePlanState JsonTablePlanState
static List * JsonValueListGetList(JsonValueList *jvl)
struct JsonValueList JsonValueList
static int compareStrings(const char *mbstr1, int mblen1, const char *mbstr2, int mblen2)
static JsonPathExecResult appendBoolResult(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonValueList *found, JsonPathBool res)
Datum jsonb_path_query_first(PG_FUNCTION_ARGS)
static void JsonTableSetDocument(TableFuncScanState *state, Datum value)
static Datum jsonb_path_query_array_internal(FunctionCallInfo fcinfo, bool tz)
static JsonPathExecResult executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, BinaryArithmFunc func, JsonValueList *found)
static int countVariablesFromJsonb(void *varsJsonb)
static Datum jsonb_path_query_internal(FunctionCallInfo fcinfo, bool tz)
#define RETURN_ERROR(throw_error)
#define JSON_TABLE_EXEC_CONTEXT_MAGIC
static JsonPathExecResult executeItemOptUnwrapResultNoThrow(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, bool unwrap, JsonValueList *found)
static JsonPathExecResult executeAnyItem(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbContainer *jbc, JsonValueList *found, uint32 level, uint32 first, uint32 last, bool ignoreStructuralErrors, bool unwrapNext)
static JsonPathExecResult executeKeyValueMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found)
static JsonPathBool executeStartsWith(JsonPathItem *jsp, JsonbValue *whole, JsonbValue *initial, void *param)
static Datum jsonb_path_match_internal(FunctionCallInfo fcinfo, bool tz)
static JsonBaseObjectInfo setBaseObject(JsonPathExecContext *cxt, JsonbValue *jbv, int32 id)
static Datum castTimeToTimeTz(Datum time, bool useTz)
static void JsonValueListAppend(JsonValueList *jvl, JsonbValue *jbv)
static JsonPathExecResult executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, PGFunction func, JsonValueList *found)
Datum JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty, bool *error, List *vars, const char *column_name)
static int JsonbType(JsonbValue *jb)
static void JsonTableResetNestedPlan(JsonTablePlanState *planstate)
static JsonPathExecResult executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found)
static JsonbValue * getScalar(JsonbValue *scalar, enum jbvType type)
static void JsonItemFromDatum(Datum val, Oid typid, int32 typmod, JsonbValue *res)
struct JsonPathExecContext JsonPathExecContext
Datum jsonb_path_match_tz(PG_FUNCTION_ARGS)
static JsonTableExecContext * GetJsonTableExecContext(TableFuncScanState *state, const char *fname)
static JsonPathExecResult executeItem(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found)
Datum jsonb_path_query(PG_FUNCTION_ARGS)
static bool JsonTablePlanScanNextRow(JsonTablePlanState *planstate)
Datum jsonb_path_match_opr(PG_FUNCTION_ARGS)
JsonPathBool(* JsonPathPredicateCallback)(JsonPathItem *jsp, JsonbValue *larg, JsonbValue *rarg, void *param)
static JsonbValue * getJsonPathVariableFromJsonb(void *varsJsonb, char *varName, int varNameLength, JsonbValue *baseObject, int *baseObjectId)
static JsonbValue * GetJsonPathVar(void *cxt, char *varName, int varNameLen, JsonbValue *baseObject, int *baseObjectId)
struct JsonTablePlanRowSource JsonTablePlanRowSource
static void JsonValueListInitIterator(const JsonValueList *jvl, JsonValueListIterator *it)
static JsonPathBool executeNestedBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb)
static int compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2, bool useTz, bool *cast_error)
static int cmpDateToTimestampTz(DateADT date1, TimestampTz tstz2, bool useTz)
Datum jsonb_path_match(PG_FUNCTION_ARGS)
static JsonbValue * wrapItemsInArray(const JsonValueList *items)
static JsonbValue * JsonValueListNext(const JsonValueList *jvl, JsonValueListIterator *it)
#define jspStrictAbsenceOfErrors(cxt)
static void JsonTableDestroyOpaque(TableFuncScanState *state)
static void JsonValueListClear(JsonValueList *jvl)
static void JsonTableInitOpaque(TableFuncScanState *state, int natts)
static JsonPathExecResult executeNextItem(JsonPathExecContext *cxt, JsonPathItem *cur, JsonPathItem *next, JsonbValue *v, JsonValueList *found, bool copy)
Datum jsonb_path_exists(PG_FUNCTION_ARGS)
#define jperIsError(jper)
static Datum jsonb_path_exists_internal(FunctionCallInfo fcinfo, bool tz)
JsonbValue * JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars, const char *column_name)
static bool JsonTablePlanNextRow(JsonTablePlanState *planstate)
struct JsonValueListIterator JsonValueListIterator
Datum jsonb_path_query_array_tz(PG_FUNCTION_ARGS)
static JsonTablePlanState * JsonTableInitPlan(JsonTableExecContext *cxt, JsonTablePlan *plan, JsonTablePlanState *parentstate, List *args, MemoryContext mcxt)
static JsonPathExecResult executeItemUnwrapTargetArray(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found, bool unwrapElements)
static int cmpTimestampToTimestampTz(Timestamp ts1, TimestampTz tstz2, bool useTz)
static JsonPathBool executeLikeRegex(JsonPathItem *jsp, JsonbValue *str, JsonbValue *rarg, void *param)
static int JsonValueListLength(const JsonValueList *jvl)
static bool JsonValueListIsEmpty(JsonValueList *jvl)
#define jspIgnoreStructuralErrors(cxt)
struct JsonLikeRegexContext JsonLikeRegexContext
static void JsonbValueInitNumericDatum(JsonbValue *jbv, Datum num)
static int CountJsonPathVars(void *cxt)
struct JsonTableExecContext JsonTableExecContext
static int compareNumeric(Numeric a, Numeric b)
static Datum JsonTableGetValue(TableFuncScanState *state, int colnum, Oid typid, int32 typmod, bool *isnull)
static JsonPathBool compareItems(int32 op, JsonbValue *jb1, JsonbValue *jb2, bool useTz)
static JsonPathExecResult getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, int32 *index)
Datum jsonb_path_query_first_tz(PG_FUNCTION_ARGS)
JsonbValue *(* JsonPathGetVarCallback)(void *vars, char *varName, int varNameLen, JsonbValue *baseObject, int *baseObjectId)
Datum jsonb_path_query_array(PG_FUNCTION_ARGS)
static JsonPathExecResult executeItemOptUnwrapResult(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, bool unwrap, JsonValueList *found)
static JsonPathExecResult executeNumericItemMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, bool unwrap, PGFunction func, JsonValueList *found)
static void getJsonPathVariable(JsonPathExecContext *cxt, JsonPathItem *variable, JsonbValue *value)
static JsonbValue * JsonValueListHead(JsonValueList *jvl)
Datum jsonb_path_exists_tz(PG_FUNCTION_ARGS)
static bool JsonTableFetchRow(TableFuncScanState *state)
static void getJsonPathItem(JsonPathExecContext *cxt, JsonPathItem *item, JsonbValue *value)
static JsonPathBool executePredicate(JsonPathExecContext *cxt, JsonPathItem *pred, JsonPathItem *larg, JsonPathItem *rarg, JsonbValue *jb, bool unwrapRightArg, JsonPathPredicateCallback exec, void *param)
static int binaryCompareStrings(const char *s1, int len1, const char *s2, int len2)
const TableFuncRoutine JsonbTableRoutine
int(* JsonPathCountVarsCallback)(void *vars)
static JsonbValue * JsonbInitBinary(JsonbValue *jbv, Jsonb *jb)
static void checkTimezoneIsUsedForCast(bool useTz, const char *type1, const char *type2)
static JsonPathExecResult executeJsonPath(JsonPath *path, void *vars, JsonPathGetVarCallback getVar, JsonPathCountVarsCallback countVars, Jsonb *json, bool throwErrors, JsonValueList *result, bool useTz)
static bool JsonTablePlanJoinNextRow(JsonTablePlanState *planstate)
#define jspThrowErrors(cxt)
static JsonbValue * copyJsonbValue(JsonbValue *src)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
int GetDatabaseEncoding(void)
char * pg_server_to_any(const char *s, int len, int encoding)
char * pnstrdup(const char *in, Size len)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextResetOnly(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static Numeric DatumGetNumeric(Datum X)
struct NumericData * Numeric
static Datum NumericGetDatum(Numeric X)
int pg_ltoa(int32 value, char *a)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static ListCell * list_head(const List *l)
static void * list_nth(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
static ListCell * list_second_cell(const List *l)
void check_stack_depth(void)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static char * DatumGetCString(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
MemoryContextSwitchTo(old_ctx)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
static int cmp(const chr *x, const chr *y, size_t len)
bool RE_compile_and_execute(text *text_re, char *dat, int dat_len, int cflags, Oid collation, int nmatch, regmatch_t *pmatch)
static pg_noinline void Size size
MemoryContext multi_call_memory_ctx
bool ignoreStructuralErrors
JsonPathGetVarCallback getVar
int lastGeneratedObjectId
JsonBaseObjectInfo baseObject
union JsonPathItem::@137 content
struct JsonPathItem::@137::@139 array
struct JsonPathItem::@137::@142 like_regex
struct JsonPathItem::@137::@140 anybounds
struct JsonPathItem::@137::@138 args
JsonTablePlanState * rootplanstate
JsonTablePlanState ** colplanstates
struct JsonTablePlanState * left
struct JsonTablePlanState * nested
struct JsonTablePlanState * parent
struct JsonTablePlanState * right
JsonTablePlanRowSource current
JsonValueListIterator iter
void(* InitOpaque)(struct TableFuncScanState *state, int natts)
static Datum TimestampTzGetDatum(TimestampTz X)
static Datum TimestampGetDatum(Timestamp X)
static Timestamp DatumGetTimestamp(Datum X)
static TimestampTz DatumGetTimestampTz(Datum X)
#define VARSIZE_ANY_EXHDR(PTR)
char * text_to_cstring(const text *t)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)