32#define LOOK_AHEAD_REQUIRED_RECHECKS 3
33#define LOOK_AHEAD_DEFAULT_DISTANCE 5
53 Datum *elems,
int nelems);
55 bool reverse,
Datum *elems,
int nelems);
58 Oid origelemtype,
Oid nextelemtype,
59 Datum *elems_orig,
int *nelems_orig,
60 Datum *elems_next,
int nelems_next);
69 Datum tupdatum,
bool tupnull,
73 Datum tupdatum,
bool tupnull,
75 int32 *set_elem_result);
80 bool readpagetup,
int sktrig,
bool *scanBehind);
83 int sktrig,
bool sktrig_required);
84#ifdef USE_ASSERT_CHECKING
86static bool _bt_verify_keys_with_arraykeys(
IndexScanDesc scan);
96 bool advancenonrequired,
bool prechecked,
bool firstmatch,
97 bool *continuescan,
int *ikey);
158 key->heapkeyspace =
true;
159 key->allequalimage =
false;
161 key->anynullkeys =
false;
162 key->nextkey =
false;
163 key->backward =
false;
164 key->keysz =
Min(indnkeyatts, tupnatts);
165 key->scantid =
key->heapkeyspace && itup ?
167 skey =
key->scankeys;
168 for (
i = 0;
i < indnkeyatts;
i++)
204 key->anynullkeys =
true;
211 if (rel->
rd_index->indnullsnotdistinct)
212 key->anynullkeys =
false;
225 while (stack != NULL)
275 int16 *indoption = rel->rd_indoption;
289 for (
int i = 0;
i < numberOfKeys;
i++)
306 if (numArrayKeys == 0)
315 "BTree array context",
333 for (
int input_ikey = 0; input_ikey < numberOfKeys; input_ikey++)
353 cur = &arrayKeyData[output_ikey];
368 &elmlen, &elmbyval, &elmalign);
371 elmlen, elmbyval, elmalign,
372 &elem_values, &elem_nulls, &num_elems);
379 for (
j = 0;
j < num_elems;
j++)
382 elem_values[num_nonnulls++] = elem_values[
j];
388 if (num_nonnulls == 0)
400 elemtype =
cur->sk_subtype;
402 elemtype = rel->rd_opcintype[
cur->sk_attno - 1];
409 switch (
cur->sk_strategy)
416 elem_values, num_nonnulls);
427 elem_values, num_nonnulls);
431 elog(
ERROR,
"unrecognized StrategyNumber: %d",
432 (
int)
cur->sk_strategy);
453 reverse = (indoption[
cur->sk_attno - 1] & INDOPTION_DESC) != 0;
455 elem_values, num_nonnulls);
457 if (origarrayatt ==
cur->sk_attno)
472 origelemtype, elemtype,
474 elem_values, num_elems))
509 origarrayatt =
cur->sk_attno;
510 origarraykey = numArrayKeys;
511 origelemtype = elemtype;
530 *new_numberOfKeys = output_ikey;
576 for (
int output_ikey = 0; output_ikey < so->
numberOfKeys; output_ikey++)
587 input_ikey = keyDataMap[output_ikey];
589 Assert(last_equal_output_ikey < output_ikey);
590 Assert(last_equal_output_ikey < input_ikey);
591 last_equal_output_ikey = output_ikey;
614 elemtype = rel->rd_opcintype[outkey->
sk_attno - 1];
651 outkey->
sk_flags &= ~SK_SEARCHARRAY;
660 memmove(array, array + 1,
692 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
693 errmsg_internal(
"number of array scan keys left by preprocessing (%d) exceeds the maximum allowed by parallel btree index scans (%d)",
736 if (elemtype == opcintype)
741 *sortprocp = orderproc;
760 elog(
ERROR,
"missing support function %d(%u,%u) for attribute %d of index \"%s\"",
782 elog(
ERROR,
"missing support function %d(%u,%u) for attribute %d of index \"%s\"",
800 Datum *elems,
int nelems)
824 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
825 strat, elemtype, elemtype,
829 elog(
ERROR,
"missing oprcode for operator %u", cmp_op);
835 for (
i = 1;
i < nelems;
i++)
859 Datum *elems,
int nelems)
903 bool reverse,
Oid origelemtype,
Oid nextelemtype,
904 Datum *elems_orig,
int *nelems_orig,
905 Datum *elems_next,
int nelems_next)
910 int nelems_orig_start = *nelems_orig,
911 nelems_orig_merged = 0;
918 if (origelemtype != nextelemtype)
935 mergeproc = &crosstypeproc;
939 cxt.sortproc = mergeproc;
941 cxt.reverse = reverse;
943 for (
int i = 0,
j = 0;
i < nelems_orig_start &&
j < nelems_next;)
945 Datum *oelem = elems_orig +
i,
946 *nelem = elems_next +
j;
951 elems_orig[nelems_orig_merged++] = *oelem;
961 *nelems_orig = nelems_orig_merged;
1022 Oid arraysk_elemtype;
1045 orderprocp = &crosstypeproc;
1052 arraysk, &cmpresult);
1060 if (cmpresult >= cmpexact)
1063 new_nelems = matchelem;
1082 if (cmpresult >= cmpexact)
1085 new_nelems = array->
num_elems - matchelem;
1087 sizeof(
Datum) * new_nelems);
1090 elog(
ERROR,
"unrecognized StrategyNumber: %d",
1096 Assert(new_nelems <= array->num_elems);
1099 *qual_ok = new_nelems > 0;
1141 Datum tupdatum,
bool tupnull,
1171 tupdatum, arrdatum));
1212 Datum tupdatum,
bool tupnull,
1214 int32 *set_elem_result)
1254 if (high_elem >= low_elem)
1263 *set_elem_result = result;
1266 mid_elem = low_elem;
1270 if (high_elem < low_elem)
1273 *set_elem_result = 1;
1282 if (high_elem >= low_elem)
1291 *set_elem_result = result;
1294 mid_elem = high_elem;
1298 if (high_elem < low_elem)
1301 *set_elem_result = -1;
1307 while (high_elem > low_elem)
1309 mid_elem = low_elem + ((high_elem - low_elem) / 2);
1321 low_elem = mid_elem;
1326 low_elem = mid_elem + 1;
1328 high_elem = mid_elem;
1336 if (low_elem != mid_elem)
1340 *set_elem_result = result;
1403 int cur_elem = curArrayKey->
cur_elem;
1405 bool rolled =
false;
1414 cur_elem = num_elems - 1;
1507 if (array->
cur_elem != first_elem_dir)
1560 bool readpagetup,
int sktrig,
bool *scanBehind)
1566 Assert(sktrig == 0 || readpagetup);
1567 Assert(!readpagetup || scanBehind == NULL);
1570 *scanBehind =
false;
1572 for (
int ikey = sktrig; ikey < so->
numberOfKeys; ikey++)
1580 Assert(!readpagetup || ikey == sktrig);
1592 Assert(ikey > sktrig || ikey == 0);
1596 if (
cur->sk_attno > tupnatts)
1652 if (readpagetup || result != 0)
1726 Assert(_bt_verify_arrays_bt_first(scan, dir));
1804 int sktrig,
bool sktrig_required)
1810 bool beyond_end_advance =
false,
1811 has_required_opposite_direction_only =
false,
1812 oppodir_inequality_sktrig =
false,
1813 all_required_satisfied =
true,
1814 all_satisfied =
true;
1822 if (sktrig_required)
1828 tupnatts,
false, 0, NULL));
1849 Assert(_bt_verify_keys_with_arraykeys(scan));
1857 required_opposite_direction_only =
false,
1881 has_required_opposite_direction_only =
1882 required_opposite_direction_only =
true;
1895 if (
cur->sk_attno > tupnatts)
1924 if (ikey == sktrig && !array)
1929 beyond_end_advance =
true;
1930 all_satisfied = all_required_satisfied =
false;
1941 if (
unlikely(required_opposite_direction_only))
1942 oppodir_inequality_sktrig =
true;
1972 if (beyond_end_advance)
1981 if (array && array->
cur_elem != final_elem_dir)
2008 if (!all_required_satisfied ||
cur->sk_attno > tupnatts)
2017 if (array && array->
cur_elem != first_elem_dir)
2034 bool cur_elem_trig = (sktrig_required && ikey == sktrig);
2041 tupdatum, tupnull, array,
cur,
2044 Assert(set_elem >= 0 && set_elem < array->num_elems);
2093 beyond_end_advance =
true;
2095 Assert(all_required_satisfied && all_satisfied);
2104 all_satisfied =
false;
2106 all_required_satisfied =
false;
2121 if (array && array->
cur_elem != set_elem)
2135 goto end_toplevel_scan;
2137 Assert(_bt_verify_keys_with_arraykeys(scan));
2156 if ((sktrig_required && all_required_satisfied) ||
2157 (!sktrig_required && all_satisfied))
2159 int nsktrig = sktrig + 1;
2162 Assert(all_required_satisfied);
2166 false,
false,
false,
2167 &continuescan, &nsktrig) &&
2171 Assert(all_satisfied && continuescan);
2206 Assert(!beyond_end_advance);
2210 tupdesc, nsktrig,
true);
2229 if (!sktrig_required)
2255 !all_required_satisfied);
2265 if (!all_required_satisfied && pstate->
finaltup == tuple)
2276 if (!all_required_satisfied && pstate->
finaltup &&
2310 if (so->
scanBehind && has_required_opposite_direction_only)
2367 else if (has_required_opposite_direction_only && pstate->
finaltup &&
2368 (all_required_satisfied || oppodir_inequality_sktrig) &&
2539 int new_numberOfKeys;
2540 int numberOfEqualCols;
2546 int *keyDataMap = NULL;
2559 Assert(_bt_verify_keys_with_arraykeys(scan));
2567 if (numberOfKeys < 1)
2585 inkeys = arrayKeyData;
2589 numberOfKeys *
sizeof(
int));
2595 if (inkeys[0].sk_attno < 1)
2596 elog(
ERROR,
"btree index keys must be ordered by attribute");
2599 if (numberOfKeys == 1)
2607 if (inkeys[0].sk_attno == 1)
2628 new_numberOfKeys = 0;
2629 numberOfEqualCols = 0;
2638 memset(xform, 0,
sizeof(xform));
2645 for (
int i = 0;;
i++)
2650 if (
i < numberOfKeys)
2665 if (
i == numberOfKeys || inkey->
sk_attno != attno)
2667 int priorNumberOfEqualCols = numberOfEqualCols;
2670 if (i < numberOfKeys && inkey->sk_attno < attno)
2671 elog(
ERROR,
"btree index keys must be ordered by attribute");
2703 array = &so->
arrayKeys[eq_arrayidx - 1];
2736 xform[
j].inkey = NULL;
2737 xform[
j].inkeyi = -1;
2742 numberOfEqualCols++;
2792 keyDataMap[new_numberOfKeys - 1] = xform[
j].inkeyi;
2793 if (priorNumberOfEqualCols == attno - 1)
2801 if (
i == numberOfKeys)
2806 memset(xform, 0,
sizeof(xform));
2819 keyDataMap[new_numberOfKeys - 1] =
i;
2820 if (numberOfEqualCols == attno - 1)
2843 if (xform[
j].inkey == NULL)
2846 xform[
j].inkey = inkey;
2847 xform[
j].inkeyi =
i;
2848 xform[
j].arrayidx = arrayidx;
2874 array = &so->
arrayKeys[xform[
j].arrayidx - 1];
2893 array, orderproc, &test_result))
2906 xform[
j].inkey = inkey;
2907 xform[
j].inkeyi =
i;
2908 xform[
j].arrayidx = arrayidx;
2947 keyDataMap[new_numberOfKeys - 1] = xform[
j].inkeyi;
2948 if (numberOfEqualCols == attno - 1)
2950 xform[
j].inkey = inkey;
2951 xform[
j].inkeyi =
i;
2952 xform[
j].arrayidx = arrayidx;
2971#ifdef USE_ASSERT_CHECKING
3007 if (array->
cur_elem != first_elem_dir)
3011 return _bt_verify_keys_with_arraykeys(scan);
3046 if (last_sk_attno >
cur->sk_attno)
3048 last_sk_attno =
cur->sk_attno;
3146 *result = (leftnull < rightnull);
3149 *result = (leftnull <= rightnull);
3152 *result = (leftnull == rightnull);
3155 *result = (leftnull >= rightnull);
3158 *result = (leftnull > rightnull);
3161 elog(
ERROR,
"unrecognized StrategyNumber: %d", (
int) strat);
3188 if (leftarray && rightarray)
3202 orderproc, array, result);
3203 else if (rightarray)
3205 orderproc, array, result);
3224 lefttype = opcintype;
3227 righttype = opcintype;
3236 if (lefttype == opcintype && righttype == optype)
3424 elog(
ERROR,
"unrecognized StrategyNumber: %d",
3491#ifdef USE_ASSERT_CHECKING
3502 tupnatts,
false, 0, NULL));
3514 false,
false,
false,
3515 &dcontinuescan, &dikey));
3645 false,
false,
false, &continuescan, &ikey);
3694 bool advancenonrequired,
bool prechecked,
bool firstmatch,
3695 bool *continuescan,
int *ikey)
3699 *continuescan =
true;
3706 bool requiredSameDir =
false,
3707 requiredOppositeDirOnly =
false;
3715 requiredSameDir =
true;
3718 requiredOppositeDirOnly =
true;
3737 (requiredSameDir || (requiredOppositeDirOnly && firstmatch)) &&
3741 if (
key->sk_attno > tupnatts)
3787 if (requiredSameDir)
3788 *continuescan =
false;
3814 *continuescan =
false;
3832 *continuescan =
false;
3848 if (!(requiredOppositeDirOnly && firstmatch) &&
3850 datum,
key->sk_argument)))
3862 if (requiredSameDir)
3863 *continuescan =
false;
3871 else if (advancenonrequired &&
3875 tupdesc, *ikey,
false);
3902 int32 cmpresult = 0;
3955 *continuescan =
false;
3973 *continuescan =
false;
3994 *continuescan =
false;
3997 *continuescan =
false;
4028 result = (cmpresult < 0);
4031 result = (cmpresult <= 0);
4034 result = (cmpresult >= 0);
4037 result = (cmpresult > 0);
4055 *continuescan =
false;
4058 *continuescan =
false;
4131 pstate->
skip = aheadoffnum + 1;
4133 pstate->
skip = aheadoffnum - 1;
4190 bool killedsomething =
false;
4237 for (
i = 0;
i < numKilled;
i++)
4244 itemIndex <= so->currPos.lastItem);
4245 if (offnum < minoff)
4247 while (offnum <= maxoff)
4251 bool killtuple =
false;
4273 for (
j = 0;
j < nposting;
j++)
4332 killedsomething =
true;
4346 if (killedsomething)
4462 elog(
ERROR,
"multiple active vacuums for index \"%s\"",
4572 offsetof(
BTOptions, vacuum_cleanup_index_scale_factor)},
4592 bool *
res,
bool *isnull)
4618 return "initializing";
4620 return "scanning table";
4622 return "sorting live tuples";
4624 return "sorting dead tuples";
4626 return "loading tuples in tree";
4681#ifdef DEBUG_NO_TRUNCATE
4683 keepnatts = nkeyatts + 1;
4687 Min(keepnatts, nkeyatts));
4696 Assert(keepnatts == nkeyatts || keepnatts == nkeyatts + 1);
4698 pivot->
t_info &= ~INDEX_SIZE_MASK;
4706 if (keepnatts <= nkeyatts)
4735 tidpivot->
t_info &= ~INDEX_SIZE_MASK;
4736 tidpivot->
t_info |= newsize;
4759#ifndef DEBUG_NO_TRUNCATE
4834 if (isNull1 != isNull2)
4899 if (isNull1 != isNull2)
4979 return tupnatts == natts;
4995 return tupnatts == nkeyatts;
5011 return tupnatts == 0;
5025 return tupnatts == 0 ||
5037 return tupnatts == nkeyatts;
5071 return tupnatts > 0 && tupnatts <= nkeyatts;
5113 elog(
ERROR,
"cannot insert oversized tuple of size %zu on internal page of index \"%s\"",
5117 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5118 errmsg(
"index row size %zu exceeds btree version %u maximum %zu for index \"%s\"",
5124 errdetail(
"Index row references tuple (%u,%u) in relation \"%s\".",
5128 errhint(
"Values larger than 1/3 of a buffer page cannot be indexed.\n"
5129 "Consider a function index of an MD5 hash of the value, "
5130 "or use full text indexing."),
5147 bool allequalimage =
true;
5172 allequalimage =
false;
5180 elog(
DEBUG1,
"index \"%s\" can safely use deduplication",
5183 elog(
DEBUG1,
"index \"%s\" cannot use deduplication",
5187 return allequalimage;
#define DatumGetArrayTypeP(X)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define InvalidAttrNumber
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
static Page BufferGetPage(Buffer buffer)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define RegProcedureIsValid(p)
#define INVERT_COMPARE_RESULT(var)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define OidIsValid(objectId)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
static void PGresult * res
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#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)
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
static int compare(const void *arg1, const void *arg2)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source, int leavenatts)
if(TABLE==NULL||TABLE_index==NULL)
#define ItemIdMarkDead(itemId)
#define ItemIdIsDead(itemId)
int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
static void ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static OffsetNumber ItemPointerGetOffsetNumberNoCheck(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
static void ItemPointerCopy(const ItemPointerData *fromPointer, ItemPointerData *toPointer)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
#define MaxIndexTuplesPerPage
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)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
void _bt_relbuf(Relation rel, Buffer buf)
void _bt_metaversion(Relation rel, bool *heapkeyspace, bool *allequalimage)
Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access)
void _bt_unlockbuf(Relation rel, Buffer buf)
void _bt_lockbuf(Relation rel, Buffer buf, int access)
void _bt_parallel_primscan_schedule(IndexScanDesc scan, BlockNumber curr_page)
void _bt_parallel_done(IndexScanDesc scan)
#define BTScanPosIsPinned(scanpos)
#define BT_PIVOT_HEAP_TID_ATTR
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
#define PROGRESS_BTREE_PHASE_PERFORMSORT_2
#define BTMaxItemSizeNoHeapTid(page)
#define PROGRESS_BTREE_PHASE_LEAF_LOAD
#define BTEQUALIMAGE_PROC
#define BTPageGetOpaque(page)
#define BTScanPosIsValid(scanpos)
#define PROGRESS_BTREE_PHASE_INDEXBUILD_TABLESCAN
#define SK_BT_INDOPTION_SHIFT
#define P_FIRSTDATAKEY(opaque)
#define PROGRESS_BTREE_PHASE_PERFORMSORT_1
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
#define P_RIGHTMOST(opaque)
#define BTMaxItemSize(page)
#define SK_BT_NULLS_FIRST
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
#define BTCommuteStrategyNumber(strat)
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTREE_NOVAC_VERSION
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
static void BTreeTupleSetNAtts(IndexTuple itup, uint16 nkeyatts, bool heaptid)
#define BTreeTupleGetNAtts(itup, rel)
BTScanOpaqueData * BTScanOpaque
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_rewind_nonrequired_arrays(IndexScanDesc scan, ScanDirection dir)
void _bt_check_third_page(Relation rel, Relation heap, bool needheaptidspace, Page page, IndexTuple newtup)
static bool _bt_check_compare(IndexScanDesc scan, ScanDirection dir, IndexTuple tuple, int tupnatts, TupleDesc tupdesc, bool advancenonrequired, bool prechecked, bool firstmatch, bool *continuescan, int *ikey)
void _bt_end_vacuum(Relation rel)
bool _bt_checkkeys(IndexScanDesc scan, BTReadPageState *pstate, bool arrayKeys, IndexTuple tuple, int tupnatts)
void _bt_end_vacuum_callback(int code, Datum arg)
static 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)
struct BTScanKeyPreproc BTScanKeyPreproc
void _bt_freestack(BTStack stack)
void BTreeShmemInit(void)
struct BTSortArrayContext BTSortArrayContext
static Datum _bt_find_extreme_element(IndexScanDesc scan, ScanKey skey, Oid elemtype, StrategyNumber strat, Datum *elems, int nelems)
struct BTVacInfo BTVacInfo
BTCycleId _bt_vacuum_cycleid(Relation rel)
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
void _bt_killitems(IndexScanDesc scan)
static bool _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate, IndexTuple tuple, int tupnatts, TupleDesc tupdesc, int sktrig, bool sktrig_required)
bool _bt_start_prim_scan(IndexScanDesc scan, ScanDirection dir)
static bool _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption)
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
IndexTuple _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
#define LOOK_AHEAD_REQUIRED_RECHECKS
int _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
#define LOOK_AHEAD_DEFAULT_DISTANCE
static BTVacInfo * btvacinfo
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)
char * btbuildphasename(int64 phasenum)
static bool _bt_tuple_before_array_skeys(IndexScanDesc scan, ScanDirection dir, IndexTuple tuple, TupleDesc tupdesc, int tupnatts, bool readpagetup, int sktrig, bool *scanBehind)
bytea * btoptions(Datum reloptions, bool validate)
static bool _bt_advance_array_keys_increment(IndexScanDesc scan, ScanDirection dir)
Size BTreeShmemSize(void)
static void _bt_setup_array_cmp(IndexScanDesc scan, ScanKey skey, Oid elemtype, FmgrInfo *orderproc, FmgrInfo **sortprocp)
static int _bt_keep_natts(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
static int _bt_sort_array_elements(ScanKey skey, FmgrInfo *sortproc, bool reverse, Datum *elems, int nelems)
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
static bool _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, ScanKey leftarg, ScanKey rightarg, BTArrayKeyInfo *array, FmgrInfo *orderproc, bool *result)
bool _bt_allequalimage(Relation rel, bool debugmessage)
static bool _bt_compare_array_scankey_args(IndexScanDesc scan, ScanKey arraysk, ScanKey skey, FmgrInfo *orderproc, BTArrayKeyInfo *array, bool *qual_ok)
static void _bt_checkkeys_look_ahead(IndexScanDesc scan, BTReadPageState *pstate, int tupnatts, TupleDesc tupdesc)
static int32 _bt_compare_array_skey(FmgrInfo *orderproc, Datum tupdatum, bool tupnull, Datum arrdatum, ScanKey cur)
struct BTOneVacInfo BTOneVacInfo
void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir)
void _bt_preprocess_keys(IndexScanDesc scan)
static bool _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts, TupleDesc tupdesc, ScanDirection dir, bool *continuescan)
bool _bt_oppodir_checkkeys(IndexScanDesc scan, ScanDirection dir, IndexTuple finaltup)
BTCycleId _bt_start_vacuum(Relation rel)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#define OffsetNumberPrev(offsetNumber)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
static bool DatumGetBool(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
#define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE
static size_t qunique_arg(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *, void *), void *arg)
MemoryContextSwitchTo(old_ctx)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfAttributes(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
int errtableconstraint(Relation rel, const char *conname)
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
void ScanKeyEntryInitializeWithInfo(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, FmgrInfo *finfo, Datum argument)
#define ScanDirectionIsForward(direction)
#define ScanDirectionIsBackward(direction)
#define ScanDirectionIsNoMovement(direction)
@ NoMovementScanDirection
Size add_size(Size s1, Size s2)
Size mul_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
static pg_noinline void Size size
#define BTGreaterStrategyNumber
#define BTMaxStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
ScanKeyData scankeys[INDEX_MAX_KEYS]
BTArrayKeyInfo * arrayKeys
MemoryContext arrayContext
BTScanPosItem items[MaxTIDsPerBTreePage]
struct BTStackData * bts_parent
BTOneVacInfo vacuums[FLEXIBLE_ARRAY_MEMBER]
struct ScanKeyData * keyData
struct ParallelIndexScanDescData * parallel_scan
StrategyNumber sk_strategy
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)