|
|
|
|
@ -126,6 +126,8 @@ typedef struct JsonLikeRegexContext |
|
|
|
|
int cflags; |
|
|
|
|
} JsonLikeRegexContext; |
|
|
|
|
|
|
|
|
|
#define EmptyJsonLikeRegexContext {NULL, 0} |
|
|
|
|
|
|
|
|
|
/* Result of jsonpath predicate evaluation */ |
|
|
|
|
typedef enum JsonPathBool |
|
|
|
|
{ |
|
|
|
|
@ -153,6 +155,8 @@ typedef struct JsonValueList |
|
|
|
|
List *list; |
|
|
|
|
} JsonValueList; |
|
|
|
|
|
|
|
|
|
#define EmptyJsonValueList {NULL, NIL} |
|
|
|
|
|
|
|
|
|
typedef struct JsonValueListIterator |
|
|
|
|
{ |
|
|
|
|
JsonbValue *value; |
|
|
|
|
@ -321,7 +325,7 @@ jsonb_path_match(PG_FUNCTION_ARGS) |
|
|
|
|
Jsonb *jb = PG_GETARG_JSONB_P(0); |
|
|
|
|
JsonPath *jp = PG_GETARG_JSONPATH_P(1); |
|
|
|
|
JsonbValue *jbv; |
|
|
|
|
JsonValueList found = {0}; |
|
|
|
|
JsonValueList found = EmptyJsonValueList; |
|
|
|
|
Jsonb *vars = NULL; |
|
|
|
|
bool silent = true; |
|
|
|
|
|
|
|
|
|
@ -379,7 +383,7 @@ jsonb_path_query(PG_FUNCTION_ARGS) |
|
|
|
|
MemoryContext oldcontext; |
|
|
|
|
Jsonb *vars; |
|
|
|
|
bool silent; |
|
|
|
|
JsonValueList found = {0}; |
|
|
|
|
JsonValueList found = EmptyJsonValueList; |
|
|
|
|
|
|
|
|
|
funcctx = SRF_FIRSTCALL_INIT(); |
|
|
|
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); |
|
|
|
|
@ -420,7 +424,7 @@ jsonb_path_query_array(FunctionCallInfo fcinfo) |
|
|
|
|
{ |
|
|
|
|
Jsonb *jb = PG_GETARG_JSONB_P(0); |
|
|
|
|
JsonPath *jp = PG_GETARG_JSONPATH_P(1); |
|
|
|
|
JsonValueList found = {0}; |
|
|
|
|
JsonValueList found = EmptyJsonValueList; |
|
|
|
|
Jsonb *vars = PG_GETARG_JSONB_P(2); |
|
|
|
|
bool silent = PG_GETARG_BOOL(3); |
|
|
|
|
|
|
|
|
|
@ -439,7 +443,7 @@ jsonb_path_query_first(FunctionCallInfo fcinfo) |
|
|
|
|
{ |
|
|
|
|
Jsonb *jb = PG_GETARG_JSONB_P(0); |
|
|
|
|
JsonPath *jp = PG_GETARG_JSONPATH_P(1); |
|
|
|
|
JsonValueList found = {0}; |
|
|
|
|
JsonValueList found = EmptyJsonValueList; |
|
|
|
|
Jsonb *vars = PG_GETARG_JSONB_P(2); |
|
|
|
|
bool silent = PG_GETARG_BOOL(3); |
|
|
|
|
|
|
|
|
|
@ -510,7 +514,7 @@ executeJsonPath(JsonPath *path, Jsonb *vars, Jsonb *json, bool throwErrors, |
|
|
|
|
* In strict mode we must get a complete list of values to check that |
|
|
|
|
* there are no errors at all. |
|
|
|
|
*/ |
|
|
|
|
JsonValueList vals = {0}; |
|
|
|
|
JsonValueList vals = EmptyJsonValueList; |
|
|
|
|
|
|
|
|
|
res = executeItem(&cxt, &jsp, &jbv, &vals); |
|
|
|
|
|
|
|
|
|
@ -1134,7 +1138,7 @@ executeItemOptUnwrapResult(JsonPathExecContext *cxt, JsonPathItem *jsp, |
|
|
|
|
{ |
|
|
|
|
if (unwrap && jspAutoUnwrap(cxt)) |
|
|
|
|
{ |
|
|
|
|
JsonValueList seq = {0}; |
|
|
|
|
JsonValueList seq = EmptyJsonValueList; |
|
|
|
|
JsonValueListIterator it; |
|
|
|
|
JsonPathExecResult res = executeItem(cxt, jsp, jb, &seq); |
|
|
|
|
JsonbValue *item; |
|
|
|
|
@ -1262,7 +1266,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp, |
|
|
|
|
* regexes, but we use Postgres regexes here. 'flags' is a |
|
|
|
|
* string literal converted to integer flags at compile-time. |
|
|
|
|
*/ |
|
|
|
|
JsonLikeRegexContext lrcxt = {0}; |
|
|
|
|
JsonLikeRegexContext lrcxt = EmptyJsonLikeRegexContext; |
|
|
|
|
|
|
|
|
|
jspInitByBuffer(&larg, jsp->base, |
|
|
|
|
jsp->content.like_regex.expr); |
|
|
|
|
@ -1280,7 +1284,7 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp, |
|
|
|
|
* In strict mode we must get a complete list of values to |
|
|
|
|
* check that there are no errors at all. |
|
|
|
|
*/ |
|
|
|
|
JsonValueList vals = {0}; |
|
|
|
|
JsonValueList vals = EmptyJsonValueList; |
|
|
|
|
JsonPathExecResult res = |
|
|
|
|
executeItemOptUnwrapResultNoThrow(cxt, &larg, jb, |
|
|
|
|
false, &vals); |
|
|
|
|
@ -1432,8 +1436,8 @@ executePredicate(JsonPathExecContext *cxt, JsonPathItem *pred, |
|
|
|
|
{ |
|
|
|
|
JsonPathExecResult res; |
|
|
|
|
JsonValueListIterator lseqit; |
|
|
|
|
JsonValueList lseq = {0}; |
|
|
|
|
JsonValueList rseq = {0}; |
|
|
|
|
JsonValueList lseq = EmptyJsonValueList; |
|
|
|
|
JsonValueList rseq = EmptyJsonValueList; |
|
|
|
|
JsonbValue *lval; |
|
|
|
|
bool error = false; |
|
|
|
|
bool found = false; |
|
|
|
|
@ -1511,8 +1515,8 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp, |
|
|
|
|
{ |
|
|
|
|
JsonPathExecResult jper; |
|
|
|
|
JsonPathItem elem; |
|
|
|
|
JsonValueList lseq = {0}; |
|
|
|
|
JsonValueList rseq = {0}; |
|
|
|
|
JsonValueList lseq = EmptyJsonValueList; |
|
|
|
|
JsonValueList rseq = EmptyJsonValueList; |
|
|
|
|
JsonbValue *lval; |
|
|
|
|
JsonbValue *rval; |
|
|
|
|
Numeric res; |
|
|
|
|
@ -1586,7 +1590,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp, |
|
|
|
|
JsonPathExecResult jper; |
|
|
|
|
JsonPathExecResult jper2; |
|
|
|
|
JsonPathItem elem; |
|
|
|
|
JsonValueList seq = {0}; |
|
|
|
|
JsonValueList seq = EmptyJsonValueList; |
|
|
|
|
JsonValueListIterator it; |
|
|
|
|
JsonbValue *val; |
|
|
|
|
bool hasNext; |
|
|
|
|
@ -2124,7 +2128,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb, |
|
|
|
|
int32 *index) |
|
|
|
|
{ |
|
|
|
|
JsonbValue *jbv; |
|
|
|
|
JsonValueList found = {0}; |
|
|
|
|
JsonValueList found = EmptyJsonValueList; |
|
|
|
|
JsonPathExecResult res = executeItem(cxt, jsp, jb, &found); |
|
|
|
|
Datum numeric_index; |
|
|
|
|
bool have_error = false; |
|
|
|
|
|