39#define GIST_MAX_SPLIT_PAGES 75
42#define GIST_SHARE BUFFER_LOCK_SHARE
43#define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE
44#define GIST_UNLOCK BUFFER_LOCK_UNLOCK
53#define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
55#define PAGE_FREE_SPACE(nbp) (nbp->freespace)
57#define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)
59#define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \
60 MAXALIGN(IndexTupleSize(itup)))
145#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
147#define SizeOfGISTSearchItem(n_distances) \
148 (offsetof(GISTSearchItem, distances) + \
149 sizeof(IndexOrderByDistance) * (n_distances))
262#define GIST_ROOT_BLKNO 0
285#define TUPLE_IS_VALID 0xffff
286#define TUPLE_IS_INVALID 0xfffe
288#define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
289#define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
319#define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
320 ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
321 (nlevel) != (gfbb)->rootlevel)
324#define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
325 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
332#define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
333 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
431 bool markfollowright,
458 Buffer leftchildbuf,
bool markfollowright);
476#define GiSTPageSize \
477 ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
479#define GIST_MIN_FILLFACTOR 10
480#define GIST_DEFAULT_FILLFACTOR 90
485 bool *res,
bool *isnull);
505 Relation r,
const Datum *attdata,
const bool *isnull,
bool isleaf);
507 const Datum *attdata,
const bool *isnull,
bool isleaf,
Datum *compatt);
517 bool l,
bool isNull);
523 Datum *attr,
bool *isnull);
532 Datum *dst,
bool *dstisnull);
540 void *callback_state);
static bool validate(Port *port, const char *auth)
static Datum values[MAXATTR]
#define FLEXIBLE_ARRAY_MEMBER
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
SplitPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
GISTSTATE * initGISTstate(Relation index)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
bytea * gistoptions(Datum reloptions, bool validate)
void gistadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple itup)
bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
XLogRecPtr gistXLogAssignLSN(void)
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate, Relation heapRel, bool is_build)
struct SplitPageLayout SplitPageLayout
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
Buffer gistNewBuffer(Relation r, Relation heaprel)
bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
struct GISTSearchHeapItem GISTSearchHeapItem
XLogRecPtr gistXLogSplit(bool page_is_leaf, SplitPageLayout *dist, BlockNumber origrlink, GistNSN orignsn, Buffer leftchildbuf, bool markfollowright)
bool gistPageRecyclable(Page page)
void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)
XLogRecPtr gistXLogPageDelete(Buffer buffer, FullTransactionId xid, Buffer parentBuffer, OffsetNumber downlinkOffset)
IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete, TransactionId snapshotConflictHorizon, Relation heaprel)
bool gistvalidate(Oid opclassoid)
bool gistgettuple(IndexScanDesc scan, ScanDirection dir)
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, Buffer buffer, IndexTuple *itup, int ntup, OffsetNumber oldoffnum, BlockNumber *newblkno, Buffer leftchildbuf, List **splitinfo, bool markfollowright, Relation heapRel, bool is_build)
HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
void gistbuildempty(Relation index)
@ GIST_OPTION_BUFFERING_OFF
@ GIST_OPTION_BUFFERING_AUTO
@ GIST_OPTION_BUFFERING_ON
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf)
struct GISTSearchItem GISTSearchItem
IndexTuple * gistextractpage(Page page, int *len)
struct GISTScanOpaqueData GISTScanOpaqueData
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
GISTScanOpaqueData * GISTScanOpaque
bool gistfitpage(IndexTuple *itvec, int len)
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
MemoryContext createTempGistContext(void)
void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)
struct GISTInsertStack GISTInsertStack
XLogRecPtr gistGetFakeLSN(Relation rel)
struct GISTSTATE GISTSTATE
void gistCompressValues(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt)
void gistXLogPageReuse(Relation rel, Relation heaprel, BlockNumber blkno, FullTransactionId deleteXid)
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
bool gistcanreturn(Relation index, int attno)
XLogRecPtr gistXLogUpdate(Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ituplen, Buffer leftchildbuf)
void freeGISTstate(GISTSTATE *giststate)
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *itup)
IndexBulkDeleteResult * gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
struct GistSplitVector GistSplitVector
void gistinitpage(Page page, uint32 f)
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber nodeBlocknum, int level)
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
struct GiSTOptions GiSTOptions
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
void GISTInitBuffer(Buffer b, uint32 f)
struct gistxlogPage gistxlogPage
void gistcheckpage(Relation rel, Buffer buf)
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
struct GISTBuildBuffers GISTBuildBuffers
struct IndexTupleData IndexTupleData
static const struct fns functions
GISTNodeBuffer ** loadedBuffers
List * bufferEmptyingQueue
OffsetNumber downlinkoffnum
struct GISTInsertStack * parent
GISTNodeBufferPage * pageBuffer
FmgrInfo fetchFn[INDEX_MAX_KEYS]
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Oid supportCollation[INDEX_MAX_KEYS]
FmgrInfo distanceFn[INDEX_MAX_KEYS]
FmgrInfo consistentFn[INDEX_MAX_KEYS]
FmgrInfo decompressFn[INDEX_MAX_KEYS]
FmgrInfo compressFn[INDEX_MAX_KEYS]
FmgrInfo equalFn[INDEX_MAX_KEYS]
FmgrInfo unionFn[INDEX_MAX_KEYS]
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
OffsetNumber * killedItems
GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]
IndexOrderByDistance * distances
MemoryContext pageDataCxt
IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER]
union GISTSearchItem::@45 data
GistOptBufferingMode buffering_mode
GIST_SPLITVEC splitVector
Datum spl_lattr[INDEX_MAX_KEYS]
bool spl_lisnull[INDEX_MAX_KEYS]
Datum spl_rattr[INDEX_MAX_KEYS]
bool spl_risnull[INDEX_MAX_KEYS]
struct SplitPageLayout * next
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)