88 key->heapkeyspace =
true;
89 key->allequalimage =
false;
91 key->anynullkeys =
false;
93 key->backward =
false;
94 key->keysz =
Min(indnkeyatts, tupnatts);
95 key->scantid =
key->heapkeyspace && itup ?
98 for (
i = 0;
i < indnkeyatts;
i++)
134 key->anynullkeys =
true;
141 if (rel->
rd_index->indnullsnotdistinct)
142 key->anynullkeys =
false;
155 while (stack != NULL)
169 int a = *((
const int *) va);
170 int b = *((
const int *) vb);
214 bool killedsomething =
false;
276 for (
int i = 0;
i < numKilled;
i++)
283 itemIndex <= so->currPos.lastItem);
289 while (offnum <= maxoff)
293 bool killtuple =
false;
307 for (
j = 0;
j < nposting;
j++)
366 killedsomething =
true;
499 elog(
ERROR,
"multiple active vacuums for index \"%s\"",
609 offsetof(
BTOptions, vacuum_cleanup_index_scale_factor)},
629 bool *res,
bool *isnull)
655 return "initializing";
657 return "scanning table";
659 return "sorting live tuples";
661 return "sorting dead tuples";
663 return "loading tuples in tree";
718#ifdef DEBUG_NO_TRUNCATE
720 keepnatts = nkeyatts + 1;
724 Min(keepnatts, nkeyatts));
733 Assert(keepnatts == nkeyatts || keepnatts == nkeyatts + 1);
735 pivot->
t_info &= ~INDEX_SIZE_MASK;
743 if (keepnatts <= nkeyatts)
772 tidpivot->
t_info &= ~INDEX_SIZE_MASK;
773 tidpivot->
t_info |= newsize;
796#ifndef DEBUG_NO_TRUNCATE
871 if (isNull1 != isNull2)
936 if (isNull1 != isNull2)
1016 return tupnatts == natts;
1032 return tupnatts == nkeyatts;
1048 return tupnatts == 0;
1062 return tupnatts == 0 ||
1074 return tupnatts == nkeyatts;
1108 return tupnatts > 0 && tupnatts <= nkeyatts;
1150 elog(
ERROR,
"cannot insert oversized tuple of size %zu on internal page of index \"%s\"",
1154 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1155 errmsg(
"index row size %zu exceeds btree version %u maximum %zu for index \"%s\"",
1160 errdetail(
"Index row references tuple (%u,%u) in relation \"%s\".",
1164 errhint(
"Values larger than 1/3 of a buffer page cannot be indexed.\n"
1165 "Consider a function index of an MD5 hash of the value, "
1166 "or use full text indexing."),
1183 bool allequalimage =
true;
1208 allequalimage =
false;
1216 elog(
DEBUG1,
"index \"%s\" can safely use deduplication",
1219 elog(
DEBUG1,
"index \"%s\" cannot use deduplication",
1223 return allequalimage;
static bool validate(Port *port, const char *auth)
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
static Page BufferGetPage(Buffer buffer)
static void * PageGetItem(const PageData *page, const ItemIdData *itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
#define FLEXIBLE_ARRAY_MEMBER
#define OidIsValid(objectId)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
Assert(PointerIsAligned(start, uint64))
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source, int leavenatts)
static int pg_cmp_s32(int32 a, int32 b)
#define ItemIdMarkDead(itemId)
#define ItemIdIsDead(itemId)
int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *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
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static Size IndexTupleSize(const IndexTupleData *itup)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void pfree(void *pointer)
void * palloc0(Size size)
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)
#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 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)
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTREE_NOVAC_VERSION
#define BTMaxItemSizeNoHeapTid
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
static void BTreeTupleSetNAtts(IndexTuple itup, uint16 nkeyatts, bool heaptid)
#define BTreeTupleGetNAtts(itup, rel)
BTScanOpaqueData * BTScanOpaque
void _bt_check_third_page(Relation rel, Relation heap, bool needheaptidspace, Page page, IndexTuple newtup)
void _bt_end_vacuum(Relation rel)
void _bt_end_vacuum_callback(int code, Datum arg)
void _bt_freestack(BTStack stack)
void BTreeShmemInit(void)
struct BTVacInfo BTVacInfo
BTCycleId _bt_vacuum_cycleid(Relation rel)
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
void _bt_killitems(IndexScanDesc scan)
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
IndexTuple _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
int _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
static BTVacInfo * btvacinfo
char * btbuildphasename(int64 phasenum)
bytea * btoptions(Datum reloptions, bool validate)
Size BTreeShmemSize(void)
static int _bt_keep_natts(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
bool _bt_allequalimage(Relation rel, bool debugmessage)
static int _bt_compare_int(const void *va, const void *vb)
struct BTOneVacInfo BTOneVacInfo
BTCycleId _bt_start_vacuum(Relation rel)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#define OffsetNumberPrev(offsetNumber)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define qsort(a, b, c, d)
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(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(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)
Size add_size(Size s1, Size s2)
Size mul_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
ScanKeyData scankeys[INDEX_MAX_KEYS]
BTScanPosItem items[MaxTIDsPerBTreePage]
struct BTStackData * bts_parent
BTOneVacInfo vacuums[FLEXIBLE_ARRAY_MEMBER]
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)