gist_private.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*-------------------------------------------------------------------------
  2. *
  3. * gist_private.h
  4. * private declarations for GiST -- declarations related to the
  5. * internal implementation of GiST, not the public API
  6. *
  7. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/access/gist_private.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef GIST_PRIVATE_H
  15. #define GIST_PRIVATE_H
  16. #include "access/amapi.h"
  17. #include "access/gist.h"
  18. #include "access/itup.h"
  19. #include "lib/pairingheap.h"
  20. #include "storage/bufmgr.h"
  21. #include "storage/buffile.h"
  22. #include "utils/hsearch.h"
  23. #include "access/genam.h"
  24. /*
  25. * Maximum number of "halves" a page can be split into in one operation.
  26. * Typically a split produces 2 halves, but can be more if keys have very
  27. * different lengths, or when inserting multiple keys in one operation (as
  28. * when inserting downlinks to an internal node). There is no theoretical
  29. * limit on this, but in practice if you get more than a handful page halves
  30. * in one split, there's something wrong with the opclass implementation.
  31. * GIST_MAX_SPLIT_PAGES is an arbitrary limit on that, used to size some
  32. * local arrays used during split. Note that there is also a limit on the
  33. * number of buffers that can be held locked at a time, MAX_SIMUL_LWLOCKS,
  34. * so if you raise this higher than that limit, you'll just get a different
  35. * error.
  36. */
  37. #define GIST_MAX_SPLIT_PAGES 75
  38. /* Buffer lock modes */
  39. #define GIST_SHARE BUFFER_LOCK_SHARE
  40. #define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE
  41. #define GIST_UNLOCK BUFFER_LOCK_UNLOCK
  42. typedef struct
  43. {
  44. BlockNumber prev;
  45. uint32 freespace;
  46. char tupledata[FLEXIBLE_ARRAY_MEMBER];
  47. } GISTNodeBufferPage;
  48. #define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
  49. /* Returns free space in node buffer page */
  50. #define PAGE_FREE_SPACE(nbp) (nbp->freespace)
  51. /* Checks if node buffer page is empty */
  52. #define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)
  53. /* Checks if node buffers page don't contain sufficient space for index tuple */
  54. #define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \
  55. MAXALIGN(IndexTupleSize(itup)))
  56. /*
  57. * GISTSTATE: information needed for any GiST index operation
  58. *
  59. * This struct retains call info for the index's opclass-specific support
  60. * functions (per index column), plus the index's tuple descriptor.
  61. *
  62. * scanCxt holds the GISTSTATE itself as well as any data that lives for the
  63. * lifetime of the index operation. We pass this to the support functions
  64. * via fn_mcxt, so that they can store scan-lifespan data in it. The
  65. * functions are invoked in tempCxt, which is typically short-lifespan
  66. * (that is, it's reset after each tuple). However, tempCxt can be the same
  67. * as scanCxt if we're not bothering with per-tuple context resets.
  68. */
  69. typedef struct GISTSTATE
  70. {
  71. MemoryContext scanCxt; /* context for scan-lifespan data */
  72. MemoryContext tempCxt; /* short-term context for calling functions */
  73. TupleDesc leafTupdesc; /* index's tuple descriptor */
  74. TupleDesc nonLeafTupdesc; /* truncated tuple descriptor for non-leaf
  75. * pages */
  76. TupleDesc fetchTupdesc; /* tuple descriptor for tuples returned in an
  77. * index-only scan */
  78. FmgrInfo consistentFn[INDEX_MAX_KEYS];
  79. FmgrInfo unionFn[INDEX_MAX_KEYS];
  80. FmgrInfo compressFn[INDEX_MAX_KEYS];
  81. FmgrInfo decompressFn[INDEX_MAX_KEYS];
  82. FmgrInfo penaltyFn[INDEX_MAX_KEYS];
  83. FmgrInfo picksplitFn[INDEX_MAX_KEYS];
  84. FmgrInfo equalFn[INDEX_MAX_KEYS];
  85. FmgrInfo distanceFn[INDEX_MAX_KEYS];
  86. FmgrInfo fetchFn[INDEX_MAX_KEYS];
  87. /* Collations to pass to the support functions */
  88. Oid supportCollation[INDEX_MAX_KEYS];
  89. } GISTSTATE;
  90. /*
  91. * During a GiST index search, we must maintain a queue of unvisited items,
  92. * which can be either individual heap tuples or whole index pages. If it
  93. * is an ordered search, the unvisited items should be visited in distance
  94. * order. Unvisited items at the same distance should be visited in
  95. * depth-first order, that is heap items first, then lower index pages, then
  96. * upper index pages; this rule avoids doing extra work during a search that
  97. * ends early due to LIMIT.
  98. *
  99. * To perform an ordered search, we use a pairing heap to manage the
  100. * distance-order queue. In a non-ordered search (no order-by operators),
  101. * we use it to return heap tuples before unvisited index pages, to
  102. * ensure depth-first order, but all entries are otherwise considered
  103. * equal.
  104. */
  105. /* Individual heap tuple to be visited */
  106. typedef struct GISTSearchHeapItem
  107. {
  108. ItemPointerData heapPtr;
  109. bool recheck; /* T if quals must be rechecked */
  110. bool recheckDistances; /* T if distances must be rechecked */
  111. HeapTuple recontup; /* data reconstructed from the index, used in
  112. * index-only scans */
  113. OffsetNumber offnum; /* track offset in page to mark tuple as
  114. * LP_DEAD */
  115. } GISTSearchHeapItem;
  116. /* Unvisited item, either index page or heap tuple */
  117. typedef struct GISTSearchItem
  118. {
  119. pairingheap_node phNode;
  120. BlockNumber blkno; /* index page number, or InvalidBlockNumber */
  121. union
  122. {
  123. GistNSN parentlsn; /* parent page's LSN, if index page */
  124. /* we must store parentlsn to detect whether a split occurred */
  125. GISTSearchHeapItem heap; /* heap info, if heap tuple */
  126. } data;
  127. /* numberOfOrderBys entries */
  128. IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER];
  129. } GISTSearchItem;
  130. #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
  131. #define SizeOfGISTSearchItem(n_distances) \
  132. (offsetof(GISTSearchItem, distances) + \
  133. sizeof(IndexOrderByDistance) * (n_distances))
  134. /*
  135. * GISTScanOpaqueData: private state for a scan of a GiST index
  136. */
  137. typedef struct GISTScanOpaqueData
  138. {
  139. GISTSTATE *giststate; /* index information, see above */
  140. Oid *orderByTypes; /* datatypes of ORDER BY expressions */
  141. pairingheap *queue; /* queue of unvisited items */
  142. MemoryContext queueCxt; /* context holding the queue */
  143. bool qual_ok; /* false if qual can never be satisfied */
  144. bool firstCall; /* true until first gistgettuple call */
  145. /* pre-allocated workspace arrays */
  146. IndexOrderByDistance *distances; /* output area for gistindex_keytest */
  147. /* info about killed items if any (killedItems is NULL if never used) */
  148. OffsetNumber *killedItems; /* offset numbers of killed items */
  149. int numKilled; /* number of currently stored items */
  150. BlockNumber curBlkno; /* current number of block */
  151. GistNSN curPageLSN; /* pos in the WAL stream when page was read */
  152. /* In a non-ordered search, returnable heap items are stored here: */
  153. GISTSearchHeapItem pageData[BLCKSZ / sizeof(IndexTupleData)];
  154. OffsetNumber nPageData; /* number of valid items in array */
  155. OffsetNumber curPageData; /* next item to return */
  156. MemoryContext pageDataCxt; /* context holding the fetched tuples, for
  157. * index-only scans */
  158. } GISTScanOpaqueData;
  159. typedef GISTScanOpaqueData *GISTScanOpaque;
  160. /* despite the name, gistxlogPage is not part of any xlog record */
  161. typedef struct gistxlogPage
  162. {
  163. BlockNumber blkno;
  164. int num; /* number of index tuples following */
  165. } gistxlogPage;
  166. /* SplitedPageLayout - gistSplit function result */
  167. typedef struct SplitedPageLayout
  168. {
  169. gistxlogPage block;
  170. IndexTupleData *list;
  171. int lenlist;
  172. IndexTuple itup; /* union key for page */
  173. Page page; /* to operate */
  174. Buffer buffer; /* to write after all proceed */
  175. struct SplitedPageLayout *next;
  176. } SplitedPageLayout;
  177. /*
  178. * GISTInsertStack used for locking buffers and transfer arguments during
  179. * insertion
  180. */
  181. typedef struct GISTInsertStack
  182. {
  183. /* current page */
  184. BlockNumber blkno;
  185. Buffer buffer;
  186. Page page;
  187. /*
  188. * log sequence number from page->lsn to recognize page update and compare
  189. * it with page's nsn to recognize page split
  190. */
  191. GistNSN lsn;
  192. /*
  193. * If set, we split the page while descending the tree to find an
  194. * insertion target. It means that we need to retry from the parent,
  195. * because the downlink of this page might no longer cover the new key.
  196. */
  197. bool retry_from_parent;
  198. /* offset of the downlink in the parent page, that points to this page */
  199. OffsetNumber downlinkoffnum;
  200. /* pointer to parent */
  201. struct GISTInsertStack *parent;
  202. } GISTInsertStack;
  203. /* Working state and results for multi-column split logic in gistsplit.c */
  204. typedef struct GistSplitVector
  205. {
  206. GIST_SPLITVEC splitVector; /* passed to/from user PickSplit method */
  207. Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
  208. * splitVector.spl_left */
  209. bool spl_lisnull[INDEX_MAX_KEYS];
  210. Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
  211. * splitVector.spl_right */
  212. bool spl_risnull[INDEX_MAX_KEYS];
  213. bool *spl_dontcare; /* flags tuples which could go to either side
  214. * of the split for zero penalty */
  215. } GistSplitVector;
  216. typedef struct
  217. {
  218. Relation r;
  219. Relation heapRel;
  220. Size freespace; /* free space to be left */
  221. bool is_build;
  222. GISTInsertStack *stack;
  223. } GISTInsertState;
  224. /* root page of a gist index */
  225. #define GIST_ROOT_BLKNO 0
  226. /*
  227. * Before PostgreSQL 9.1, we used to rely on so-called "invalid tuples" on
  228. * inner pages to finish crash recovery of incomplete page splits. If a crash
  229. * happened in the middle of a page split, so that the downlink pointers were
  230. * not yet inserted, crash recovery inserted a special downlink pointer. The
  231. * semantics of an invalid tuple was that it if you encounter one in a scan,
  232. * it must always be followed, because we don't know if the tuples on the
  233. * child page match or not.
  234. *
  235. * We no longer create such invalid tuples, we now mark the left-half of such
  236. * an incomplete split with the F_FOLLOW_RIGHT flag instead, and finish the
  237. * split properly the next time we need to insert on that page. To retain
  238. * on-disk compatibility for the sake of pg_upgrade, we still store 0xffff as
  239. * the offset number of all inner tuples. If we encounter any invalid tuples
  240. * with 0xfffe during insertion, we throw an error, though scans still handle
  241. * them. You should only encounter invalid tuples if you pg_upgrade a pre-9.1
  242. * gist index which already has invalid tuples in it because of a crash. That
  243. * should be rare, and you are recommended to REINDEX anyway if you have any
  244. * invalid tuples in an index, so throwing an error is as far as we go with
  245. * supporting that.
  246. */
  247. #define TUPLE_IS_VALID 0xffff
  248. #define TUPLE_IS_INVALID 0xfffe
  249. #define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
  250. #define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
  251. /*
  252. * A buffer attached to an internal node, used when building an index in
  253. * buffering mode.
  254. */
  255. typedef struct
  256. {
  257. BlockNumber nodeBlocknum; /* index block # this buffer is for */
  258. int32 blocksCount; /* current # of blocks occupied by buffer */
  259. BlockNumber pageBlocknum; /* temporary file block # */
  260. GISTNodeBufferPage *pageBuffer; /* in-memory buffer page */
  261. /* is this buffer queued for emptying? */
  262. bool queuedForEmptying;
  263. /* is this a temporary copy, not in the hash table? */
  264. bool isTemp;
  265. int level; /* 0 == leaf */
  266. } GISTNodeBuffer;
  267. /*
  268. * Does specified level have buffers? (Beware of multiple evaluation of
  269. * arguments.)
  270. */
  271. #define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
  272. ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
  273. (nlevel) != (gfbb)->rootlevel)
  274. /* Is specified buffer at least half-filled (should be queued for emptying)? */
  275. #define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
  276. ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
  277. /*
  278. * Is specified buffer full? Our buffers can actually grow indefinitely,
  279. * beyond the "maximum" size, so this just means whether the buffer has grown
  280. * beyond the nominal maximum size.
  281. */
  282. #define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
  283. ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
  284. /*
  285. * Data structure with general information about build buffers.
  286. */
  287. typedef struct GISTBuildBuffers
  288. {
  289. /* Persistent memory context for the buffers and metadata. */
  290. MemoryContext context;
  291. BufFile *pfile; /* Temporary file to store buffers in */
  292. long nFileBlocks; /* Current size of the temporary file */
  293. /*
  294. * resizable array of free blocks.
  295. */
  296. long *freeBlocks;
  297. int nFreeBlocks; /* # of currently free blocks in the array */
  298. int freeBlocksLen; /* current allocated length of the array */
  299. /* Hash for buffers by block number */
  300. HTAB *nodeBuffersTab;
  301. /* List of buffers scheduled for emptying */
  302. List *bufferEmptyingQueue;
  303. /*
  304. * Parameters to the buffering build algorithm. levelStep determines which
  305. * levels in the tree have buffers, and pagesPerBuffer determines how
  306. * large each buffer is.
  307. */
  308. int levelStep;
  309. int pagesPerBuffer;
  310. /* Array of lists of buffers on each level, for final emptying */
  311. List **buffersOnLevels;
  312. int buffersOnLevelsLen;
  313. /*
  314. * Dynamically-sized array of buffers that currently have their last page
  315. * loaded in main memory.
  316. */
  317. GISTNodeBuffer **loadedBuffers;
  318. int loadedBuffersCount; /* # of entries in loadedBuffers */
  319. int loadedBuffersLen; /* allocated size of loadedBuffers */
  320. /* Level of the current root node (= height of the index tree - 1) */
  321. int rootlevel;
  322. } GISTBuildBuffers;
  323. /* GiSTOptions->buffering_mode values */
  324. typedef enum GistOptBufferingMode
  325. {
  326. GIST_OPTION_BUFFERING_AUTO,
  327. GIST_OPTION_BUFFERING_ON,
  328. GIST_OPTION_BUFFERING_OFF
  329. } GistOptBufferingMode;
  330. /*
  331. * Storage type for GiST's reloptions
  332. */
  333. typedef struct GiSTOptions
  334. {
  335. int32 vl_len_; /* varlena header (do not touch directly!) */
  336. int fillfactor; /* page fill factor in percent (0..100) */
  337. GistOptBufferingMode buffering_mode; /* buffering build mode */
  338. } GiSTOptions;
  339. /* gist.c */
  340. extern void gistbuildempty(Relation index);
  341. extern bool gistinsert(Relation r, Datum *values, bool *isnull,
  342. ItemPointer ht_ctid, Relation heapRel,
  343. IndexUniqueCheck checkUnique,
  344. bool indexUnchanged,
  345. struct IndexInfo *indexInfo);
  346. extern MemoryContext createTempGistContext(void);
  347. extern GISTSTATE *initGISTstate(Relation index);
  348. extern void freeGISTstate(GISTSTATE *giststate);
  349. extern void gistdoinsert(Relation r,
  350. IndexTuple itup,
  351. Size freespace,
  352. GISTSTATE *giststate,
  353. Relation heapRel,
  354. bool is_build);
  355. /* A List of these is returned from gistplacetopage() in *splitinfo */
  356. typedef struct
  357. {
  358. Buffer buf; /* the split page "half" */
  359. IndexTuple downlink; /* downlink for this half. */
  360. } GISTPageSplitInfo;
  361. extern bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
  362. Buffer buffer,
  363. IndexTuple *itup, int ntup,
  364. OffsetNumber oldoffnum, BlockNumber *newblkno,
  365. Buffer leftchildbuf,
  366. List **splitinfo,
  367. bool markfollowright,
  368. Relation heapRel,
  369. bool is_build);
  370. extern SplitedPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
  371. int len, GISTSTATE *giststate);
  372. /* gistxlog.c */
  373. extern XLogRecPtr gistXLogPageDelete(Buffer buffer,
  374. FullTransactionId xid, Buffer parentBuffer,
  375. OffsetNumber downlinkOffset);
  376. extern void gistXLogPageReuse(Relation rel, BlockNumber blkno,
  377. FullTransactionId latestRemovedXid);
  378. extern XLogRecPtr gistXLogUpdate(Buffer buffer,
  379. OffsetNumber *todelete, int ntodelete,
  380. IndexTuple *itup, int ntup,
  381. Buffer leftchild);
  382. extern XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete,
  383. int ntodelete, TransactionId latestRemovedXid);
  384. extern XLogRecPtr gistXLogSplit(bool page_is_leaf,
  385. SplitedPageLayout *dist,
  386. BlockNumber origrlink, GistNSN oldnsn,
  387. Buffer leftchild, bool markfollowright);
  388. extern XLogRecPtr gistXLogAssignLSN(void);
  389. /* gistget.c */
  390. extern bool gistgettuple(IndexScanDesc scan, ScanDirection dir);
  391. extern int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
  392. extern bool gistcanreturn(Relation index, int attno);
  393. /* gistvalidate.c */
  394. extern bool gistvalidate(Oid opclassoid);
  395. extern void gistadjustmembers(Oid opfamilyoid,
  396. Oid opclassoid,
  397. List *operators,
  398. List *functions);
  399. /* gistutil.c */
  400. #define GiSTPageSize \
  401. ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
  402. #define GIST_MIN_FILLFACTOR 10
  403. #define GIST_DEFAULT_FILLFACTOR 90
  404. extern bytea *gistoptions(Datum reloptions, bool validate);
  405. extern bool gistproperty(Oid index_oid, int attno,
  406. IndexAMProperty prop, const char *propname,
  407. bool *res, bool *isnull);
  408. extern bool gistfitpage(IndexTuple *itvec, int len);
  409. extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace);
  410. extern void gistcheckpage(Relation rel, Buffer buf);
  411. extern Buffer gistNewBuffer(Relation r);
  412. extern bool gistPageRecyclable(Page page);
  413. extern void gistfillbuffer(Page page, IndexTuple *itup, int len,
  414. OffsetNumber off);
  415. extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
  416. extern IndexTuple *gistjoinvector(IndexTuple *itvec, int *len,
  417. IndexTuple *additvec, int addlen);
  418. extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
  419. extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
  420. int len, GISTSTATE *giststate);
  421. extern IndexTuple gistgetadjusted(Relation r,
  422. IndexTuple oldtup,
  423. IndexTuple addtup,
  424. GISTSTATE *giststate);
  425. extern IndexTuple gistFormTuple(GISTSTATE *giststate,
  426. Relation r, Datum *attdata, bool *isnull, bool isleaf);
  427. extern void gistCompressValues(GISTSTATE *giststate, Relation r,
  428. Datum *attdata, bool *isnull, bool isleaf, Datum *compatt);
  429. extern OffsetNumber gistchoose(Relation r, Page p,
  430. IndexTuple it,
  431. GISTSTATE *giststate);
  432. extern void GISTInitBuffer(Buffer b, uint32 f);
  433. extern void gistinitpage(Page page, uint32 f);
  434. extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
  435. Datum k, Relation r, Page pg, OffsetNumber o,
  436. bool l, bool isNull);
  437. extern float gistpenalty(GISTSTATE *giststate, int attno,
  438. GISTENTRY *key1, bool isNull1,
  439. GISTENTRY *key2, bool isNull2);
  440. extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
  441. Datum *attr, bool *isnull);
  442. extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
  443. extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
  444. OffsetNumber o, GISTENTRY *attdata, bool *isnull);
  445. extern HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
  446. IndexTuple tuple);
  447. extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
  448. GISTENTRY *entry1, bool isnull1,
  449. GISTENTRY *entry2, bool isnull2,
  450. Datum *dst, bool *dstisnull);
  451. extern XLogRecPtr gistGetFakeLSN(Relation rel);
  452. /* gistvacuum.c */
  453. extern IndexBulkDeleteResult *gistbulkdelete(IndexVacuumInfo *info,
  454. IndexBulkDeleteResult *stats,
  455. IndexBulkDeleteCallback callback,
  456. void *callback_state);
  457. extern IndexBulkDeleteResult *gistvacuumcleanup(IndexVacuumInfo *info,
  458. IndexBulkDeleteResult *stats);
  459. /* gistsplit.c */
  460. extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
  461. int len, GISTSTATE *giststate,
  462. GistSplitVector *v,
  463. int attno);
  464. /* gistbuild.c */
  465. extern IndexBuildResult *gistbuild(Relation heap, Relation index,
  466. struct IndexInfo *indexInfo);
  467. extern void gistValidateBufferingOption(const char *value);
  468. /* gistbuildbuffers.c */
  469. extern GISTBuildBuffers *gistInitBuildBuffers(int pagesPerBuffer, int levelStep,
  470. int maxLevel);
  471. extern GISTNodeBuffer *gistGetNodeBuffer(GISTBuildBuffers *gfbb,
  472. GISTSTATE *giststate,
  473. BlockNumber blkno, int level);
  474. extern void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb,
  475. GISTNodeBuffer *nodeBuffer, IndexTuple item);
  476. extern bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb,
  477. GISTNodeBuffer *nodeBuffer, IndexTuple *item);
  478. extern void gistFreeBuildBuffers(GISTBuildBuffers *gfbb);
  479. extern void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb,
  480. GISTSTATE *giststate, Relation r,
  481. int level, Buffer buffer,
  482. List *splitinfo);
  483. extern void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb);
  484. #endif /* GIST_PRIVATE_H */