14 #ifndef GIST_PRIVATE_H
15 #define GIST_PRIVATE_H
40 #define GIST_MAX_SPLIT_PAGES 75
43 #define GIST_SHARE BUFFER_LOCK_SHARE
44 #define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE
45 #define GIST_UNLOCK BUFFER_LOCK_UNLOCK
51 char tupledata[FLEXIBLE_ARRAY_MEMBER];
54 #define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
56 #define PAGE_FREE_SPACE(nbp) (nbp->freespace)
58 #define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)
60 #define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \
61 MAXALIGN(IndexTupleSize(itup)))
147 #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
149 #define SizeOfGISTSearchItem(n_distances) (offsetof(GISTSearchItem, distances) + sizeof(double) * (n_distances))
186 #define XLOG_GIST_PAGE_UPDATE 0x00
188 #define XLOG_GIST_PAGE_SPLIT 0x30
190 #define XLOG_GIST_CREATE_INDEX 0x50
297 #define GIST_ROOT_BLKNO 0
320 #define TUPLE_IS_VALID 0xffff
321 #define TUPLE_IS_INVALID 0xfffe
323 #define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
324 #define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
354 #define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
355 ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
356 (nlevel) != (gfbb)->rootlevel)
359 #define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
360 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
367 #define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
368 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
482 #define GiSTPageSize \
483 ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
485 #define GIST_MIN_FILLFACTOR 10
486 #define GIST_DEFAULT_FILLFACTOR 90
517 bool l,
bool isNull);
523 Datum *attr,
bool *isnull);
532 Datum *dst,
bool *dstisnull);
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
struct gistxlogPage gistxlogPage
Buffer gistNewBuffer(Relation r)
Datum gistbuild(PG_FUNCTION_ARGS)
Datum spl_lattr[INDEX_MAX_KEYS]
struct GISTSTATE GISTSTATE
struct GISTSearchItem GISTSearchItem
Datum gistcanreturn(PG_FUNCTION_ARGS)
OffsetNumber * killedItems
FmgrInfo fetchFn[INDEX_MAX_KEYS]
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber blkno, int level)
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
struct gistxlogPageSplit gistxlogPageSplit
Oid supportCollation[INDEX_MAX_KEYS]
FmgrInfo compressFn[INDEX_MAX_KEYS]
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)
FmgrInfo equalFn[INDEX_MAX_KEYS]
MemoryContext createTempGistContext(void)
struct gistxlogPageUpdate gistxlogPageUpdate
GIST_SPLITVEC splitVector
Datum gistinsert(PG_FUNCTION_ARGS)
void gist_xlog_cleanup(void)
MemoryContext pageDataCxt
struct GiSTOptions GiSTOptions
Datum spl_rattr[INDEX_MAX_KEYS]
struct GISTScanOpaqueData GISTScanOpaqueData
double distances[FLEXIBLE_ARRAY_MEMBER]
GISTNodeBufferPage * pageBuffer
struct GistSplitVector GistSplitVector
FmgrInfo consistentFn[INDEX_MAX_KEYS]
void gistValidateBufferingOption(char *value)
List * bufferEmptyingQueue
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
GISTScanOpaqueData * GISTScanOpaque
void GISTInitBuffer(Buffer b, uint32 f)
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple item)
Datum gistgetbitmap(PG_FUNCTION_ARGS)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *key1, bool isNull1, GISTENTRY *key2, bool isNull2)
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *item)
XLogRecPtr gistGetFakeLSN(Relation rel)
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
bool gistfitpage(IndexTuple *itvec, int len)
struct SplitedPageLayout * next
GISTSTATE * initGISTstate(Relation index)
FmgrInfo decompressFn[INDEX_MAX_KEYS]
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
XLogRecPtr gistXLogSplit(RelFileNode node, BlockNumber blkno, bool page_is_leaf, SplitedPageLayout *dist, BlockNumber origrlink, GistNSN oldnsn, Buffer leftchild, bool markfollowright)
Datum gistgettuple(PG_FUNCTION_ARGS)
OffsetNumber downlinkoffnum
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
struct IndexTupleData IndexTupleData
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
IndexTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
SplitedPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
XLogRecPtr gistXLogUpdate(RelFileNode node, Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ntup, Buffer leftchild)
void freeGISTstate(GISTSTATE *giststate)
Datum gistvacuumcleanup(PG_FUNCTION_ARGS)
const char * gist_identify(uint8 info)
struct SplitedPageLayout SplitedPageLayout
void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)
GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]
Datum gistbulkdelete(PG_FUNCTION_ARGS)
FmgrInfo distanceFn[INDEX_MAX_KEYS]
GISTNodeBuffer ** loadedBuffers
bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, Buffer buffer, IndexTuple *itup, int ntup, OffsetNumber oldoffnum, BlockNumber *newblkno, Buffer leftchildbuf, List **splitinfo, bool markleftchild)
bool spl_risnull[INDEX_MAX_KEYS]
IndexTuple * gistextractpage(Page page, int *len)
union GISTSearchItem::@35 data
struct GISTSearchHeapItem GISTSearchHeapItem
struct GISTBuildBuffers GISTBuildBuffers
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *GISTstate)
Datum gistoptions(PG_FUNCTION_ARGS)
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
Datum gistbuildempty(PG_FUNCTION_ARGS)
bool spl_lisnull[INDEX_MAX_KEYS]
FmgrInfo unionFn[INDEX_MAX_KEYS]
struct GISTInsertStack * parent
void gist_redo(XLogReaderState *record)
struct GISTInsertStack GISTInsertStack
void gistcheckpage(Relation rel, Buffer buf)
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf)
void gist_desc(StringInfo buf, XLogReaderState *record)
void gist_xlog_startup(void)