91 typedef JsonbValue *(*JsonPathGetVarCallback) (
void *
vars,
char *varName,
int varNameLen,
144 #define jperIsError(jper) ((jper) == jperError)
221 #define JSON_TABLE_EXEC_CONTEXT_MAGIC 418352867
238 #define jspStrictAbsenceOfErrors(cxt) (!(cxt)->laxMode)
239 #define jspAutoUnwrap(cxt) ((cxt)->laxMode)
240 #define jspAutoWrap(cxt) ((cxt)->laxMode)
241 #define jspIgnoreStructuralErrors(cxt) ((cxt)->ignoreStructuralErrors)
242 #define jspThrowErrors(cxt) ((cxt)->throwErrors)
245 #define RETURN_ERROR(throw_error) \
247 if (jspThrowErrors(cxt)) \
262 Jsonb *json,
bool throwErrors,
286 bool ignoreStructuralErrors,
bool unwrapNext);
351 bool useTz,
bool *cast_error);
365 Oid typid,
int32 typmod,
bool *isnull);
376 .SetNamespace = NULL,
377 .SetRowFilter = NULL,
378 .SetColumnFilter = NULL,
415 jb, !silent, NULL, tz);
472 jb, !silent, &found, tz);
490 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
491 errmsg(
"single boolean result is expected")));
552 jb, !silent, &found, tz);
601 jb, !silent, &found, tz);
634 jb, !silent, &found, tz);
779 v = hasNext ? &vbuf :
palloc(
sizeof(*v));
850 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
851 errmsg(
"jsonpath wildcard array accessor can only be applied to an array"))));
863 (cxt, hasNext ? &elem : NULL,
864 jb->
val.binary.data, found, 1, 1, 1,
873 (
errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
874 errmsg(
"jsonpath wildcard member accessor can only be applied to an object"))));
884 bool singleton =
size < 0;
915 index_to = index_from;
919 index_from > index_to ||
922 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
923 errmsg(
"jsonpath array subscript is out of bounds"))));
928 if (index_to >=
size)
954 if (!hasNext && !found)
979 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
980 errmsg(
"jsonpath array accessor can only be applied to an array"))));
991 bool savedIgnoreStructuralErrors;
1005 (cxt, hasNext ? &elem : NULL,
1006 jb->
val.binary.data, found,
1043 (
errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
1044 errmsg(
"JSON object does not contain key \"%s\"",
1046 key.val.string.len))));
1055 (
errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
1056 errmsg(
"jsonpath member accessor can only be applied to an object"))));
1096 jbv->
val.string.len = strlen(jbv->
val.string.val);
1113 (
errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
1114 errmsg(
"jsonpath item method .%s() can only be applied to an array",
1122 jb =
palloc(
sizeof(*jb));
1162 (
Node *) &escontext);
1166 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1167 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type double precision",
1169 if (isinf(
val) || isnan(
val))
1171 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1172 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1181 jb->
val.string.len);
1188 (
Node *) &escontext);
1192 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1193 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type double precision",
1195 if (isinf(
val) || isnan(
val))
1197 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1198 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1210 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1211 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1243 elog(
ERROR,
"evaluating jsonpath LAST outside of array subscript");
1245 if (!hasNext && !found)
1253 lastjbv = hasNext ? &tmpjbv :
palloc(
sizeof(*lastjbv));
1259 lastjbv, found, hasNext);
1280 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1281 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type bigint",
1293 jb->
val.string.len);
1299 (
Node *) &escontext,
1304 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1305 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type bigint",
1312 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1313 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1336 bval = jb->
val.boolean;
1351 (
Node *) &escontext,
1356 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1357 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type boolean",
1372 jb->
val.string.len);
1376 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1377 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type boolean",
1385 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1386 errmsg(
"jsonpath item method .%s() can only be applied to a boolean, string, or numeric value",
1391 jb->
val.boolean = bval;
1402 char *numstr = NULL;
1410 num = jb->
val.numeric;
1413 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1414 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1433 (
Node *) &escontext,
1438 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1439 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type numeric",
1445 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1446 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1454 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1455 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1480 elog(
ERROR,
"invalid jsonpath item type for .decimal() precision");
1486 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1487 errmsg(
"precision of jsonpath item method .%s() is out of range for type integer",
1494 elog(
ERROR,
"invalid jsonpath item type for .decimal() scale");
1500 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1501 errmsg(
"scale of jsonpath item method .%s() is out of range for type integer",
1522 (
Node *) &escontext,
1527 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1528 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type numeric",
1537 jb->
val.numeric = num;
1560 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1561 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type integer",
1573 jb->
val.string.len);
1579 (
Node *) &escontext,
1584 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1585 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type integer",
1592 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1593 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1622 jb->
val.string.len);
1629 tmp = (jb->
val.boolean) ?
"true" :
"false";
1636 jb->
val.datetime.value,
1637 jb->
val.datetime.typid,
1638 &jb->
val.datetime.tz);
1647 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
1648 errmsg(
"jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value",
1655 jb->
val.string.val = tmp;
1656 jb->
val.string.len = strlen(jb->
val.string.val);
1664 elog(
ERROR,
"unrecognized jsonpath item type: %d", jsp->
type);
1676 bool unwrapElements)
1681 elog(
ERROR,
"invalid jsonb array value type: %d", jb->
type);
1685 (cxt, jsp, jb->
val.binary.data, found, 1, 1, 1,
1686 false, unwrapElements);
1702 hasNext =
next != NULL;
1789 elog(
ERROR,
"boolean jsonpath item cannot have next item");
1903 elog(
ERROR,
"invalid boolean jsonpath item type: %d", jsp->
type);
1936 bool ignoreStructuralErrors,
bool unwrapNext)
1964 if (level >= first ||
1971 if (ignoreStructuralErrors)
1973 bool savedIgnoreStructuralErrors;
1998 (cxt, jsp, v.
val.binary.data, found,
1999 level + 1, first, last,
2000 ignoreStructuralErrors, unwrapNext);
2047 unwrapRightArg, &rseq);
2066 while (rarg ? (rval != NULL) : first)
2136 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
2137 errmsg(
"left operand of jsonpath operator %s is not a single numeric value",
2143 (
errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
2144 errmsg(
"right operand of jsonpath operator %s is not a single numeric value",
2149 res = func(lval->
val.numeric, rval->
val.numeric, NULL);
2164 lval =
palloc(
sizeof(*lval));
2202 if (!found && !hasNext)
2207 if (!found && !hasNext)
2211 (
errcode(ERRCODE_SQL_JSON_NUMBER_NOT_FOUND),
2212 errmsg(
"operand of unary jsonpath operator %s is not a numeric value",
2252 if (whole->
val.string.len >= initial->
val.string.len &&
2253 !memcmp(whole->
val.string.val,
2254 initial->
val.string.val,
2255 initial->
val.string.len))
2286 str->val.string.len,
2287 cxt->
cflags, DEFAULT_COLLATION_OID, 0, NULL))
2310 (
errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
2311 errmsg(
"jsonpath item method .%s() can only be applied to a numeric value",
2319 jb =
palloc(
sizeof(*jb));
2352 int32 time_precision = -1;
2356 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2357 errmsg(
"jsonpath item method .%s() can only be applied to a string",
2361 jb->
val.string.len);
2368 collid = DEFAULT_COLLATION_OID;
2384 elog(
ERROR,
"invalid jsonpath item type for .datetime() argument");
2392 &typid, &typmod, &tz,
2409 static const char *fmt_str[] =
2416 "yyyy-mm-dd HH24:MI:SS.USTZ",
2417 "yyyy-mm-dd HH24:MI:SSTZ",
2418 "yyyy-mm-dd\"T\"HH24:MI:SS.USTZ",
2419 "yyyy-mm-dd\"T\"HH24:MI:SSTZ",
2420 "yyyy-mm-dd HH24:MI:SS.US",
2421 "yyyy-mm-dd HH24:MI:SS",
2422 "yyyy-mm-dd\"T\"HH24:MI:SS.US",
2423 "yyyy-mm-dd\"T\"HH24:MI:SS"
2442 elog(
ERROR,
"invalid jsonpath item type for %s argument",
2449 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2450 errmsg(
"time precision of jsonpath item method .%s() is out of range for type integer",
2469 &typid, &typmod, &tz,
2470 (
Node *) &escontext);
2483 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2484 errmsg(
"%s format is not recognized: \"%s\"",
2486 errhint(
"Use a datetime template argument to specify the input data format."))));
2489 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2490 errmsg(
"%s format is not recognized: \"%s\"",
2516 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2517 errmsg(
"%s format is not recognized: \"%s\"",
2524 case TIMESTAMPTZOID:
2526 "timestamptz",
"date");
2531 elog(
ERROR,
"type with oid %u not supported", typid);
2544 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2545 errmsg(
"%s format is not recognized: \"%s\"",
2560 case TIMESTAMPTZOID:
2562 "timestamptz",
"time");
2567 elog(
ERROR,
"type with oid %u not supported", typid);
2571 if (time_precision != -1)
2583 typmod = time_precision;
2597 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2598 errmsg(
"%s format is not recognized: \"%s\"",
2609 case TIMESTAMPTZOID:
2614 elog(
ERROR,
"type with oid %u not supported", typid);
2618 if (time_precision != -1)
2630 typmod = time_precision;
2648 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2649 errmsg(
"%s format is not recognized: \"%s\"",
2654 case TIMESTAMPTZOID:
2656 "timestamptz",
"timestamp");
2661 elog(
ERROR,
"type with oid %u not supported", typid);
2665 if (time_precision != -1)
2675 (
Node *) &escontext);
2678 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2679 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2684 typmod = time_precision;
2687 typid = TIMESTAMPOID;
2700 "date",
"timestamptz");
2719 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2720 errmsg(
"%s format is not recognized: \"%s\"",
2725 "timestamp",
"timestamptz");
2732 &fsec, NULL, NULL) == 0)
2739 case TIMESTAMPTZOID:
2742 elog(
ERROR,
"type with oid %u not supported", typid);
2746 if (time_precision != -1)
2756 (
Node *) &escontext);
2759 (
errcode(ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION),
2760 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2765 typmod = time_precision;
2768 typid = TIMESTAMPTZOID;
2772 elog(
ERROR,
"unrecognized jsonpath item type: %d", jsp->
type);
2782 if (!hasNext && !found)
2785 jb = hasNext ? &jbvbuf :
palloc(
sizeof(*jb));
2789 jb->
val.datetime.typid = typid;
2790 jb->
val.datetime.typmod = typmod;
2791 jb->
val.datetime.tz = tz;
2839 (
errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
2840 errmsg(
"jsonpath item method .%s() can only be applied to an object",
2843 jbc = jb->
val.binary.data;
2851 keystr.
val.string.val =
"key";
2852 keystr.
val.string.len = 3;
2855 valstr.
val.string.val =
"value";
2856 valstr.
val.string.len = 5;
2859 idstr.
val.string.val =
"id";
2860 idstr.
val.string.len = 2;
2865 id += (int64) cxt->
baseObject.
id * INT64CONST(10000000000);
2885 if (!hasNext && !found)
2977 &
value->val.string.len);
2983 elog(
ERROR,
"unexpected jsonpath item type");
3004 if (curvar->
namelen == varNameLen &&
3005 strncmp(curvar->
name, varName, varNameLen) == 0)
3029 *baseObject = *result;
3085 case TIMESTAMPTZOID:
3087 res->val.datetime.value =
val;
3088 res->val.datetime.typid = typid;
3089 res->val.datetime.typmod = typmod;
3090 res->val.datetime.tz = 0;
3123 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3124 errmsg(
"could not convert value of type %s to jsonpath",
3153 if (cxt->
vars == NULL ||
3154 (v = cxt->
getVar(cxt->
vars, varName, varNameLength,
3155 &baseObject, &baseObjectId)) == NULL)
3157 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3158 errmsg(
"could not find jsonpath variable \"%s\"",
3159 pnstrdup(varName, varNameLength))));
3161 if (baseObjectId > 0)
3181 tmp.
val.string.val = varName;
3182 tmp.
val.string.len = varNameLength;
3210 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3211 errmsg(
"\"vars\" argument is not an object"),
3212 errdetail(
"Jsonpath parameters should be encoded as key-value pairs of \"vars\" object."));
3216 return vars != NULL ? 1 : 0;
3254 const char *
s2,
int len2)
3266 return len1 < len2 ? -1 : 1;
3275 const char *mbstr2,
int mblen2)
3303 utf8len1 = (mbstr1 == utf8str1) ? mblen1 : strlen(utf8str1);
3304 utf8len2 = (mbstr2 == utf8str2) ? mblen2 : strlen(utf8str2);
3312 if (mbstr1 == utf8str1 && mbstr2 == utf8str2)
3316 if (mbstr1 != utf8str1)
3318 if (mbstr2 != utf8str2)
3366 cmp = jb1->
val.boolean == jb2->
val.boolean ? 0 :
3367 jb1->
val.boolean ? 1 : -1;
3374 return jb1->
val.string.len != jb2->
val.string.len ||
3375 memcmp(jb1->
val.string.val,
3376 jb2->
val.string.val,
3380 jb2->
val.string.val, jb2->
val.string.len);
3387 jb1->
val.datetime.typid,
3388 jb2->
val.datetime.value,
3389 jb2->
val.datetime.typid,
3428 elog(
ERROR,
"unrecognized jsonpath operation: %d", op);
3465 Datum numeric_index;
3466 bool have_error =
false;
3474 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
3475 errmsg(
"jsonpath array subscript is not a single numeric value"))));
3486 (
errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
3487 errmsg(
"jsonpath array subscript is out of integer range"))));
3520 else if (!jvl->
list)
3604 jbv->
val.binary.data = &jb->
root;
3644 return scalar->
type ==
type ? scalar : NULL;
3670 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3671 errmsg(
"cannot convert value from %s to %s without time zone usage",
3673 errhint(
"Use *_tz() function for time zone support.")));
3724 bool useTz,
bool *cast_error)
3728 *cast_error =
false;
3745 case TIMESTAMPTZOID:
3756 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3777 case TIMESTAMPTZOID:
3782 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3803 case TIMESTAMPTZOID:
3808 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3826 case TIMESTAMPTZOID:
3837 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3842 case TIMESTAMPTZOID:
3855 case TIMESTAMPTZOID:
3866 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3872 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u", typid1);
3913 const char *column_name)
3952 if (singleton == NULL)
3962 elog(
ERROR,
"unrecognized json wrapper %d", (
int) wrapper);
3980 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3981 errmsg(
"JSON path expression for column \"%s\" should return single item without wrapper",
3983 errhint(
"Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
3986 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3987 errmsg(
"JSON path expression in JSON_QUERY should return single item without wrapper"),
3988 errhint(
"Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
4006 const char *column_name)
4015 !
error, &found,
true);
4028 *empty = (count == 0);
4044 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4045 errmsg(
"JSON path expression for column \"%s\" should return single scalar item",
4049 (
errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4050 errmsg(
"JSON path expression in JSON_VALUE should return single scalar item")));
4068 (
errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4069 errmsg(
"JSON path expression for column \"%s\" should return single scalar item",
4073 (
errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4074 errmsg(
"JSON path expression in JSON_VALUE should return single scalar item")));
4095 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4098 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4128 if (
state->passingvalexprs)
4136 namelc, je->passing_names)
4168 state->opaque = cxt;
4184 state->opaque = NULL;
4200 planstate->
parent = parentstate;
4216 for (
i = scan->
colMin;
i >= 0 && i <= scan->colMax;
i++)
4300 elog(
ERROR,
"invalid JsonTablePlan %d", (
int) planstate->
plan->type);
4455 Oid typid,
int32 typmod,
bool *isnull)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
void j2date(int jd, int *year, int *month, int *day)
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)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
int32 anytimestamp_typmod_check(bool istz, int32 typmod)
Datum timestamptz_timestamp(PG_FUNCTION_ARGS)
bool parse_bool(const char *value, bool *result)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define POSTGRES_EPOCH_JDATE
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 timetz_time(PG_FUNCTION_ARGS)
Datum time_timetz(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 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)
char * JsonEncodeDateTime(char *buf, Datum value, Oid typid, const int *tzp)
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)