142#define jperIsError(jper) ((jper) == jperError)
168#define BASE_JVL_ITEMS 2
169#define MIN_EXTRA_JVL_ITEMS 16
246#define JSON_TABLE_EXEC_CONTEXT_MAGIC 418352867
263#define jspStrictAbsenceOfErrors(cxt) (!(cxt)->laxMode)
264#define jspAutoUnwrap(cxt) ((cxt)->laxMode)
265#define jspAutoWrap(cxt) ((cxt)->laxMode)
266#define jspIgnoreStructuralErrors(cxt) ((cxt)->ignoreStructuralErrors)
267#define jspThrowErrors(cxt) ((cxt)->throwErrors)
270#define RETURN_ERROR(throw_error) \
272 if (jspThrowErrors(cxt)) \
288 Jsonb *json,
bool throwErrors,
312 bool ignoreStructuralErrors,
bool unwrapNext);
391 Oid typid,
int32 typmod,
bool *isnull);
402 .SetNamespace =
NULL,
403 .SetRowFilter =
NULL,
404 .SetColumnFilter =
NULL,
519 errmsg(
"single boolean result is expected")));
888 errmsg(
"jsonpath wildcard array accessor can only be applied to an array"))));
897 elog(
ERROR,
"invalid jsonb object type: %d",
jb->type);
901 jb->val.binary.data, found, 1, 1, 1,
911 errmsg(
"jsonpath wildcard member accessor can only be applied to an object"))));
929 for (
i = 0;
i <
jsp->content.array.nelems;
i++)
960 errmsg(
"jsonpath array subscript is out of bounds"))));
995 if (res ==
jperOk && !found)
1002 if (res ==
jperOk && !found)
1012 errmsg(
"jsonpath array accessor can only be applied to an array"))));
1021 if (
jsp->content.anybounds.first == 0)
1031 if (res ==
jperOk && !found)
1038 jb->val.binary.data, found,
1040 jsp->content.anybounds.first,
1073 errmsg(
"JSON object does not contain key \"%s\"",
1075 key.val.string.len))));
1085 errmsg(
"jsonpath member accessor can only be applied to an object"))));
1142 errmsg(
"jsonpath item method .%s() can only be applied to an array",
1188 (
Node *) &escontext);
1193 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1198 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1207 jb->val.string.len);
1214 (
Node *) &escontext);
1219 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1224 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1237 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1268 elog(
ERROR,
"evaluating jsonpath LAST outside of array subscript");
1301 (
Node *) &escontext);
1305 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1318 jb->val.string.len);
1324 (
Node *) &escontext,
1330 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1338 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1360 bval =
jb->val.boolean;
1375 (
Node *) &escontext,
1381 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1396 jb->val.string.len);
1401 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1410 errmsg(
"jsonpath item method .%s() can only be applied to a boolean, string, or numeric value",
1414 jbv.val.boolean = bval;
1433 num =
jb->val.numeric;
1437 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1456 (
Node *) &escontext,
1462 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1469 errmsg(
"NaN or Infinity is not allowed for jsonpath item method .%s()",
1478 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1502 elog(
ERROR,
"invalid jsonpath item type for .decimal() precision");
1505 (
Node *) &escontext);
1509 errmsg(
"precision of jsonpath item method .%s() is out of range for type integer",
1512 if (
jsp->content.args.right)
1516 elog(
ERROR,
"invalid jsonpath item type for .decimal() scale");
1519 (
Node *) &escontext);
1520 if (escontext.error_occurred)
1523 errmsg(
"scale of jsonpath item method .%s() is out of range for type integer",
1544 (
Node *) &escontext,
1550 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1558 jbv.val.numeric = num;
1579 (
Node *) &escontext);
1583 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1595 jb->val.string.len);
1601 (
Node *) &escontext,
1607 errmsg(
"argument \"%s\" of jsonpath item method .%s() is invalid for type %s",
1615 errmsg(
"jsonpath item method .%s() can only be applied to a string or numeric value",
1643 jb->val.string.len);
1650 tmp = (
jb->val.boolean) ?
"true" :
"false";
1657 jb->val.datetime.value,
1658 jb->val.datetime.typid,
1659 &
jb->val.datetime.tz);
1669 errmsg(
"jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value",
1675 jbv.val.string.val = tmp;
1684 elog(
ERROR,
"unrecognized jsonpath item type: %d",
jsp->type);
1701 elog(
ERROR,
"invalid jsonb array value type: %d",
jb->type);
1705 (cxt,
jsp,
jb->val.binary.data, found, 1, 1, 1,
1818 elog(
ERROR,
"boolean jsonpath item cannot have next item");
1894 jsp->content.like_regex.expr);
1939 elog(
ERROR,
"invalid boolean jsonpath item type: %d",
jsp->type);
1972 bool ignoreStructuralErrors,
bool unwrapNext)
2000 if (level >= first ||
2007 if (ignoreStructuralErrors)
2022 if (res ==
jperOk && !found)
2034 (cxt,
jsp, v.
val.binary.data, found,
2035 level + 1, first, last,
2111 while (rarg ? (
rval !=
NULL) : first)
2202 errmsg(
"left operand of jsonpath operator %s is not a single numeric value",
2213 errmsg(
"right operand of jsonpath operator %s is not a single numeric value",
2219 res = func(lval->
val.numeric,
rval->val.numeric,
NULL);
2225 res = func(lval->
val.numeric,
rval->val.numeric, (
Node *) &escontext);
2242 resval.val.numeric = res;
2294 errmsg(
"operand of unary jsonpath operator %s is not a numeric value",
2340 if (
whole->val.string.len >=
initial->val.string.len &&
2368 jsp->content.like_regex.patternlen);
2374 str->val.string.len,
2400 errmsg(
"jsonpath item method .%s() can only be applied to a numeric value",
2445 errmsg(
"jsonpath item method .%s() can only be applied to a string",
2449 jb->val.string.len);
2472 elog(
ERROR,
"invalid jsonpath item type for .datetime() argument");
2480 &typid, &typmod, &tz,
2497 static const char *
fmt_str[] =
2504 "yyyy-mm-dd HH24:MI:SS.USTZ",
2505 "yyyy-mm-dd HH24:MI:SSTZ",
2506 "yyyy-mm-dd\"T\"HH24:MI:SS.USTZ",
2507 "yyyy-mm-dd\"T\"HH24:MI:SSTZ",
2508 "yyyy-mm-dd HH24:MI:SS.US",
2509 "yyyy-mm-dd HH24:MI:SS",
2510 "yyyy-mm-dd\"T\"HH24:MI:SS.US",
2511 "yyyy-mm-dd\"T\"HH24:MI:SS"
2530 elog(
ERROR,
"invalid jsonpath item type for %s argument",
2534 (
Node *) &escontext);
2538 errmsg(
"time precision of jsonpath item method .%s() is out of range for type integer",
2557 &typid, &typmod, &tz,
2558 (
Node *) &escontext);
2572 errmsg(
"%s format is not recognized: \"%s\"",
2574 errhint(
"Use a datetime template argument to specify the input data format."))));
2578 errmsg(
"%s format is not recognized: \"%s\"",
2605 errmsg(
"%s format is not recognized: \"%s\"",
2614 "timestamptz",
"date");
2619 elog(
ERROR,
"type with oid %u not supported", typid);
2633 errmsg(
"%s format is not recognized: \"%s\"",
2650 "timestamptz",
"time");
2655 elog(
ERROR,
"type with oid %u not supported", typid);
2686 errmsg(
"%s format is not recognized: \"%s\"",
2702 elog(
ERROR,
"type with oid %u not supported", typid);
2737 errmsg(
"%s format is not recognized: \"%s\"",
2744 "timestamptz",
"timestamp");
2749 elog(
ERROR,
"type with oid %u not supported", typid);
2763 (
Node *) &escontext);
2767 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2788 "date",
"timestamptz");
2808 errmsg(
"%s format is not recognized: \"%s\"",
2813 "timestamp",
"timestamptz");
2830 elog(
ERROR,
"type with oid %u not supported", typid);
2844 (
Node *) &escontext);
2848 errmsg(
"time precision of jsonpath item method .%s() is invalid",
2860 elog(
ERROR,
"unrecognized jsonpath item type: %d",
jsp->type);
2875 jbv.val.datetime.typid = typid;
2876 jbv.val.datetime.typmod = typmod;
2877 jbv.val.datetime.tz = tz;
2926 errmsg(
"jsonpath item method .%s() can only be applied to an object",
2929 jbc =
jb->val.binary.data;
2937 keystr.val.string.val =
"key";
2938 keystr.val.string.len = 3;
2941 valstr.val.string.val =
"value";
2942 valstr.val.string.len = 5;
2945 idstr.val.string.val =
"id";
2946 idstr.val.string.len = 2;
3004 if (res ==
jperOk && !found)
3063 &
value->val.string.len);
3069 elog(
ERROR,
"unexpected jsonpath item type");
3115 *baseObject = *result;
3173 res->
val.datetime.value =
val;
3174 res->
val.datetime.typid = typid;
3175 res->
val.datetime.typmod = typmod;
3176 res->
val.datetime.tz = 0;
3210 errmsg(
"could not convert value of type %s to jsonpath",
3244 errmsg(
"could not find jsonpath variable \"%s\"",
3267 tmp.
val.string.val = varName;
3297 errmsg(
"\"vars\" argument is not an object"),
3298 errdetail(
"Jsonpath parameters should be encoded as key-value pairs of \"vars\" object."));
3340 const char *
s2,
int len2)
3352 return len1 < len2 ? -1 : 1;
3432 if (
jb1->type !=
jb2->type)
3452 cmp =
jb1->val.boolean ==
jb2->val.boolean ? 0 :
3453 jb1->val.boolean ? 1 : -1;
3460 return jb1->val.string.len !=
jb2->val.string.len ||
3462 jb2->val.string.val,
3466 jb2->val.string.val,
jb2->val.string.len);
3473 jb1->val.datetime.typid,
3474 jb2->val.datetime.value,
3475 jb2->val.datetime.typid,
3514 elog(
ERROR,
"unrecognized jsonpath operation: %d", op);
3570 errmsg(
"jsonpath array subscript is not a single numeric value"))));
3578 (
Node *) &escontext);
3585 errmsg(
"jsonpath array subscript is out of integer range"))));
3668 return (
jvl->nitems == 0);
3674#if BASE_JVL_ITEMS > 1
3676 return (
jvl->nitems == 1);
3678 return (
jvl->nitems == 1 &&
jvl->next ==
NULL);
3685#if BASE_JVL_ITEMS > 1
3687 return (
jvl->nitems > 1);
3689 return (
jvl->nitems == 1 &&
jvl->next !=
NULL);
3697 return &
jvl->items[0];
3720 if (
it->nextitem >=
it->chunk->nitems)
3722 it->chunk =
it->chunk->next;
3728 return &
it->chunk->items[
it->nextitem++];
3738 jbv->val.binary.data = &
jb->root;
3807 errmsg(
"cannot convert value from %s to %s without time zone usage",
3809 errhint(
"Use *_tz() function for time zone support.")));
3892 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3918 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3944 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
3973 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
4002 elog(
ERROR,
"unrecognized SQL/JSON datetime type oid: %u",
4049 const char *column_name)
4094 elog(
ERROR,
"unrecognized json wrapper %d", (
int) wrapper);
4113 errmsg(
"JSON path expression for column \"%s\" must return single item when no wrapper is requested",
4115 errhint(
"Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
4119 errmsg(
"JSON path expression in JSON_QUERY must return single item when no wrapper is requested"),
4120 errhint(
"Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
4138 const char *column_name)
4148 !
error, &found,
true);
4176 errmsg(
"JSON path expression for column \"%s\" must return single scalar item",
4181 errmsg(
"JSON path expression in JSON_VALUE must return single scalar item")));
4200 errmsg(
"JSON path expression for column \"%s\" must return single scalar item",
4205 errmsg(
"JSON path expression in JSON_VALUE must return single scalar item")));
4226 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4229 elog(
ERROR,
"%s called with invalid TableFuncScanState", fname);
4259 if (
state->passingvalexprs)
4298 state->opaque = cxt;
4339 planstate->
args = args;
4431 elog(
ERROR,
"invalid JsonTablePlan %d", (
int) planstate->
plan->type);
4586 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)
Datum float8_numeric(PG_FUNCTION_ARGS)
Datum numeric_cmp(PG_FUNCTION_ARGS)
Numeric int64_to_numeric(int64 val)
Datum float4_numeric(PG_FUNCTION_ARGS)
Datum int4_numeric(PG_FUNCTION_ARGS)
Datum numeric_uminus(PG_FUNCTION_ARGS)
Numeric numeric_mod_safe(Numeric num1, Numeric num2, Node *escontext)
Datum numeric_ceil(PG_FUNCTION_ARGS)
int32 numeric_int4_safe(Numeric num, Node *escontext)
Datum numerictypmodin(PG_FUNCTION_ARGS)
Numeric numeric_add_safe(Numeric num1, Numeric num2, Node *escontext)
int64 numeric_int8_safe(Numeric num, Node *escontext)
Numeric numeric_div_safe(Numeric num1, Numeric num2, Node *escontext)
Numeric numeric_sub_safe(Numeric num1, Numeric num2, Node *escontext)
Datum numeric_out(PG_FUNCTION_ARGS)
Datum numeric_trunc(PG_FUNCTION_ARGS)
Datum numeric_in(PG_FUNCTION_ARGS)
bool numeric_is_nan(Numeric num)
Datum int2_numeric(PG_FUNCTION_ARGS)
Numeric numeric_mul_safe(Numeric num1, Numeric num2, Node *escontext)
Datum numeric_abs(PG_FUNCTION_ARGS)
Datum int8_numeric(PG_FUNCTION_ARGS)
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 TimeTzADT * DatumGetTimeTzADTP(Datum X)
static DateADT DatumGetDateADT(Datum X)
static TimeADT DatumGetTimeADT(Datum X)
static Datum TimeTzADTPGetDatum(const TimeTzADT *X)
static Datum TimeADTGetDatum(TimeADT X)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define palloc_object(type)
#define palloc_array(type, count)
#define palloc0_object(type)
float8 float8in_internal(char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)
bool DirectInputFunctionCallSafe(PGFunction func, char *str, Oid typioparam, int32 typmod, Node *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)
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)
#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)
static Jsonb * DatumGetJsonbP(Datum d)
void pushJsonbValue(JsonbInState *pstate, JsonbIteratorToken seq, JsonbValue *jbval)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
JsonbValue * findJsonbValueFromContainer(JsonbContainer *container, uint32 flags, JsonbValue *key)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
JsonbValue * getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
Jsonb * JsonbValueToJsonb(JsonbValue *val)
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)
char * jspGetString(JsonPathItem *v, int32 *len)
Numeric jspGetNumeric(JsonPathItem *v)
bool jspGetArraySubscript(JsonPathItem *v, JsonPathItem *from, JsonPathItem *to, int i)
const char * jspOperationName(JsonPathItemType type)
bool jspGetNext(JsonPathItem *v, JsonPathItem *a)
void jspGetRightArg(JsonPathItem *v, JsonPathItem *a)
bool jspConvertRegexFlags(uint32 xflags, int *result, struct Node *escontext)
#define PG_GETARG_JSONPATH_P(x)
#define PG_GETARG_JSONPATH_P_COPY(x)
static JsonPath * DatumGetJsonPathP(Datum d)
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)
static JsonbValue * JsonValueListNext(JsonValueListIterator *it)
static void JsonTableResetRowPattern(JsonTablePlanState *planstate, Datum item)
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 bool JsonValueListIsEmpty(const JsonValueList *jvl)
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 JsonTableExecContext * GetJsonTableExecContext(TableFuncScanState *state, const char *fname)
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)
Numeric(* BinaryArithmFunc)(Numeric num1, Numeric num2, Node *escontext)
static JsonBaseObjectInfo setBaseObject(JsonPathExecContext *cxt, JsonbValue *jbv, int32 id)
static Datum castTimeToTimeTz(Datum time, bool useTz)
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)
JsonbValue *(* JsonPathGetVarCallback)(void *vars, char *varName, int varNameLen, JsonbValue *baseObject, int *baseObjectId)
Datum jsonb_path_match_tz(PG_FUNCTION_ARGS)
static JsonPathExecResult executeItem(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, JsonValueList *found)
static void JsonValueListInit(JsonValueList *jvl)
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)
static bool JsonValueListIsSingleton(const JsonValueList *jvl)
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)
#define jspStrictAbsenceOfErrors(cxt)
static void JsonTableDestroyOpaque(TableFuncScanState *state)
static void JsonValueListClear(JsonValueList *jvl)
static void JsonTableInitOpaque(TableFuncScanState *state, int natts)
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)
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)
#define jspIgnoreStructuralErrors(cxt)
static void JsonbValueInitNumericDatum(JsonbValue *jbv, Datum num)
static int CountJsonPathVars(void *cxt)
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)
#define MIN_EXTRA_JVL_ITEMS
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)
static void JsonValueListInitIterator(JsonValueList *jvl, JsonValueListIterator *it)
Datum jsonb_path_exists_tz(PG_FUNCTION_ARGS)
static bool JsonTableFetchRow(TableFuncScanState *state)
static void getJsonPathItem(JsonPathExecContext *cxt, JsonPathItem *item, JsonbValue *value)
static JsonPathExecResult executeNextItem(JsonPathExecContext *cxt, JsonPathItem *cur, JsonPathItem *next, JsonbValue *v, JsonValueList *found)
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)
static bool JsonValueListHasMultipleItems(const JsonValueList *jvl)
const TableFuncRoutine JsonbTableRoutine
static void JsonValueListAppend(JsonValueList *jvl, const JsonbValue *jbv)
static JsonbValue * wrapItemsInArray(JsonValueList *items)
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)
int GetDatabaseEncoding(void)
char * pg_server_to_any(const char *s, int len, int encoding)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
char * pnstrdup(const char *in, Size len)
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)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static void * list_nth(const List *list, int n)
static char buf[DEFAULT_XLOG_SEG_SIZE]
PGDLLIMPORT pg_tz * session_timezone
static Datum Int64GetDatum(int64 X)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static char * DatumGetCString(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum Float8GetDatum(float8 X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
static int cmp(const chr *x, const chr *y, size_t len)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
bool RE_compile_and_execute(text *text_re, char *dat, int dat_len, int cflags, Oid collation, int nmatch, regmatch_t *pmatch)
void check_stack_depth(void)
bool ignoreStructuralErrors
JsonPathGetVarCallback getVar
int lastGeneratedObjectId
JsonBaseObjectInfo baseObject
JsonTablePlanState * rootplanstate
JsonTablePlanState ** colplanstates
struct JsonTablePlanState * left
struct JsonTablePlanState * nested
struct JsonTablePlanState * parent
struct JsonTablePlanState * right
JsonTablePlanRowSource current
JsonValueListIterator iter
struct JsonValueList * last
JsonbValue items[BASE_JVL_ITEMS]
struct JsonValueList * next
void(* InitOpaque)(TableFuncScanState *state, int natts)
static Datum TimestampTzGetDatum(TimestampTz X)
static Datum TimestampGetDatum(Timestamp X)
static Timestamp DatumGetTimestamp(Datum X)
static TimestampTz DatumGetTimestampTz(Datum X)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *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)