PostgreSQL Source Code  git master
spgutils.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * spgutils.c
4  * various support functions for SP-GiST
5  *
6  *
7  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * IDENTIFICATION
11  * src/backend/access/spgist/spgutils.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 
16 #include "postgres.h"
17 
18 #include "access/amvalidate.h"
19 #include "access/htup_details.h"
20 #include "access/reloptions.h"
21 #include "access/spgist_private.h"
22 #include "access/transam.h"
23 #include "access/xact.h"
24 #include "catalog/pg_amop.h"
25 #include "commands/vacuum.h"
26 #include "storage/bufmgr.h"
27 #include "storage/indexfsm.h"
28 #include "storage/lmgr.h"
29 #include "utils/builtins.h"
30 #include "utils/catcache.h"
31 #include "utils/index_selfuncs.h"
32 #include "utils/lsyscache.h"
33 #include "utils/syscache.h"
34 
35 
36 /*
37  * SP-GiST handler function: return IndexAmRoutine with access method parameters
38  * and callbacks.
39  */
40 Datum
42 {
44 
45  amroutine->amstrategies = 0;
46  amroutine->amsupport = SPGISTNProc;
47  amroutine->amcanorder = false;
48  amroutine->amcanorderbyop = true;
49  amroutine->amcanbackward = false;
50  amroutine->amcanunique = false;
51  amroutine->amcanmulticol = false;
52  amroutine->amoptionalkey = true;
53  amroutine->amsearcharray = false;
54  amroutine->amsearchnulls = true;
55  amroutine->amstorage = false;
56  amroutine->amclusterable = false;
57  amroutine->ampredlocks = false;
58  amroutine->amcanparallel = false;
59  amroutine->amcaninclude = false;
60  amroutine->amusemaintenanceworkmem = false;
61  amroutine->amparallelvacuumoptions =
63  amroutine->amkeytype = InvalidOid;
64 
65  amroutine->ambuild = spgbuild;
66  amroutine->ambuildempty = spgbuildempty;
67  amroutine->aminsert = spginsert;
68  amroutine->ambulkdelete = spgbulkdelete;
69  amroutine->amvacuumcleanup = spgvacuumcleanup;
70  amroutine->amcanreturn = spgcanreturn;
71  amroutine->amcostestimate = spgcostestimate;
72  amroutine->amoptions = spgoptions;
73  amroutine->amproperty = spgproperty;
74  amroutine->ambuildphasename = NULL;
75  amroutine->amvalidate = spgvalidate;
76  amroutine->ambeginscan = spgbeginscan;
77  amroutine->amrescan = spgrescan;
78  amroutine->amgettuple = spggettuple;
79  amroutine->amgetbitmap = spggetbitmap;
80  amroutine->amendscan = spgendscan;
81  amroutine->ammarkpos = NULL;
82  amroutine->amrestrpos = NULL;
83  amroutine->amestimateparallelscan = NULL;
84  amroutine->aminitparallelscan = NULL;
85  amroutine->amparallelrescan = NULL;
86 
87  PG_RETURN_POINTER(amroutine);
88 }
89 
90 /* Fill in a SpGistTypeDesc struct with info about the specified data type */
91 static void
93 {
94  desc->type = type;
95  get_typlenbyval(type, &desc->attlen, &desc->attbyval);
96 }
97 
98 /*
99  * Fetch local cache of AM-specific info about the index, initializing it
100  * if necessary
101  */
102 SpGistCache *
104 {
105  SpGistCache *cache;
106 
107  if (index->rd_amcache == NULL)
108  {
109  Oid atttype;
110  spgConfigIn in;
111  FmgrInfo *procinfo;
112  Buffer metabuffer;
113  SpGistMetaPageData *metadata;
114 
115  cache = MemoryContextAllocZero(index->rd_indexcxt,
116  sizeof(SpGistCache));
117 
118  /* SPGiST doesn't support multi-column indexes */
119  Assert(index->rd_att->natts == 1);
120 
121  /*
122  * Get the actual data type of the indexed column from the index
123  * tupdesc. We pass this to the opclass config function so that
124  * polymorphic opclasses are possible.
125  */
126  atttype = TupleDescAttr(index->rd_att, 0)->atttypid;
127 
128  /* Call the config function to get config info for the opclass */
129  in.attType = atttype;
130 
131  procinfo = index_getprocinfo(index, 1, SPGIST_CONFIG_PROC);
132  FunctionCall2Coll(procinfo,
133  index->rd_indcollation[0],
134  PointerGetDatum(&in),
135  PointerGetDatum(&cache->config));
136 
137  /* Get the information we need about each relevant datatype */
138  fillTypeDesc(&cache->attType, atttype);
139 
140  if (OidIsValid(cache->config.leafType) &&
141  cache->config.leafType != atttype)
142  {
144  ereport(ERROR,
145  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
146  errmsg("compress method must be defined when leaf type is different from input type")));
147 
148  fillTypeDesc(&cache->attLeafType, cache->config.leafType);
149  }
150  else
151  {
152  cache->attLeafType = cache->attType;
153  }
154 
155  fillTypeDesc(&cache->attPrefixType, cache->config.prefixType);
156  fillTypeDesc(&cache->attLabelType, cache->config.labelType);
157 
158  /* Last, get the lastUsedPages data from the metapage */
159  metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO);
160  LockBuffer(metabuffer, BUFFER_LOCK_SHARE);
161 
162  metadata = SpGistPageGetMeta(BufferGetPage(metabuffer));
163 
164  if (metadata->magicNumber != SPGIST_MAGIC_NUMBER)
165  elog(ERROR, "index \"%s\" is not an SP-GiST index",
166  RelationGetRelationName(index));
167 
168  cache->lastUsedPages = metadata->lastUsedPages;
169 
170  UnlockReleaseBuffer(metabuffer);
171 
172  index->rd_amcache = (void *) cache;
173  }
174  else
175  {
176  /* assume it's up to date */
177  cache = (SpGistCache *) index->rd_amcache;
178  }
179 
180  return cache;
181 }
182 
183 /* Initialize SpGistState for working with the given index */
184 void
186 {
187  SpGistCache *cache;
188 
189  /* Get cached static information about index */
190  cache = spgGetCache(index);
191 
192  state->config = cache->config;
193  state->attType = cache->attType;
194  state->attLeafType = cache->attLeafType;
195  state->attPrefixType = cache->attPrefixType;
196  state->attLabelType = cache->attLabelType;
197 
198  /* Make workspace for constructing dead tuples */
200 
201  /* Set XID to use in redirection tuples */
202  state->myXid = GetTopTransactionIdIfAny();
203 
204  /* Assume we're not in an index build (spgbuild will override) */
205  state->isBuild = false;
206 }
207 
208 /*
209  * Allocate a new page (either by recycling, or by extending the index file).
210  *
211  * The returned buffer is already pinned and exclusive-locked.
212  * Caller is responsible for initializing the page by calling SpGistInitBuffer.
213  */
214 Buffer
216 {
217  Buffer buffer;
218  bool needLock;
219 
220  /* First, try to get a page from FSM */
221  for (;;)
222  {
223  BlockNumber blkno = GetFreeIndexPage(index);
224 
225  if (blkno == InvalidBlockNumber)
226  break; /* nothing known to FSM */
227 
228  /*
229  * The fixed pages shouldn't ever be listed in FSM, but just in case
230  * one is, ignore it.
231  */
232  if (SpGistBlockIsFixed(blkno))
233  continue;
234 
235  buffer = ReadBuffer(index, blkno);
236 
237  /*
238  * We have to guard against the possibility that someone else already
239  * recycled this page; the buffer may be locked if so.
240  */
241  if (ConditionalLockBuffer(buffer))
242  {
243  Page page = BufferGetPage(buffer);
244 
245  if (PageIsNew(page))
246  return buffer; /* OK to use, if never initialized */
247 
248  if (SpGistPageIsDeleted(page) || PageIsEmpty(page))
249  return buffer; /* OK to use */
250 
252  }
253 
254  /* Can't use it, so release buffer and try again */
255  ReleaseBuffer(buffer);
256  }
257 
258  /* Must extend the file */
259  needLock = !RELATION_IS_LOCAL(index);
260  if (needLock)
262 
263  buffer = ReadBuffer(index, P_NEW);
265 
266  if (needLock)
268 
269  return buffer;
270 }
271 
272 /*
273  * Update index metapage's lastUsedPages info from local cache, if possible
274  *
275  * Updating meta page isn't critical for index working, so
276  * 1 use ConditionalLockBuffer to improve concurrency
277  * 2 don't WAL-log metabuffer changes to decrease WAL traffic
278  */
279 void
281 {
282  SpGistCache *cache = (SpGistCache *) index->rd_amcache;
283 
284  if (cache != NULL)
285  {
286  Buffer metabuffer;
287 
288  metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO);
289 
290  if (ConditionalLockBuffer(metabuffer))
291  {
292  Page metapage = BufferGetPage(metabuffer);
293  SpGistMetaPageData *metadata = SpGistPageGetMeta(metapage);
294 
295  metadata->lastUsedPages = cache->lastUsedPages;
296 
297  /*
298  * Set pd_lower just past the end of the metadata. This is
299  * essential, because without doing so, metadata will be lost if
300  * xlog.c compresses the page. (We must do this here because
301  * pre-v11 versions of PG did not set the metapage's pd_lower
302  * correctly, so a pg_upgraded index might contain the wrong
303  * value.)
304  */
305  ((PageHeader) metapage)->pd_lower =
306  ((char *) metadata + sizeof(SpGistMetaPageData)) - (char *) metapage;
307 
308  MarkBufferDirty(metabuffer);
309  UnlockReleaseBuffer(metabuffer);
310  }
311  else
312  {
313  ReleaseBuffer(metabuffer);
314  }
315  }
316 }
317 
318 /* Macro to select proper element of lastUsedPages cache depending on flags */
319 /* Masking flags with SPGIST_CACHED_PAGES is just for paranoia's sake */
320 #define GET_LUP(c, f) (&(c)->lastUsedPages.cachedPage[((unsigned int) (f)) % SPGIST_CACHED_PAGES])
321 
322 /*
323  * Allocate and initialize a new buffer of the type and parity specified by
324  * flags. The returned buffer is already pinned and exclusive-locked.
325  *
326  * When requesting an inner page, if we get one with the wrong parity,
327  * we just release the buffer and try again. We will get a different page
328  * because GetFreeIndexPage will have marked the page used in FSM. The page
329  * is entered in our local lastUsedPages cache, so there's some hope of
330  * making use of it later in this session, but otherwise we rely on VACUUM
331  * to eventually re-enter the page in FSM, making it available for recycling.
332  * Note that such a page does not get marked dirty here, so unless it's used
333  * fairly soon, the buffer will just get discarded and the page will remain
334  * as it was on disk.
335  *
336  * When we return a buffer to the caller, the page is *not* entered into
337  * the lastUsedPages cache; we expect the caller will do so after it's taken
338  * whatever space it will use. This is because after the caller has used up
339  * some space, the page might have less space than whatever was cached already
340  * so we'd rather not trash the old cache entry.
341  */
342 static Buffer
344 {
345  SpGistCache *cache = spgGetCache(index);
346  uint16 pageflags = 0;
347 
348  if (GBUF_REQ_LEAF(flags))
349  pageflags |= SPGIST_LEAF;
350  if (GBUF_REQ_NULLS(flags))
351  pageflags |= SPGIST_NULLS;
352 
353  for (;;)
354  {
355  Buffer buffer;
356 
357  buffer = SpGistNewBuffer(index);
358  SpGistInitBuffer(buffer, pageflags);
359 
360  if (pageflags & SPGIST_LEAF)
361  {
362  /* Leaf pages have no parity concerns, so just use it */
363  return buffer;
364  }
365  else
366  {
367  BlockNumber blkno = BufferGetBlockNumber(buffer);
368  int blkFlags = GBUF_INNER_PARITY(blkno);
369 
370  if ((flags & GBUF_PARITY_MASK) == blkFlags)
371  {
372  /* Page has right parity, use it */
373  return buffer;
374  }
375  else
376  {
377  /* Page has wrong parity, record it in cache and try again */
378  if (pageflags & SPGIST_NULLS)
379  blkFlags |= GBUF_NULLS;
380  cache->lastUsedPages.cachedPage[blkFlags].blkno = blkno;
381  cache->lastUsedPages.cachedPage[blkFlags].freeSpace =
383  UnlockReleaseBuffer(buffer);
384  }
385  }
386  }
387 }
388 
389 /*
390  * Get a buffer of the type and parity specified by flags, having at least
391  * as much free space as indicated by needSpace. We use the lastUsedPages
392  * cache to assign the same buffer previously requested when possible.
393  * The returned buffer is already pinned and exclusive-locked.
394  *
395  * *isNew is set true if the page was initialized here, false if it was
396  * already valid.
397  */
398 Buffer
399 SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew)
400 {
401  SpGistCache *cache = spgGetCache(index);
402  SpGistLastUsedPage *lup;
403 
404  /* Bail out if even an empty page wouldn't meet the demand */
405  if (needSpace > SPGIST_PAGE_CAPACITY)
406  elog(ERROR, "desired SPGiST tuple size is too big");
407 
408  /*
409  * If possible, increase the space request to include relation's
410  * fillfactor. This ensures that when we add unrelated tuples to a page,
411  * we try to keep 100-fillfactor% available for adding tuples that are
412  * related to the ones already on it. But fillfactor mustn't cause an
413  * error for requests that would otherwise be legal.
414  */
415  needSpace += SpGistGetTargetPageFreeSpace(index);
416  needSpace = Min(needSpace, SPGIST_PAGE_CAPACITY);
417 
418  /* Get the cache entry for this flags setting */
419  lup = GET_LUP(cache, flags);
420 
421  /* If we have nothing cached, just turn it over to allocNewBuffer */
422  if (lup->blkno == InvalidBlockNumber)
423  {
424  *isNew = true;
425  return allocNewBuffer(index, flags);
426  }
427 
428  /* fixed pages should never be in cache */
430 
431  /* If cached freeSpace isn't enough, don't bother looking at the page */
432  if (lup->freeSpace >= needSpace)
433  {
434  Buffer buffer;
435  Page page;
436 
437  buffer = ReadBuffer(index, lup->blkno);
438 
439  if (!ConditionalLockBuffer(buffer))
440  {
441  /*
442  * buffer is locked by another process, so return a new buffer
443  */
444  ReleaseBuffer(buffer);
445  *isNew = true;
446  return allocNewBuffer(index, flags);
447  }
448 
449  page = BufferGetPage(buffer);
450 
451  if (PageIsNew(page) || SpGistPageIsDeleted(page) || PageIsEmpty(page))
452  {
453  /* OK to initialize the page */
454  uint16 pageflags = 0;
455 
456  if (GBUF_REQ_LEAF(flags))
457  pageflags |= SPGIST_LEAF;
458  if (GBUF_REQ_NULLS(flags))
459  pageflags |= SPGIST_NULLS;
460  SpGistInitBuffer(buffer, pageflags);
461  lup->freeSpace = PageGetExactFreeSpace(page) - needSpace;
462  *isNew = true;
463  return buffer;
464  }
465 
466  /*
467  * Check that page is of right type and has enough space. We must
468  * recheck this since our cache isn't necessarily up to date.
469  */
470  if ((GBUF_REQ_LEAF(flags) ? SpGistPageIsLeaf(page) : !SpGistPageIsLeaf(page)) &&
472  {
473  int freeSpace = PageGetExactFreeSpace(page);
474 
475  if (freeSpace >= needSpace)
476  {
477  /* Success, update freespace info and return the buffer */
478  lup->freeSpace = freeSpace - needSpace;
479  *isNew = false;
480  return buffer;
481  }
482  }
483 
484  /*
485  * fallback to allocation of new buffer
486  */
487  UnlockReleaseBuffer(buffer);
488  }
489 
490  /* No success with cache, so return a new buffer */
491  *isNew = true;
492  return allocNewBuffer(index, flags);
493 }
494 
495 /*
496  * Update lastUsedPages cache when done modifying a page.
497  *
498  * We update the appropriate cache entry if it already contained this page
499  * (its freeSpace is likely obsolete), or if this page has more space than
500  * whatever we had cached.
501  */
502 void
504 {
505  SpGistCache *cache = spgGetCache(index);
506  SpGistLastUsedPage *lup;
507  int freeSpace;
508  Page page = BufferGetPage(buffer);
509  BlockNumber blkno = BufferGetBlockNumber(buffer);
510  int flags;
511 
512  /* Never enter fixed pages (root pages) in cache, though */
513  if (SpGistBlockIsFixed(blkno))
514  return;
515 
516  if (SpGistPageIsLeaf(page))
517  flags = GBUF_LEAF;
518  else
519  flags = GBUF_INNER_PARITY(blkno);
520  if (SpGistPageStoresNulls(page))
521  flags |= GBUF_NULLS;
522 
523  lup = GET_LUP(cache, flags);
524 
525  freeSpace = PageGetExactFreeSpace(page);
526  if (lup->blkno == InvalidBlockNumber || lup->blkno == blkno ||
527  lup->freeSpace < freeSpace)
528  {
529  lup->blkno = blkno;
530  lup->freeSpace = freeSpace;
531  }
532 }
533 
534 /*
535  * Initialize an SPGiST page to empty, with specified flags
536  */
537 void
539 {
540  SpGistPageOpaque opaque;
541 
542  PageInit(page, BLCKSZ, MAXALIGN(sizeof(SpGistPageOpaqueData)));
543  opaque = SpGistPageGetOpaque(page);
544  memset(opaque, 0, sizeof(SpGistPageOpaqueData));
545  opaque->flags = f;
546  opaque->spgist_page_id = SPGIST_PAGE_ID;
547 }
548 
549 /*
550  * Initialize a buffer's page to empty, with specified flags
551  */
552 void
554 {
555  Assert(BufferGetPageSize(b) == BLCKSZ);
557 }
558 
559 /*
560  * Initialize metadata page
561  */
562 void
564 {
565  SpGistMetaPageData *metadata;
566  int i;
567 
569  metadata = SpGistPageGetMeta(page);
570  memset(metadata, 0, sizeof(SpGistMetaPageData));
571  metadata->magicNumber = SPGIST_MAGIC_NUMBER;
572 
573  /* initialize last-used-page cache to empty */
574  for (i = 0; i < SPGIST_CACHED_PAGES; i++)
576 
577  /*
578  * Set pd_lower just past the end of the metadata. This is essential,
579  * because without doing so, metadata will be lost if xlog.c compresses
580  * the page.
581  */
582  ((PageHeader) page)->pd_lower =
583  ((char *) metadata + sizeof(SpGistMetaPageData)) - (char *) page;
584 }
585 
586 /*
587  * reloptions processing for SPGiST
588  */
589 bytea *
590 spgoptions(Datum reloptions, bool validate)
591 {
592  static const relopt_parse_elt tab[] = {
594  };
595 
596  return (bytea *) build_reloptions(reloptions, validate,
598  sizeof(SpGistOptions),
599  tab, lengthof(tab));
600 
601 }
602 
603 /*
604  * Get the space needed to store a non-null datum of the indicated type.
605  * Note the result is already rounded up to a MAXALIGN boundary.
606  * Also, we follow the SPGiST convention that pass-by-val types are
607  * just stored in their Datum representation (compare memcpyDatum).
608  */
609 unsigned int
611 {
612  unsigned int size;
613 
614  if (att->attbyval)
615  size = sizeof(Datum);
616  else if (att->attlen > 0)
617  size = att->attlen;
618  else
619  size = VARSIZE_ANY(datum);
620 
621  return MAXALIGN(size);
622 }
623 
624 /*
625  * Copy the given non-null datum to *target
626  */
627 static void
628 memcpyDatum(void *target, SpGistTypeDesc *att, Datum datum)
629 {
630  unsigned int size;
631 
632  if (att->attbyval)
633  {
634  memcpy(target, &datum, sizeof(Datum));
635  }
636  else
637  {
638  size = (att->attlen > 0) ? att->attlen : VARSIZE_ANY(datum);
639  memcpy(target, DatumGetPointer(datum), size);
640  }
641 }
642 
643 /*
644  * Construct a leaf tuple containing the given heap TID and datum value
645  */
648  Datum datum, bool isnull)
649 {
650  SpGistLeafTuple tup;
651  unsigned int size;
652 
653  /* compute space needed (note result is already maxaligned) */
654  size = SGLTHDRSZ;
655  if (!isnull)
656  size += SpGistGetTypeSize(&state->attLeafType, datum);
657 
658  /*
659  * Ensure that we can replace the tuple with a dead tuple later. This
660  * test is unnecessary when !isnull, but let's be safe.
661  */
662  if (size < SGDTSIZE)
663  size = SGDTSIZE;
664 
665  /* OK, form the tuple */
666  tup = (SpGistLeafTuple) palloc0(size);
667 
668  tup->size = size;
670  tup->heapPtr = *heapPtr;
671  if (!isnull)
672  memcpyDatum(SGLTDATAPTR(tup), &state->attLeafType, datum);
673 
674  return tup;
675 }
676 
677 /*
678  * Construct a node (to go into an inner tuple) containing the given label
679  *
680  * Note that the node's downlink is just set invalid here. Caller will fill
681  * it in later.
682  */
685 {
686  SpGistNodeTuple tup;
687  unsigned int size;
688  unsigned short infomask = 0;
689 
690  /* compute space needed (note result is already maxaligned) */
691  size = SGNTHDRSZ;
692  if (!isnull)
693  size += SpGistGetTypeSize(&state->attLabelType, label);
694 
695  /*
696  * Here we make sure that the size will fit in the field reserved for it
697  * in t_info.
698  */
699  if ((size & INDEX_SIZE_MASK) != size)
700  ereport(ERROR,
701  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
702  errmsg("index row requires %zu bytes, maximum size is %zu",
703  (Size) size, (Size) INDEX_SIZE_MASK)));
704 
705  tup = (SpGistNodeTuple) palloc0(size);
706 
707  if (isnull)
708  infomask |= INDEX_NULL_MASK;
709  /* we don't bother setting the INDEX_VAR_MASK bit */
710  infomask |= size;
711  tup->t_info = infomask;
712 
713  /* The TID field will be filled in later */
715 
716  if (!isnull)
717  memcpyDatum(SGNTDATAPTR(tup), &state->attLabelType, label);
718 
719  return tup;
720 }
721 
722 /*
723  * Construct an inner tuple containing the given prefix and node array
724  */
726 spgFormInnerTuple(SpGistState *state, bool hasPrefix, Datum prefix,
727  int nNodes, SpGistNodeTuple *nodes)
728 {
729  SpGistInnerTuple tup;
730  unsigned int size;
731  unsigned int prefixSize;
732  int i;
733  char *ptr;
734 
735  /* Compute size needed */
736  if (hasPrefix)
737  prefixSize = SpGistGetTypeSize(&state->attPrefixType, prefix);
738  else
739  prefixSize = 0;
740 
741  size = SGITHDRSZ + prefixSize;
742 
743  /* Note: we rely on node tuple sizes to be maxaligned already */
744  for (i = 0; i < nNodes; i++)
745  size += IndexTupleSize(nodes[i]);
746 
747  /*
748  * Ensure that we can replace the tuple with a dead tuple later. This
749  * test is unnecessary given current tuple layouts, but let's be safe.
750  */
751  if (size < SGDTSIZE)
752  size = SGDTSIZE;
753 
754  /*
755  * Inner tuple should be small enough to fit on a page
756  */
757  if (size > SPGIST_PAGE_CAPACITY - sizeof(ItemIdData))
758  ereport(ERROR,
759  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
760  errmsg("SP-GiST inner tuple size %zu exceeds maximum %zu",
761  (Size) size,
762  SPGIST_PAGE_CAPACITY - sizeof(ItemIdData)),
763  errhint("Values larger than a buffer page cannot be indexed.")));
764 
765  /*
766  * Check for overflow of header fields --- probably can't fail if the
767  * above succeeded, but let's be paranoid
768  */
769  if (size > SGITMAXSIZE ||
770  prefixSize > SGITMAXPREFIXSIZE ||
771  nNodes > SGITMAXNNODES)
772  elog(ERROR, "SPGiST inner tuple header field is too small");
773 
774  /* OK, form the tuple */
775  tup = (SpGistInnerTuple) palloc0(size);
776 
777  tup->nNodes = nNodes;
778  tup->prefixSize = prefixSize;
779  tup->size = size;
780 
781  if (hasPrefix)
782  memcpyDatum(SGITDATAPTR(tup), &state->attPrefixType, prefix);
783 
784  ptr = (char *) SGITNODEPTR(tup);
785 
786  for (i = 0; i < nNodes; i++)
787  {
788  SpGistNodeTuple node = nodes[i];
789 
790  memcpy(ptr, node, IndexTupleSize(node));
791  ptr += IndexTupleSize(node);
792  }
793 
794  return tup;
795 }
796 
797 /*
798  * Construct a "dead" tuple to replace a tuple being deleted.
799  *
800  * The state can be SPGIST_REDIRECT, SPGIST_DEAD, or SPGIST_PLACEHOLDER.
801  * For a REDIRECT tuple, a pointer (blkno+offset) must be supplied, and
802  * the xid field is filled in automatically.
803  *
804  * This is called in critical sections, so we don't use palloc; the tuple
805  * is built in preallocated storage. It should be copied before another
806  * call with different parameters can occur.
807  */
810  BlockNumber blkno, OffsetNumber offnum)
811 {
813 
814  tuple->tupstate = tupstate;
815  tuple->size = SGDTSIZE;
817 
818  if (tupstate == SPGIST_REDIRECT)
819  {
820  ItemPointerSet(&tuple->pointer, blkno, offnum);
822  tuple->xid = state->myXid;
823  }
824  else
825  {
827  tuple->xid = InvalidTransactionId;
828  }
829 
830  return tuple;
831 }
832 
833 /*
834  * Extract the label datums of the nodes within innerTuple
835  *
836  * Returns NULL if label datums are NULLs
837  */
838 Datum *
840 {
841  Datum *nodeLabels;
842  int i;
843  SpGistNodeTuple node;
844 
845  /* Either all the labels must be NULL, or none. */
846  node = SGITNODEPTR(innerTuple);
847  if (IndexTupleHasNulls(node))
848  {
849  SGITITERATE(innerTuple, i, node)
850  {
851  if (!IndexTupleHasNulls(node))
852  elog(ERROR, "some but not all node labels are null in SPGiST inner tuple");
853  }
854  /* They're all null, so just return NULL */
855  return NULL;
856  }
857  else
858  {
859  nodeLabels = (Datum *) palloc(sizeof(Datum) * innerTuple->nNodes);
860  SGITITERATE(innerTuple, i, node)
861  {
862  if (IndexTupleHasNulls(node))
863  elog(ERROR, "some but not all node labels are null in SPGiST inner tuple");
864  nodeLabels[i] = SGNTDATUM(node, state);
865  }
866  return nodeLabels;
867  }
868 }
869 
870 /*
871  * Add a new item to the page, replacing a PLACEHOLDER item if possible.
872  * Return the location it's inserted at, or InvalidOffsetNumber on failure.
873  *
874  * If startOffset isn't NULL, we start searching for placeholders at
875  * *startOffset, and update that to the next place to search. This is just
876  * an optimization for repeated insertions.
877  *
878  * If errorOK is false, we throw error when there's not enough room,
879  * rather than returning InvalidOffsetNumber.
880  */
883  OffsetNumber *startOffset, bool errorOK)
884 {
885  SpGistPageOpaque opaque = SpGistPageGetOpaque(page);
886  OffsetNumber i,
887  maxoff,
888  offnum;
889 
890  if (opaque->nPlaceholder > 0 &&
891  PageGetExactFreeSpace(page) + SGDTSIZE >= MAXALIGN(size))
892  {
893  /* Try to replace a placeholder */
894  maxoff = PageGetMaxOffsetNumber(page);
895  offnum = InvalidOffsetNumber;
896 
897  for (;;)
898  {
899  if (startOffset && *startOffset != InvalidOffsetNumber)
900  i = *startOffset;
901  else
902  i = FirstOffsetNumber;
903  for (; i <= maxoff; i++)
904  {
906  PageGetItemId(page, i));
907 
908  if (it->tupstate == SPGIST_PLACEHOLDER)
909  {
910  offnum = i;
911  break;
912  }
913  }
914 
915  /* Done if we found a placeholder */
916  if (offnum != InvalidOffsetNumber)
917  break;
918 
919  if (startOffset && *startOffset != InvalidOffsetNumber)
920  {
921  /* Hint was no good, re-search from beginning */
922  *startOffset = InvalidOffsetNumber;
923  continue;
924  }
925 
926  /* Hmm, no placeholder found? */
927  opaque->nPlaceholder = 0;
928  break;
929  }
930 
931  if (offnum != InvalidOffsetNumber)
932  {
933  /* Replace the placeholder tuple */
934  PageIndexTupleDelete(page, offnum);
935 
936  offnum = PageAddItem(page, item, size, offnum, false, false);
937 
938  /*
939  * We should not have failed given the size check at the top of
940  * the function, but test anyway. If we did fail, we must PANIC
941  * because we've already deleted the placeholder tuple, and
942  * there's no other way to keep the damage from getting to disk.
943  */
944  if (offnum != InvalidOffsetNumber)
945  {
946  Assert(opaque->nPlaceholder > 0);
947  opaque->nPlaceholder--;
948  if (startOffset)
949  *startOffset = offnum + 1;
950  }
951  else
952  elog(PANIC, "failed to add item of size %u to SPGiST index page",
953  (int) size);
954 
955  return offnum;
956  }
957  }
958 
959  /* No luck in replacing a placeholder, so just add it to the page */
960  offnum = PageAddItem(page, item, size,
961  InvalidOffsetNumber, false, false);
962 
963  if (offnum == InvalidOffsetNumber && !errorOK)
964  elog(ERROR, "failed to add item of size %u to SPGiST index page",
965  (int) size);
966 
967  return offnum;
968 }
969 
970 /*
971  * spgproperty() -- Check boolean properties of indexes.
972  *
973  * This is optional for most AMs, but is required for SP-GiST because the core
974  * property code doesn't support AMPROP_DISTANCE_ORDERABLE.
975  */
976 bool
977 spgproperty(Oid index_oid, int attno,
978  IndexAMProperty prop, const char *propname,
979  bool *res, bool *isnull)
980 {
981  Oid opclass,
982  opfamily,
983  opcintype;
984  CatCList *catlist;
985  int i;
986 
987  /* Only answer column-level inquiries */
988  if (attno == 0)
989  return false;
990 
991  switch (prop)
992  {
994  break;
995  default:
996  return false;
997  }
998 
999  /*
1000  * Currently, SP-GiST distance-ordered scans require that there be a
1001  * distance operator in the opclass with the default types. So we assume
1002  * that if such a operator exists, then there's a reason for it.
1003  */
1004 
1005  /* First we need to know the column's opclass. */
1006  opclass = get_index_column_opclass(index_oid, attno);
1007  if (!OidIsValid(opclass))
1008  {
1009  *isnull = true;
1010  return true;
1011  }
1012 
1013  /* Now look up the opclass family and input datatype. */
1014  if (!get_opclass_opfamily_and_input_type(opclass, &opfamily, &opcintype))
1015  {
1016  *isnull = true;
1017  return true;
1018  }
1019 
1020  /* And now we can check whether the operator is provided. */
1022  ObjectIdGetDatum(opfamily));
1023 
1024  *res = false;
1025 
1026  for (i = 0; i < catlist->n_members; i++)
1027  {
1028  HeapTuple amoptup = &catlist->members[i]->tuple;
1029  Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(amoptup);
1030 
1031  if (amopform->amoppurpose == AMOP_ORDER &&
1032  (amopform->amoplefttype == opcintype ||
1033  amopform->amoprighttype == opcintype) &&
1034  opfamily_can_sort_type(amopform->amopsortfamily,
1035  get_op_rettype(amopform->amopopr)))
1036  {
1037  *res = true;
1038  break;
1039  }
1040  }
1041 
1042  ReleaseSysCacheList(catlist);
1043 
1044  *isnull = false;
1045 
1046  return true;
1047 }
ambeginscan_function ambeginscan
Definition: amapi.h:225
void SpGistUpdateMetaPage(Relation index)
Definition: spgutils.c:280
uint8 amparallelvacuumoptions
Definition: amapi.h:203
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
SpGistTypeDesc attLeafType
#define SGITNODEPTR(x)
#define BUFFER_LOCK_UNLOCK
Definition: bufmgr.h:86
Definition: fmgr.h:56
SpGistTypeDesc attPrefixType
ambulkdelete_function ambulkdelete
Definition: amapi.h:217
Datum * spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
Definition: spgutils.c:839
bool amcanmulticol
Definition: amapi.h:183
int n_members
Definition: catcache.h:176
uint16 amsupport
Definition: amapi.h:173
SpGistInnerTupleData * SpGistInnerTuple
#define PageIsEmpty(page)
Definition: bufpage.h:222
#define SpGistPageIsLeaf(page)
SpGistDeadTuple spgFormDeadTuple(SpGistState *state, int tupstate, BlockNumber blkno, OffsetNumber offnum)
Definition: spgutils.c:809
int errhint(const char *fmt,...)
Definition: elog.c:1069
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
IndexAMProperty
Definition: amapi.h:34
SpGistCache * spgGetCache(Relation index)
Definition: spgutils.c:103
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:794
#define SGITMAXPREFIXSIZE
#define SGDTSIZE
bool opfamily_can_sort_type(Oid opfamilyoid, Oid datatypeoid)
Definition: amvalidate.c:217
amgettuple_function amgettuple
Definition: amapi.h:227
#define SPGIST_REDIRECT
bool amcanorderbyop
Definition: amapi.h:177
amproperty_function amproperty
Definition: amapi.h:222
#define GET_LUP(c, f)
Definition: spgutils.c:320
void PageIndexTupleDelete(Page page, OffsetNumber offnum)
Definition: bufpage.c:726
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
#define ExclusiveLock
Definition: lockdefs.h:44
#define PointerGetDatum(X)
Definition: postgres.h:556
bool spgproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: spgutils.c:977
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
IndexBulkDeleteResult * spgvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: spgvacuum.c:932
#define SGITITERATE(x, i, nt)
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:548
SpGistTypeDesc attLeafType
ItemPointerData t_tid
Definition: itup.h:37
#define SPGIST_PLACEHOLDER
amparallelrescan_function amparallelrescan
Definition: amapi.h:236
#define Min(x, y)
Definition: c.h:911
SpGistTypeDesc attType
#define SPGIST_NULLS
bool amstorage
Definition: amapi.h:191
void SpGistSetLastUsedPage(Relation index, Buffer buffer)
Definition: spgutils.c:503
Pointer Item
Definition: item.h:17
#define SGLTDATAPTR(x)
#define INDEX_SIZE_MASK
Definition: itup.h:65
int errcode(int sqlerrcode)
Definition: elog.c:608
void spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: spgscan.c:365
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
Definition: bufpage.h:416
static Buffer allocNewBuffer(Relation index, int flags)
Definition: spgutils.c:343
bool ampredlocks
Definition: amapi.h:195
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3375
SpGistTypeDesc attLabelType
#define IndexTupleHasNulls(itup)
Definition: itup.h:72
#define P_NEW
Definition: bufmgr.h:81
aminsert_function aminsert
Definition: amapi.h:216
Oid attType
Definition: spgist.h:37
bool spginsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, IndexInfo *indexInfo)
Definition: spginsert.c:207
#define lengthof(array)
Definition: c.h:669
#define SGNTHDRSZ
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:88
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1150
unsigned int Oid
Definition: postgres_ext.h:31
SpGistTypeDesc attType
Oid amkeytype
Definition: amapi.h:205
void spgendscan(IndexScanDesc scan)
Definition: spgscan.c:411
#define OidIsValid(objectId)
Definition: c.h:645
#define PANIC
Definition: elog.h:53
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
Oid get_op_rettype(Oid opno)
Definition: lsyscache.c:1140
bool amoptionalkey
Definition: amapi.h:185
amvalidate_function amvalidate
Definition: amapi.h:224
SpGistLUPCache lastUsedPages
bool spgcanreturn(Relation index, int attno)
Definition: spgscan.c:1019
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
Definition: reloptions.c:1552
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
spgConfigOut config
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
Definition: lsyscache.c:1064
SpGistLastUsedPage cachedPage[SPGIST_CACHED_PAGES]
#define GBUF_REQ_NULLS(flags)
unsigned short uint16
Definition: c.h:358
amgetbitmap_function amgetbitmap
Definition: amapi.h:228
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3398
Oid * rd_indcollation
Definition: rel.h:174
ItemPointerData pointer
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
IndexBulkDeleteResult * spgbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: spgvacuum.c:901
ambuild_function ambuild
Definition: amapi.h:214
amoptions_function amoptions
Definition: amapi.h:221
int fillfactor
Definition: pgbench.c:159
bool amcaninclude
Definition: amapi.h:199
#define SPGIST_PAGE_ID
#define GBUF_INNER_PARITY(x)
unsigned int prefixSize
amcostestimate_function amcostestimate
Definition: amapi.h:220
bool amcanunique
Definition: amapi.h:181
#define SGITMAXSIZE
#define SGITDATAPTR(x)
amvacuumcleanup_function amvacuumcleanup
Definition: amapi.h:218
amendscan_function amendscan
Definition: amapi.h:229
bool amcanbackward
Definition: amapi.h:179
#define FirstOffsetNumber
Definition: off.h:27
SpGistInnerTuple spgFormInnerTuple(SpGistState *state, bool hasPrefix, Datum prefix, int nNodes, SpGistNodeTuple *nodes)
Definition: spgutils.c:726
#define SPGIST_METAPAGE_BLKNO
void initSpGistState(SpGistState *state, Relation index)
Definition: spgutils.c:185
SpGistDeadTupleData * SpGistDeadTuple
#define InvalidTransactionId
Definition: transam.h:31
#define RelationGetRelationName(relation)
Definition: rel.h:462
int64 spggetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: spgscan.c:889
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define SpGistBlockIsFixed(blkno)
TransactionId myXid
void spgbuildempty(Relation index)
Definition: spginsert.c:156
#define INDEX_NULL_MASK
Definition: itup.h:69
TransactionId GetTopTransactionIdIfAny(void)
Definition: xact.c:409
void SpGistInitBuffer(Buffer b, uint16 f)
Definition: spgutils.c:553
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define SGITMAXNNODES
#define ereport(elevel, rest)
Definition: elog.h:141
amrescan_function amrescan
Definition: amapi.h:226
bool amcanparallel
Definition: amapi.h:197
bool ConditionalLockBuffer(Buffer buffer)
Definition: bufmgr.c:3638
#define SPGIST_META
#define SGLTHDRSZ
#define GBUF_LEAF
bytea * spgoptions(Datum reloptions, bool validate)
Definition: spgutils.c:590
unsigned int SpGistGetTypeSize(SpGistTypeDesc *att, Datum datum)
Definition: spgutils.c:610
#define SPGIST_MAGIC_NUMBER
spgConfigOut config
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
SpGistLeafTuple spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr, Datum datum, bool isnull)
Definition: spgutils.c:647
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:402
bool amsearchnulls
Definition: amapi.h:189
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
SpGistLUPCache lastUsedPages
void * palloc0(Size size)
Definition: mcxt.c:980
unsigned int tupstate
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:452
uintptr_t Datum
Definition: postgres.h:367
#define BufferGetPageSize(buffer)
Definition: bufmgr.h:146
static char * label
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3612
#define SPGIST_PAGE_CAPACITY
char * deadTupleStorage
bool amclusterable
Definition: amapi.h:193
Oid prefixType
Definition: spgist.h:42
TupleDesc rd_att
Definition: rel.h:85
#define VARSIZE_ANY(PTR)
Definition: postgres.h:335
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:839
Buffer SpGistNewBuffer(Relation index)
Definition: spgutils.c:215
OffsetNumber nextOffset
bool amsearcharray
Definition: amapi.h:187
#define InvalidOffsetNumber
Definition: off.h:26
#define InvalidOid
Definition: postgres_ext.h:36
#define GBUF_PARITY_MASK
bool amusemaintenanceworkmem
Definition: amapi.h:201
BlockNumber GetFreeIndexPage(Relation rel)
Definition: indexfsm.c:38
#define SpGistPageStoresNulls(page)
void spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Definition: selfuncs.c:6296
#define makeNode(_type_)
Definition: nodes.h:573
PageHeaderData * PageHeader
Definition: bufpage.h:166
#define Assert(condition)
Definition: c.h:739
#define VACUUM_OPTION_PARALLEL_COND_CLEANUP
Definition: vacuum.h:52
Definition: regguts.h:298
#define SpGistPageIsDeleted(page)
#define SGNTDATAPTR(x)
Buffer SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew)
Definition: spgutils.c:399
#define SPGIST_COMPRESS_PROC
Definition: spgist.h:28
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:596
#define SPGIST_CONFIG_PROC
Definition: spgist.h:23
size_t Size
Definition: c.h:467
void SpGistInitMetapage(Page page)
Definition: spgutils.c:563
#define InvalidBlockNumber
Definition: block.h:33
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2029
#define MAXALIGN(LEN)
Definition: c.h:692
#define GBUF_NULLS
OffsetNumber nextOffset
ammarkpos_function ammarkpos
Definition: amapi.h:230
bool amcanorder
Definition: amapi.h:175
ambuildphasename_function ambuildphasename
Definition: amapi.h:223
#define VACUUM_OPTION_PARALLEL_BULKDEL
Definition: vacuum.h:45
#define SPGIST_CACHED_PAGES
#define SpGistPageGetMeta(p)
amestimateparallelscan_function amestimateparallelscan
Definition: amapi.h:234
SpGistTypeDesc attLabelType
IndexBuildResult * spgbuild(Relation heap, Relation index, IndexInfo *indexInfo)
Definition: spginsert.c:75
#define DatumGetPointer(X)
Definition: postgres.h:549
Size PageGetExactFreeSpace(Page page)
Definition: bufpage.c:632
#define SpGistPageGetOpaque(page)
uint16 amstrategies
Definition: amapi.h:171
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2623
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
Oid get_index_column_opclass(Oid index_oid, int attno)
Definition: lsyscache.c:3164
static void memcpyDatum(void *target, SpGistTypeDesc *att, Datum datum)
Definition: spgutils.c:628
#define PageIsNew(page)
Definition: bufpage.h:229
void SpGistInitPage(Page page, uint16 f)
Definition: spgutils.c:538
void * palloc(Size size)
Definition: mcxt.c:949
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define SPGISTNProc
Definition: spgist.h:30
bool spgvalidate(Oid opclassoid)
Definition: spgvalidate.c:39
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
bool spggettuple(IndexScanDesc scan, ScanDirection dir)
Definition: spgscan.c:961
#define elog(elevel,...)
Definition: elog.h:228
ambuildempty_function ambuildempty
Definition: amapi.h:215
MemoryContext rd_indexcxt
Definition: rel.h:161
Oid labelType
Definition: spgist.h:43
int i
Oid leafType
Definition: spgist.h:44
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:87
#define SpGistGetTargetPageFreeSpace(relation)
SpGistTypeDesc attPrefixType
Definition: c.h:556
#define PG_FUNCTION_ARGS
Definition: fmgr.h:188
#define SGNTDATUM(x, s)
IndexScanDesc spgbeginscan(Relation rel, int keysz, int orderbysz)
Definition: spgscan.c:295
HeapTupleData tuple
Definition: catcache.h:121
static void fillTypeDesc(SpGistTypeDesc *desc, Oid type)
Definition: spgutils.c:92
ItemPointerData heapPtr
unsigned short t_info
Definition: itup.h:49
#define TransactionIdIsValid(xid)
Definition: transam.h:41
void * rd_amcache
Definition: rel.h:185
SpGistLeafTupleData * SpGistLeafTuple
#define SPGIST_LEAF
int Buffer
Definition: buf.h:23
amcanreturn_function amcanreturn
Definition: amapi.h:219
OffsetNumber SpGistPageAddNewItem(SpGistState *state, Page page, Item item, Size size, OffsetNumber *startOffset, bool errorOK)
Definition: spgutils.c:882
SpGistNodeTuple spgFormNodeTuple(SpGistState *state, Datum label, bool isnull)
Definition: spgutils.c:684
#define offsetof(type, field)
Definition: c.h:662
#define SGITHDRSZ
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
Pointer Page
Definition: bufpage.h:78
#define IndexTupleSize(itup)
Definition: itup.h:71
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127
aminitparallelscan_function aminitparallelscan
Definition: amapi.h:235
Datum spghandler(PG_FUNCTION_ARGS)
Definition: spgutils.c:41
amrestrpos_function amrestrpos
Definition: amapi.h:231
SpGistNodeTupleData * SpGistNodeTuple
void PageInit(Page page, Size pageSize, Size specialSize)
Definition: bufpage.c:42
#define GBUF_REQ_LEAF(flags)
RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:760