70 const Datum *elems,
int nelems);
74 bool reverse,
Datum *elems,
int nelems);
219 if (
so->numberOfKeys > 0)
230 so->numberOfKeys = 0;
232 if (numberOfKeys < 1)
254 numberOfKeys *
sizeof(
int));
268 if (
inkeys[0].sk_attno < 1)
269 elog(
ERROR,
"btree index keys must be ordered by attribute");
272 if (numberOfKeys == 1)
278 so->numberOfKeys = 1;
280 if (
inkeys[0].sk_attno == 1)
291 (
so->arrayKeys[0].scan_key == 0 &&
319 for (
int i = 0;;
i++)
324 if (
i < numberOfKeys)
339 if (
i == numberOfKeys || inkey->
sk_attno != attno)
345 elog(
ERROR,
"btree index keys must be ordered by attribute");
485 if (
i == numberOfKeys)
513 xform[
j].arrayidx = arrayidx;
531 array = &
so->arrayKeys[arrayidx - 1];
540 array = &
so->arrayKeys[
xform[
j].arrayidx - 1];
573 xform[
j].arrayidx = arrayidx;
616 xform[
j].arrayidx = arrayidx;
784 switch (
skey->sk_strategy)
798 elog(
ERROR,
"unrecognized StrategyNumber: %d",
799 (
int)
skey->sk_strategy);
818 if (
subkey->sk_attno != attno)
1024 lefttype =
leftarg->sk_subtype;
1026 lefttype = opcintype;
1029 righttype = opcintype;
1038 if (lefttype == opcintype && righttype ==
optype)
1194 skey->sk_argument,
false, array,
1197 switch (
skey->sk_strategy)
1233 elog(
ERROR,
"unrecognized StrategyNumber: %d",
1234 (
int)
skey->sk_strategy);
1297 switch (
skey->sk_strategy)
1339 elog(
ERROR,
"unrecognized StrategyNumber: %d",
1340 (
int)
skey->sk_strategy);
1442 so->qual_ok =
false;
1500 so->qual_ok =
false;
1575 attno =
so->keyData[0].sk_attno;
1580 for (
int i = 0;
i <
so->numberOfKeys;
i++)
1584 if (
origkey->sk_attno != attno)
1660 if (
so->numArrayKeys)
1674 for (
int i = 0;
i <
so->numberOfKeys;
i++)
1689 if (
so->numArrayKeys)
1707 if (
so->numArrayKeys)
1762 if (
so->numArrayKeys)
1869 if (numArrayKeys == 0)
1883 if (
so->arrayContext ==
NULL)
1885 "BTree array context",
1959 elog(
ERROR,
"missing oprcode for skipping equals operator %u",
eq_op);
1972 so->arrayKeys[numArrayKeys].num_elems = -1;
1977 so->arrayKeys[numArrayKeys].attlen = attr->
attlen;
1978 so->arrayKeys[numArrayKeys].attbyval = attr->
attbyval;
1979 so->arrayKeys[numArrayKeys].null_elem =
true;
1980 so->arrayKeys[numArrayKeys].sksup =
1982 so->arrayKeys[numArrayKeys].low_compare =
NULL;
1983 so->arrayKeys[numArrayKeys].high_compare =
NULL;
2022 so->qual_ok =
false;
2036 &elem_values, &elem_nulls, &num_elems);
2043 for (
int j = 0;
j < num_elems;
j++)
2054 so->qual_ok =
false;
2064 elemtype =
cur->sk_subtype;
2073 switch (
cur->sk_strategy)
2095 elog(
ERROR,
"unrecognized StrategyNumber: %d",
2096 (
int)
cur->sk_strategy);
2137 orig->elem_values, &
orig->num_elems,
2138 elem_values, num_elems))
2147 if (
orig->num_elems == 0)
2149 so->qual_ok =
false;
2180 so->arrayKeys[numArrayKeys].num_elems = num_elems;
2183 so->arrayKeys[numArrayKeys].elem_values = elem_values;
2184 so->arrayKeys[numArrayKeys].cur_elem = -1;
2193 so->numArrayKeys = numArrayKeys;
2238 if (
so->numArrayKeys == 0)
2277 elemtype =
outkey->sk_subtype;
2297 for (; arrayidx <
so->numArrayKeys; arrayidx++)
2328 if (
so->numArrayKeys == 0)
2334 (
so->numArrayKeys - arrayidx));
2374 errmsg_internal(
"number of array scan keys left by preprocessing (%d) exceeds the maximum allowed by parallel btree index scans (%d)",
2438#ifdef DEBUG_DISABLE_SKIP_SCAN
2443 for (
int i = 0;;
i++)
2581 const Datum *elems,
int nelems)
2605 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
2606 strat, elemtype, elemtype,
2616 for (
i = 1;
i < nelems;
i++)
2667 if (elemtype == opcintype)
2691 elog(
ERROR,
"missing support function %d(%u,%u) for attribute %d of index \"%s\"",
2713 elog(
ERROR,
"missing support function %d(%u,%u) for attribute %d of index \"%s\"",
2733 Datum *elems,
int nelems)
#define DatumGetArrayTypeP(X)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define InvalidAttrNumber
#define RegProcedureIsValid(p)
#define INVERT_COMPARE_RESULT(var)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
Datum OidFunctionCall2Coll(Oid functionId, Oid collation, Datum arg1, Datum arg2)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
static int compare(const void *arg1, const void *arg2)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
static int pg_cmp_s32(int32 a, int32 b)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
RegProcedure get_opcode(Oid opno)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextReset(MemoryContext context)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
static bool _bt_merge_arrays(IndexScanDesc scan, ScanKey skey, FmgrInfo *sortproc, bool reverse, Oid origelemtype, Oid nextelemtype, Datum *elems_orig, int *nelems_orig, Datum *elems_next, int nelems_next)
static void _bt_skiparray_strat_increment(IndexScanDesc scan, ScanKey arraysk, BTArrayKeyInfo *array)
static int _bt_num_array_keys(IndexScanDesc scan, Oid *skip_eq_ops_out, int *numSkipArrayKeys_out)
static bool _bt_saoparray_shrink(IndexScanDesc scan, ScanKey arraysk, ScanKey skey, FmgrInfo *orderproc, BTArrayKeyInfo *array, bool *qual_ok)
static void _bt_skiparray_strat_adjust(IndexScanDesc scan, ScanKey arraysk, BTArrayKeyInfo *array)
static int _bt_reorder_array_cmp(const void *a, const void *b)
static bool _bt_skiparray_shrink(IndexScanDesc scan, ScanKey skey, BTArrayKeyInfo *array, bool *qual_ok)
static bool _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption)
static void _bt_unmark_keys(IndexScanDesc scan, int *keyDataMap)
static void _bt_mark_scankey_required(ScanKey skey)
static ScanKey _bt_preprocess_array_keys(IndexScanDesc scan, int *new_numberOfKeys)
static int _bt_compare_array_elements(const void *a, const void *b, void *arg)
static void _bt_preprocess_array_keys_final(IndexScanDesc scan, int *keyDataMap)
static void _bt_setup_array_cmp(IndexScanDesc scan, ScanKey skey, Oid elemtype, FmgrInfo *orderproc, FmgrInfo **sortprocp)
static int _bt_sort_array_elements(ScanKey skey, FmgrInfo *sortproc, bool reverse, Datum *elems, int nelems)
static Datum _bt_find_extreme_element(IndexScanDesc scan, ScanKey skey, Oid elemtype, StrategyNumber strat, const Datum *elems, int nelems)
static bool _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, ScanKey leftarg, ScanKey rightarg, BTArrayKeyInfo *array, FmgrInfo *orderproc, bool *result)
static void _bt_skiparray_strat_decrement(IndexScanDesc scan, ScanKey arraysk, BTArrayKeyInfo *array)
static bool _bt_compare_array_scankey_args(IndexScanDesc scan, ScanKey arraysk, ScanKey skey, FmgrInfo *orderproc, BTArrayKeyInfo *array, bool *qual_ok)
void _bt_preprocess_keys(IndexScanDesc scan)
int _bt_binsrch_array_skey(FmgrInfo *orderproc, bool cur_elem_trig, ScanDirection dir, Datum tupdatum, bool tupnull, BTArrayKeyInfo *array, ScanKey cur, int32 *set_elem_result)
#define SK_BT_INDOPTION_SHIFT
#define SK_BT_NULLS_FIRST
#define BTCommuteStrategyNumber(strat)
BTScanOpaqueData * BTScanOpaque
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
#define qsort(a, b, c, d)
static bool DatumGetBool(Datum X)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
static size_t qunique_arg(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *, void *), void *arg)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
void ScanKeyEntryInitialize(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, RegProcedure procedure, Datum argument)
@ NoMovementScanDirection
SkipSupport PrepareSkipSupportFromOpclass(Oid opfamily, Oid opcintype, bool reverse)
#define BTGreaterStrategyNumber
#define BTMaxStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
struct ScanKeyData * keyData
struct ParallelIndexScanDescData * parallel_scan
StrategyNumber sk_strategy
SkipSupportIncDec decrement
SkipSupportIncDec increment
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)