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);
889 TEXTOID, -1,
false, TYPALIGN_INT,
890 &key_datums, &key_nulls, &key_count);
894 for (
i = 0,
j = 0;
i < key_count;
i++)
922 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
954 for (
i = 0;
i < nkeys;
i++)
986 for (
i = 0;
i < nkeys;
i++)
1002 Assert(extra_data && extra_data[0]);
1008 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1034 for (
i = 0;
i < nkeys;
i++)
1048 for (
i = 0;
i < nkeys;
i++)
1063 Assert(extra_data && extra_data[0]);
1073 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1171 elog(
ERROR,
"invalid JsonbIteratorNext rc: %d", (
int) r);
1175 *nentries = entries.
count;
1213 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1245 for (
i = 0;
i < nkeys;
i++)
1261 Assert(extra_data && extra_data[0]);
1267 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1291 for (
i = 0;
i < nkeys;
i++)
1305 Assert(extra_data && extra_data[0]);
1315 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1337 snprintf(hashbuf,
sizeof(hashbuf),
"%08x", hashval);
1370 switch (scalarVal->
type)
1379 scalarVal->
val.boolean ?
"t" :
"f", 1);
1400 scalarVal->
val.string.val,
1401 scalarVal->
val.string.len);
1404 elog(
ERROR,
"unrecognized jsonb scalar type: %d", scalarVal->
type);
#define PG_GETARG_ARRAYTYPE_P(n)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
char * numeric_normalize(Numeric num)
#define offsetof(type, field)
#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 List * extract_jsp_path_expr_nodes(JsonPathGinContext *cxt, JsonPathGinPath path, JsonPathItem *jsp, JsonbValue *scalar)
static List * jsonb_ops__extract_nodes(JsonPathGinContext *cxt, JsonPathGinPath path, JsonbValue *scalar, List *nodes)
static JsonPathGinNode * make_jsp_entry_node_scalar(JsonbValue *scalar, bool iskey)
static Datum * extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps, int32 *nentries, Pointer **extra_data)
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 * 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 Datum make_scalar_key(const JsonbValue *scalarVal, bool is_key)
static JsonPathGinNode * make_jsp_expr_node_binary(JsonPathGinNodeType type, JsonPathGinNode *arg1, JsonPathGinNode *arg2)
static JsonPathGinNode * make_jsp_expr_node(JsonPathGinNodeType type, int nargs)
Datum gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
Datum gin_extract_jsonb_query(PG_FUNCTION_ARGS)
Datum gin_extract_jsonb(PG_FUNCTION_ARGS)
static void init_gin_entries(GinEntries *entries, int preallocated)
struct PathHashStack PathHashStack
struct GinEntries GinEntries
List *(* JsonPathGinExtractNodesFunc)(JsonPathGinContext *cxt, JsonPathGinPath path, JsonbValue *scalar, List *nodes)
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)
static JsonPathGinNode * make_jsp_entry_node(Datum entry)
Datum gin_extract_jsonb_path(PG_FUNCTION_ARGS)
struct JsonPathGinPathItem JsonPathGinPathItem
static JsonPathGinNode * make_jsp_expr_node_args(JsonPathGinNodeType type, List *args)
static int add_gin_entry(GinEntries *entries, Datum entry)
union JsonPathGinPath JsonPathGinPath
Datum gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
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)
bool jspGetNext(JsonPathItem *v, JsonPathItem *a)
void jspGetRightArg(JsonPathItem *v, JsonPathItem *a)
char * jspGetString(JsonPathItem *v, int32 *len)
#define PG_GETARG_JSONPATH_P(x)
#define jspIsScalar(type)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
void pfree(void *pointer)
void * palloc0(Size size)
void * repalloc(void *pointer, Size size)
struct NumericData * Numeric
static int list_length(const List *l)
void check_stack_depth(void)
#define UInt32GetDatum(X)
#define DatumGetPointer(X)
#define SET_VARSIZE(PTR, len)
#define PointerGetDatum(X)
#define DatumGetUInt32(X)
#define VARSIZE_ANY_EXHDR(PTR)
static unsigned hash(unsigned *uv, int n)
JsonPathGinExtractNodesFunc extract_nodes
JsonPathGinAddPathItemFunc add_path_item
JsonPathGinNode * args[FLEXIBLE_ARRAY_MEMBER]
union JsonPathGinNode::@20 val
struct JsonPathGinPathItem * parent
struct JsonPathItem::@136::@140 value
union JsonPathItem::@136 content
struct PathHashStack * parent
JsonPathGinPathItem * items
int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)