68#include "utils/fmgrprotos.h"
166 entries->
buf = preallocated ?
palloc(
sizeof(
Datum) * preallocated) : NULL;
174 int id = entries->
count;
191 entries->
buf[entries->
count++] = entry;
220 result =
varstr_cmp(a1p, len1, a2p, len2, C_COLLATION_OID);
271 *nentries = entries.
count;
310 pentry =
palloc(
sizeof(*pentry));
316 path->
items = pentry;
373 sizeof(node->
args[0]) * nargs);
400 node->
args[0] = arg1;
401 node->
args[1] = arg2;
421 for (pentry = path.
items; pentry; pentry = pentry->
parent)
527 nodes =
lappend(nodes, filter);
609 return larg ? larg : rarg;
672 scalar_item = &left_item;
673 path_item = &right_item;
677 scalar_item = &right_item;
678 path_item = &left_item;
683 switch (scalar_item->
type)
700 scalar.
val.string.len =
704 elog(
ERROR,
"invalid scalar jsonpath item type: %d",
784 *nentries = entries.
count;
788 *extra_data =
palloc0(
sizeof(**extra_data) * entries.
count);
842 elog(
ERROR,
"invalid jsonpath gin node type: %d", node->
type);
892 for (
i = 0,
j = 0;
i < key_count;
i++)
921 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
953 for (
i = 0;
i < nkeys;
i++)
985 for (
i = 0;
i < nkeys;
i++)
1001 Assert(extra_data && extra_data[0]);
1007 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1033 for (
i = 0;
i < nkeys;
i++)
1047 for (
i = 0;
i < nkeys;
i++)
1062 Assert(extra_data && extra_data[0]);
1072 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1170 elog(
ERROR,
"invalid JsonbIteratorNext rc: %d", (
int) r);
1174 *nentries = entries.
count;
1212 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1244 for (
i = 0;
i < nkeys;
i++)
1260 Assert(extra_data && extra_data[0]);
1266 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1290 for (
i = 0;
i < nkeys;
i++)
1304 Assert(extra_data && extra_data[0]);
1314 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1336 snprintf(hashbuf,
sizeof(hashbuf),
"%08x", hashval);
1369 switch (scalarVal->
type)
1378 scalarVal->
val.boolean ?
"t" :
"f", 1);
1399 scalarVal->
val.string.val,
1400 scalarVal->
val.string.len);
1403 elog(
ERROR,
"unrecognized jsonb scalar type: %d", scalarVal->
type);
#define PG_GETARG_ARRAYTYPE_P(n)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
char * numeric_normalize(Numeric num)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
static void PGresult * res
#define PG_FREE_IF_COPY(ptr, n)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define PG_RETURN_GIN_TERNARY_VALUE(x)
#define GIN_SEARCH_MODE_ALL
static Datum hash_any(const unsigned char *k, int keylen)
#define PG_GETARG_JSONB_P(x)
#define JsonbContainsStrategyNumber
#define JsonbJsonpathPredicateStrategyNumber
#define JsonbExistsAllStrategyNumber
#define JsonbExistsStrategyNumber
#define JsonbExistsAnyStrategyNumber
#define JsonbJsonpathExistsStrategyNumber
#define JB_ROOT_COUNT(jbp_)
static JsonPathGinNode * extract_jsp_bool_expr(JsonPathGinContext *cxt, JsonPathGinPath path, JsonPathItem *jsp, bool not)
static JsonPathGinNode * make_jsp_entry_node_scalar(JsonbValue *scalar, bool iskey)
Datum gin_compare_jsonb(PG_FUNCTION_ARGS)
static Datum make_text_key(char flag, const char *str, int len)
static List * jsonb_path_ops__extract_nodes(JsonPathGinContext *cxt, JsonPathGinPath path, JsonbValue *scalar, List *nodes)
static GinTernaryValue execute_jsp_gin_node(JsonPathGinNode *node, void *check, bool ternary)
static JsonPathGinNode * make_jsp_expr_node_args(JsonPathGinNodeType type, List *args)
static JsonPathGinNode * extract_jsp_path_expr(JsonPathGinContext *cxt, JsonPathGinPath path, JsonPathItem *jsp, JsonbValue *scalar)
bool(* JsonPathGinAddPathItemFunc)(JsonPathGinPath *path, JsonPathItem *jsp)
static bool jsonb_ops__add_path_item(JsonPathGinPath *path, JsonPathItem *jsp)
static JsonPathGinNode * make_jsp_expr_node(JsonPathGinNodeType type, int nargs)
static Datum make_scalar_key(const JsonbValue *scalarVal, bool is_key)
static List * jsonb_ops__extract_nodes(JsonPathGinContext *cxt, JsonPathGinPath path, JsonbValue *scalar, List *nodes)
static Datum * extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps, int32 *nentries, Pointer **extra_data)
Datum gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
Datum gin_extract_jsonb_query(PG_FUNCTION_ARGS)
Datum gin_extract_jsonb(PG_FUNCTION_ARGS)
static List * extract_jsp_path_expr_nodes(JsonPathGinContext *cxt, JsonPathGinPath path, JsonPathItem *jsp, JsonbValue *scalar)
static void init_gin_entries(GinEntries *entries, int preallocated)
struct PathHashStack PathHashStack
struct GinEntries GinEntries
static bool jsonb_path_ops__add_path_item(JsonPathGinPath *path, JsonPathItem *jsp)
Datum gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
Datum gin_consistent_jsonb(PG_FUNCTION_ARGS)
Datum gin_extract_jsonb_path(PG_FUNCTION_ARGS)
struct JsonPathGinPathItem JsonPathGinPathItem
static int add_gin_entry(GinEntries *entries, Datum entry)
List *(* JsonPathGinExtractNodesFunc)(JsonPathGinContext *cxt, JsonPathGinPath path, JsonbValue *scalar, List *nodes)
static JsonPathGinNode * make_jsp_expr_node_binary(JsonPathGinNodeType type, JsonPathGinNode *arg1, JsonPathGinNode *arg2)
union JsonPathGinPath JsonPathGinPath
Datum gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
static JsonPathGinNode * make_jsp_entry_node(Datum entry)
static void emit_jsp_gin_entries(JsonPathGinNode *node, GinEntries *entries)
Datum gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
void JsonbHashScalarValue(const JsonbValue *scalarVal, uint32 *hash)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
void jspGetLeftArg(JsonPathItem *v, JsonPathItem *a)
void jspGetArg(JsonPathItem *v, JsonPathItem *a)
void jspInit(JsonPathItem *v, JsonPath *js)
char * jspGetString(JsonPathItem *v, int32 *len)
bool jspGetNext(JsonPathItem *v, JsonPathItem *a)
void jspGetRightArg(JsonPathItem *v, JsonPathItem *a)
#define PG_GETARG_JSONPATH_P(x)
#define jspIsScalar(type)
List * lappend(List *list, void *datum)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
struct NumericData * Numeric
static int list_length(const List *l)
static uint32 DatumGetUInt32(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static Datum UInt32GetDatum(uint32 X)
static unsigned hash(unsigned *uv, int n)
void check_stack_depth(void)
JsonPathGinExtractNodesFunc extract_nodes
JsonPathGinAddPathItemFunc add_path_item
JsonPathGinNode * args[FLEXIBLE_ARRAY_MEMBER]
union JsonPathGinNode::@23 val
struct JsonPathGinPathItem * parent
struct JsonPathItem::@143::@147 value
union JsonPathItem::@143 content
struct PathHashStack * parent
JsonPathGinPathItem * items
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)
int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)