PostgreSQL Source Code  git master
ginutil.c File Reference
#include "postgres.h"
#include "access/gin_private.h"
#include "access/ginxlog.h"
#include "access/reloptions.h"
#include "access/xloginsert.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
#include "storage/predicate.h"
#include "utils/builtins.h"
#include "utils/index_selfuncs.h"
#include "utils/typcache.h"
Include dependency graph for ginutil.c:

Go to the source code of this file.

Data Structures

struct  keyEntryData
 
struct  cmpEntriesArg
 

Functions

Datum ginhandler (PG_FUNCTION_ARGS)
 
void initGinState (GinState *state, Relation index)
 
OffsetNumber gintuple_get_attrnum (GinState *ginstate, IndexTuple tuple)
 
Datum gintuple_get_key (GinState *ginstate, IndexTuple tuple, GinNullCategory *category)
 
Buffer GinNewBuffer (Relation index)
 
void GinInitPage (Page page, uint32 f, Size pageSize)
 
void GinInitBuffer (Buffer b, uint32 f)
 
void GinInitMetabuffer (Buffer b)
 
int ginCompareEntries (GinState *ginstate, OffsetNumber attnum, Datum a, GinNullCategory categorya, Datum b, GinNullCategory categoryb)
 
int ginCompareAttEntries (GinState *ginstate, OffsetNumber attnuma, Datum a, GinNullCategory categorya, OffsetNumber attnumb, Datum b, GinNullCategory categoryb)
 
static int cmpEntries (const void *a, const void *b, void *arg)
 
DatumginExtractEntries (GinState *ginstate, OffsetNumber attnum, Datum value, bool isNull, int32 *nentries, GinNullCategory **categories)
 
byteaginoptions (Datum reloptions, bool validate)
 
void ginGetStats (Relation index, GinStatsData *stats)
 
void ginUpdateStats (Relation index, const GinStatsData *stats, bool is_build)
 

Function Documentation

◆ cmpEntries()

static int cmpEntries ( const void *  a,
const void *  b,
void *  arg 
)
static

Definition at line 444 of file ginutil.c.

References cmpEntriesArg::cmpDatumFunc, cmpEntriesArg::collation, keyEntryData::datum, DatumGetInt32, FunctionCall2Coll(), cmpEntriesArg::haveDups, and keyEntryData::isnull.

Referenced by ginExtractEntries().

445 {
446  const keyEntryData *aa = (const keyEntryData *) a;
447  const keyEntryData *bb = (const keyEntryData *) b;
448  cmpEntriesArg *data = (cmpEntriesArg *) arg;
449  int res;
450 
451  if (aa->isnull)
452  {
453  if (bb->isnull)
454  res = 0; /* NULL "=" NULL */
455  else
456  res = 1; /* NULL ">" not-NULL */
457  }
458  else if (bb->isnull)
459  res = -1; /* not-NULL "<" NULL */
460  else
462  data->collation,
463  aa->datum, bb->datum));
464 
465  /*
466  * Detect if we have any duplicates. If there are equal keys, qsort must
467  * compare them at some point, else it wouldn't know whether one should go
468  * before or after the other.
469  */
470  if (res == 0)
471  data->haveDups = true;
472 
473  return res;
474 }
FmgrInfo * cmpDatumFunc
Definition: ginutil.c:438
#define DatumGetInt32(X)
Definition: postgres.h:472
bool isnull
Definition: ginutil.c:433
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1150
Datum datum
Definition: ginutil.c:432
bool haveDups
Definition: ginutil.c:440
Oid collation
Definition: ginutil.c:439
void * arg

◆ ginCompareAttEntries()

int ginCompareAttEntries ( GinState ginstate,
OffsetNumber  attnuma,
Datum  a,
GinNullCategory  categorya,
OffsetNumber  attnumb,
Datum  b,
GinNullCategory  categoryb 
)

Definition at line 411 of file ginutil.c.

References ginCompareEntries().

Referenced by cmpEntryAccumulator(), entryIsMoveRight(), entryLocateEntry(), and entryLocateLeafEntry().

414 {
415  /* attribute number is the first sort key */
416  if (attnuma != attnumb)
417  return (attnuma < attnumb) ? -1 : 1;
418 
419  return ginCompareEntries(ginstate, attnuma, a, categorya, b, categoryb);
420 }
int ginCompareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, GinNullCategory categorya, Datum b, GinNullCategory categoryb)
Definition: ginutil.c:389

◆ ginCompareEntries()

int ginCompareEntries ( GinState ginstate,
OffsetNumber  attnum,
Datum  a,
GinNullCategory  categorya,
Datum  b,
GinNullCategory  categoryb 
)

Definition at line 389 of file ginutil.c.

References GinState::compareFn, DatumGetInt32, FunctionCall2Coll(), GIN_CAT_NORM_KEY, and GinState::supportCollation.

Referenced by collectMatchBitmap(), collectMatchesForHeapRow(), ginCompareAttEntries(), and ginFillScanEntry().

392 {
393  /* if not of same null category, sort by that first */
394  if (categorya != categoryb)
395  return (categorya < categoryb) ? -1 : 1;
396 
397  /* all null items in same category are equal */
398  if (categorya != GIN_CAT_NORM_KEY)
399  return 0;
400 
401  /* both not null, so safe to call the compareFn */
402  return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attnum - 1],
403  ginstate->supportCollation[attnum - 1],
404  a, b));
405 }
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gin_private.h:87
#define DatumGetInt32(X)
Definition: postgres.h:472
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1150
#define GIN_CAT_NORM_KEY
Definition: ginblock.h:209
int16 attnum
Definition: pg_attribute.h:79
FmgrInfo compareFn[INDEX_MAX_KEYS]
Definition: gin_private.h:78

◆ ginExtractEntries()

Datum* ginExtractEntries ( GinState ginstate,
OffsetNumber  attnum,
Datum  value,
bool  isNull,
int32 nentries,
GinNullCategory **  categories 
)

Definition at line 484 of file ginutil.c.

References arg, cmpEntriesArg::cmpDatumFunc, cmpEntries(), cmpEntriesArg::collation, GinState::compareFn, keyEntryData::datum, DatumGetPointer, GinState::extractValueFn, FunctionCall3Coll(), GIN_CAT_EMPTY_ITEM, GIN_CAT_NORM_KEY, GIN_CAT_NULL_ITEM, GIN_CAT_NULL_KEY, cmpEntriesArg::haveDups, i, keyEntryData::isnull, palloc(), palloc0(), pfree(), PointerGetDatum, qsort_arg(), and GinState::supportCollation.

Referenced by ginHeapTupleBulkInsert(), ginHeapTupleFastCollect(), and ginHeapTupleInsert().

487 {
488  Datum *entries;
489  bool *nullFlags;
490  int32 i;
491 
492  /*
493  * We don't call the extractValueFn on a null item. Instead generate a
494  * placeholder.
495  */
496  if (isNull)
497  {
498  *nentries = 1;
499  entries = (Datum *) palloc(sizeof(Datum));
500  entries[0] = (Datum) 0;
501  *categories = (GinNullCategory *) palloc(sizeof(GinNullCategory));
502  (*categories)[0] = GIN_CAT_NULL_ITEM;
503  return entries;
504  }
505 
506  /* OK, call the opclass's extractValueFn */
507  nullFlags = NULL; /* in case extractValue doesn't set it */
508  entries = (Datum *)
510  ginstate->supportCollation[attnum - 1],
511  value,
512  PointerGetDatum(nentries),
513  PointerGetDatum(&nullFlags)));
514 
515  /*
516  * Generate a placeholder if the item contained no keys.
517  */
518  if (entries == NULL || *nentries <= 0)
519  {
520  *nentries = 1;
521  entries = (Datum *) palloc(sizeof(Datum));
522  entries[0] = (Datum) 0;
523  *categories = (GinNullCategory *) palloc(sizeof(GinNullCategory));
524  (*categories)[0] = GIN_CAT_EMPTY_ITEM;
525  return entries;
526  }
527 
528  /*
529  * If the extractValueFn didn't create a nullFlags array, create one,
530  * assuming that everything's non-null.
531  */
532  if (nullFlags == NULL)
533  nullFlags = (bool *) palloc0(*nentries * sizeof(bool));
534 
535  /*
536  * If there's more than one key, sort and unique-ify.
537  *
538  * XXX Using qsort here is notationally painful, and the overhead is
539  * pretty bad too. For small numbers of keys it'd likely be better to use
540  * a simple insertion sort.
541  */
542  if (*nentries > 1)
543  {
544  keyEntryData *keydata;
546 
547  keydata = (keyEntryData *) palloc(*nentries * sizeof(keyEntryData));
548  for (i = 0; i < *nentries; i++)
549  {
550  keydata[i].datum = entries[i];
551  keydata[i].isnull = nullFlags[i];
552  }
553 
554  arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1];
555  arg.collation = ginstate->supportCollation[attnum - 1];
556  arg.haveDups = false;
557  qsort_arg(keydata, *nentries, sizeof(keyEntryData),
558  cmpEntries, (void *) &arg);
559 
560  if (arg.haveDups)
561  {
562  /* there are duplicates, must get rid of 'em */
563  int32 j;
564 
565  entries[0] = keydata[0].datum;
566  nullFlags[0] = keydata[0].isnull;
567  j = 1;
568  for (i = 1; i < *nentries; i++)
569  {
570  if (cmpEntries(&keydata[i - 1], &keydata[i], &arg) != 0)
571  {
572  entries[j] = keydata[i].datum;
573  nullFlags[j] = keydata[i].isnull;
574  j++;
575  }
576  }
577  *nentries = j;
578  }
579  else
580  {
581  /* easy, no duplicates */
582  for (i = 0; i < *nentries; i++)
583  {
584  entries[i] = keydata[i].datum;
585  nullFlags[i] = keydata[i].isnull;
586  }
587  }
588 
589  pfree(keydata);
590  }
591 
592  /*
593  * Create GinNullCategory representation from nullFlags.
594  */
595  *categories = (GinNullCategory *) palloc0(*nentries * sizeof(GinNullCategory));
596  for (i = 0; i < *nentries; i++)
597  (*categories)[i] = (nullFlags[i] ? GIN_CAT_NULL_KEY : GIN_CAT_NORM_KEY);
598 
599  return entries;
600 }
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gin_private.h:87
FmgrInfo * cmpDatumFunc
Definition: ginutil.c:438
bool isnull
Definition: ginutil.c:433
#define PointerGetDatum(X)
Definition: postgres.h:556
static struct @145 value
FmgrInfo extractValueFn[INDEX_MAX_KEYS]
Definition: gin_private.h:79
Datum datum
Definition: ginutil.c:432
signed int int32
Definition: c.h:347
void pfree(void *pointer)
Definition: mcxt.c:1056
signed char GinNullCategory
Definition: ginblock.h:207
bool haveDups
Definition: ginutil.c:440
#define GIN_CAT_NORM_KEY
Definition: ginblock.h:209
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
Definition: qsort_arg.c:113
#define GIN_CAT_NULL_KEY
Definition: ginblock.h:210
void * palloc0(Size size)
Definition: mcxt.c:980
uintptr_t Datum
Definition: postgres.h:367
#define GIN_CAT_NULL_ITEM
Definition: ginblock.h:212
int16 attnum
Definition: pg_attribute.h:79
Datum FunctionCall3Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
Definition: fmgr.c:1172
Oid collation
Definition: ginutil.c:439
#define DatumGetPointer(X)
Definition: postgres.h:549
void * palloc(Size size)
Definition: mcxt.c:949
int i
void * arg
#define GIN_CAT_EMPTY_ITEM
Definition: ginblock.h:211
static int cmpEntries(const void *a, const void *b, void *arg)
Definition: ginutil.c:444
FmgrInfo compareFn[INDEX_MAX_KEYS]
Definition: gin_private.h:78

◆ ginGetStats()

void ginGetStats ( Relation  index,
GinStatsData stats 
)

Definition at line 624 of file ginutil.c.

References BufferGetPage, GIN_METAPAGE_BLKNO, GIN_SHARE, GinPageGetMeta, GinStatsData::ginVersion, GinMetaPageData::ginVersion, LockBuffer(), GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, GinStatsData::nPendingPages, GinMetaPageData::nPendingPages, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, ReadBuffer(), and UnlockReleaseBuffer().

Referenced by gincostestimate(), and ginNewScanKey().

625 {
626  Buffer metabuffer;
627  Page metapage;
628  GinMetaPageData *metadata;
629 
630  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
631  LockBuffer(metabuffer, GIN_SHARE);
632  metapage = BufferGetPage(metabuffer);
633  metadata = GinPageGetMeta(metapage);
634 
635  stats->nPendingPages = metadata->nPendingPages;
636  stats->nTotalPages = metadata->nTotalPages;
637  stats->nEntryPages = metadata->nEntryPages;
638  stats->nDataPages = metadata->nDataPages;
639  stats->nEntries = metadata->nEntries;
640  stats->ginVersion = metadata->ginVersion;
641 
642  UnlockReleaseBuffer(metabuffer);
643 }
BlockNumber nEntryPages
Definition: ginblock.h:80
BlockNumber nEntryPages
Definition: gin.h:45
int64 nEntries
Definition: gin.h:47
BlockNumber nTotalPages
Definition: ginblock.h:79
#define GIN_METAPAGE_BLKNO
Definition: ginblock.h:51
int64 nEntries
Definition: ginblock.h:82
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3388
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define GIN_SHARE
Definition: gin_private.h:49
BlockNumber nPendingPages
Definition: gin.h:43
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3602
BlockNumber nDataPages
Definition: gin.h:46
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:596
BlockNumber nTotalPages
Definition: gin.h:44
int32 ginVersion
Definition: ginblock.h:99
int32 ginVersion
Definition: gin.h:48
BlockNumber nDataPages
Definition: ginblock.h:81
#define GinPageGetMeta(p)
Definition: ginblock.h:104
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78
BlockNumber nPendingPages
Definition: ginblock.h:73

◆ ginhandler()

Datum ginhandler ( PG_FUNCTION_ARGS  )

Definition at line 37 of file ginutil.c.

References IndexAmRoutine::ambeginscan, IndexAmRoutine::ambuild, IndexAmRoutine::ambuildempty, IndexAmRoutine::ambuildphasename, IndexAmRoutine::ambulkdelete, IndexAmRoutine::amcanbackward, IndexAmRoutine::amcaninclude, IndexAmRoutine::amcanmulticol, IndexAmRoutine::amcanorder, IndexAmRoutine::amcanorderbyop, IndexAmRoutine::amcanparallel, IndexAmRoutine::amcanreturn, IndexAmRoutine::amcanunique, IndexAmRoutine::amclusterable, IndexAmRoutine::amcostestimate, IndexAmRoutine::amendscan, IndexAmRoutine::amestimateparallelscan, IndexAmRoutine::amgetbitmap, IndexAmRoutine::amgettuple, IndexAmRoutine::aminitparallelscan, IndexAmRoutine::aminsert, IndexAmRoutine::amkeytype, IndexAmRoutine::ammarkpos, IndexAmRoutine::amoptionalkey, IndexAmRoutine::amoptions, IndexAmRoutine::amparallelrescan, IndexAmRoutine::ampredlocks, IndexAmRoutine::amproperty, IndexAmRoutine::amrescan, IndexAmRoutine::amrestrpos, IndexAmRoutine::amsearcharray, IndexAmRoutine::amsearchnulls, IndexAmRoutine::amstorage, IndexAmRoutine::amstrategies, IndexAmRoutine::amsupport, IndexAmRoutine::amvacuumcleanup, IndexAmRoutine::amvalidate, ginbeginscan(), ginbuild(), ginbuildempty(), ginbulkdelete(), gincostestimate(), ginendscan(), gingetbitmap(), gininsert(), GINNProcs, ginoptions(), ginrescan(), ginvacuumcleanup(), ginvalidate(), InvalidOid, makeNode, and PG_RETURN_POINTER.

38 {
40 
41  amroutine->amstrategies = 0;
42  amroutine->amsupport = GINNProcs;
43  amroutine->amcanorder = false;
44  amroutine->amcanorderbyop = false;
45  amroutine->amcanbackward = false;
46  amroutine->amcanunique = false;
47  amroutine->amcanmulticol = true;
48  amroutine->amoptionalkey = true;
49  amroutine->amsearcharray = false;
50  amroutine->amsearchnulls = false;
51  amroutine->amstorage = true;
52  amroutine->amclusterable = false;
53  amroutine->ampredlocks = true;
54  amroutine->amcanparallel = false;
55  amroutine->amcaninclude = false;
56  amroutine->amkeytype = InvalidOid;
57 
58  amroutine->ambuild = ginbuild;
59  amroutine->ambuildempty = ginbuildempty;
60  amroutine->aminsert = gininsert;
61  amroutine->ambulkdelete = ginbulkdelete;
62  amroutine->amvacuumcleanup = ginvacuumcleanup;
63  amroutine->amcanreturn = NULL;
64  amroutine->amcostestimate = gincostestimate;
65  amroutine->amoptions = ginoptions;
66  amroutine->amproperty = NULL;
67  amroutine->ambuildphasename = NULL;
68  amroutine->amvalidate = ginvalidate;
69  amroutine->ambeginscan = ginbeginscan;
70  amroutine->amrescan = ginrescan;
71  amroutine->amgettuple = NULL;
72  amroutine->amgetbitmap = gingetbitmap;
73  amroutine->amendscan = ginendscan;
74  amroutine->ammarkpos = NULL;
75  amroutine->amrestrpos = NULL;
76  amroutine->amestimateparallelscan = NULL;
77  amroutine->aminitparallelscan = NULL;
78  amroutine->amparallelrescan = NULL;
79 
80  PG_RETURN_POINTER(amroutine);
81 }
ambeginscan_function ambeginscan
Definition: amapi.h:221
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
IndexBulkDeleteResult * ginvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: ginvacuum.c:684
IndexScanDesc ginbeginscan(Relation rel, int nkeys, int norderbys)
Definition: ginscan.c:25
int64 gingetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: ginget.c:1849
void ginendscan(IndexScanDesc scan)
Definition: ginscan.c:429
ambulkdelete_function ambulkdelete
Definition: amapi.h:213
void ginrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: ginscan.c:413
bool amcanmulticol
Definition: amapi.h:183
uint16 amsupport
Definition: amapi.h:173
amgettuple_function amgettuple
Definition: amapi.h:223
void gincostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Definition: selfuncs.c:6641
bool amcanorderbyop
Definition: amapi.h:177
amproperty_function amproperty
Definition: amapi.h:218
amparallelrescan_function amparallelrescan
Definition: amapi.h:232
bool amstorage
Definition: amapi.h:191
bool ampredlocks
Definition: amapi.h:195
void ginbuildempty(Relation index)
Definition: gininsert.c:435
aminsert_function aminsert
Definition: amapi.h:212
Oid amkeytype
Definition: amapi.h:201
bool amoptionalkey
Definition: amapi.h:185
amvalidate_function amvalidate
Definition: amapi.h:220
amgetbitmap_function amgetbitmap
Definition: amapi.h:224
IndexBuildResult * ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
Definition: gininsert.c:318
ambuild_function ambuild
Definition: amapi.h:210
amoptions_function amoptions
Definition: amapi.h:217
bool ginvalidate(Oid opclassoid)
Definition: ginvalidate.c:33
bool amcaninclude
Definition: amapi.h:199
amcostestimate_function amcostestimate
Definition: amapi.h:216
bool gininsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, IndexInfo *indexInfo)
Definition: gininsert.c:486
bool amcanunique
Definition: amapi.h:181
amvacuumcleanup_function amvacuumcleanup
Definition: amapi.h:214
amendscan_function amendscan
Definition: amapi.h:225
bool amcanbackward
Definition: amapi.h:179
#define GINNProcs
Definition: gin.h:28
amrescan_function amrescan
Definition: amapi.h:222
bool amcanparallel
Definition: amapi.h:197
bytea * ginoptions(Datum reloptions, bool validate)
Definition: ginutil.c:603
bool amsearchnulls
Definition: amapi.h:189
bool amclusterable
Definition: amapi.h:193
bool amsearcharray
Definition: amapi.h:187
#define InvalidOid
Definition: postgres_ext.h:36
#define makeNode(_type_)
Definition: nodes.h:573
IndexBulkDeleteResult * ginbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: ginvacuum.c:561
ammarkpos_function ammarkpos
Definition: amapi.h:226
bool amcanorder
Definition: amapi.h:175
ambuildphasename_function ambuildphasename
Definition: amapi.h:219
amestimateparallelscan_function amestimateparallelscan
Definition: amapi.h:230
uint16 amstrategies
Definition: amapi.h:171
ambuildempty_function ambuildempty
Definition: amapi.h:211
amcanreturn_function amcanreturn
Definition: amapi.h:215
aminitparallelscan_function aminitparallelscan
Definition: amapi.h:231
amrestrpos_function amrestrpos
Definition: amapi.h:227

◆ GinInitBuffer()

void GinInitBuffer ( Buffer  b,
uint32  f 
)

Definition at line 351 of file ginutil.c.

References BufferGetPage, BufferGetPageSize, and GinInitPage().

Referenced by ginbuild(), ginbuildempty(), ginRedoCreatePTree(), ginRedoDeleteListPages(), ginRedoInsertListPage(), and writeListPage().

352 {
354 }
void GinInitPage(Page page, uint32 f, Size pageSize)
Definition: ginutil.c:338
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define BufferGetPageSize(buffer)
Definition: bufmgr.h:146

◆ GinInitMetabuffer()

void GinInitMetabuffer ( Buffer  b)

Definition at line 357 of file ginutil.c.

References BufferGetPage, BufferGetPageSize, GIN_CURRENT_VERSION, GIN_META, GinInitPage(), GinPageGetMeta, GinMetaPageData::ginVersion, GinMetaPageData::head, InvalidBlockNumber, GinMetaPageData::nDataPages, GinMetaPageData::nEntries, GinMetaPageData::nEntryPages, GinMetaPageData::nPendingHeapTuples, GinMetaPageData::nPendingPages, GinMetaPageData::nTotalPages, GinMetaPageData::tail, and GinMetaPageData::tailFreeSize.

Referenced by ginbuild(), ginbuildempty(), ginRedoDeleteListPages(), and ginRedoUpdateMetapage().

358 {
359  GinMetaPageData *metadata;
360  Page page = BufferGetPage(b);
361 
363 
364  metadata = GinPageGetMeta(page);
365 
366  metadata->head = metadata->tail = InvalidBlockNumber;
367  metadata->tailFreeSize = 0;
368  metadata->nPendingPages = 0;
369  metadata->nPendingHeapTuples = 0;
370  metadata->nTotalPages = 0;
371  metadata->nEntryPages = 0;
372  metadata->nDataPages = 0;
373  metadata->nEntries = 0;
374  metadata->ginVersion = GIN_CURRENT_VERSION;
375 
376  /*
377  * Set pd_lower just past the end of the metadata. This is essential,
378  * because without doing so, metadata will be lost if xlog.c compresses
379  * the page.
380  */
381  ((PageHeader) page)->pd_lower =
382  ((char *) metadata + sizeof(GinMetaPageData)) - (char *) page;
383 }
BlockNumber nEntryPages
Definition: ginblock.h:80
void GinInitPage(Page page, uint32 f, Size pageSize)
Definition: ginutil.c:338
BlockNumber nTotalPages
Definition: ginblock.h:79
int64 nEntries
Definition: ginblock.h:82
int64 nPendingHeapTuples
Definition: ginblock.h:74
#define GIN_META
Definition: ginblock.h:43
BlockNumber head
Definition: ginblock.h:61
BlockNumber tail
Definition: ginblock.h:62
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define BufferGetPageSize(buffer)
Definition: bufmgr.h:146
PageHeaderData * PageHeader
Definition: bufpage.h:166
uint32 tailFreeSize
Definition: ginblock.h:67
#define GIN_CURRENT_VERSION
Definition: ginblock.h:102
#define InvalidBlockNumber
Definition: block.h:33
int32 ginVersion
Definition: ginblock.h:99
BlockNumber nDataPages
Definition: ginblock.h:81
#define GinPageGetMeta(p)
Definition: ginblock.h:104
Pointer Page
Definition: bufpage.h:78
BlockNumber nPendingPages
Definition: ginblock.h:73

◆ GinInitPage()

void GinInitPage ( Page  page,
uint32  f,
Size  pageSize 
)

Definition at line 338 of file ginutil.c.

References GinPageOpaqueData::flags, GinPageGetOpaque, InvalidBlockNumber, PageInit(), and GinPageOpaqueData::rightlink.

Referenced by createPostingTree(), dataPlaceToPageLeafSplit(), dataSplitPageInternal(), entrySplitPage(), GinInitBuffer(), GinInitMetabuffer(), and ginPlaceToPage().

339 {
340  GinPageOpaque opaque;
341 
342  PageInit(page, pageSize, sizeof(GinPageOpaqueData));
343 
344  opaque = GinPageGetOpaque(page);
345  memset(opaque, 0, sizeof(GinPageOpaqueData));
346  opaque->flags = f;
347  opaque->rightlink = InvalidBlockNumber;
348 }
BlockNumber rightlink
Definition: ginblock.h:31
#define GinPageGetOpaque(page)
Definition: ginblock.h:110
#define InvalidBlockNumber
Definition: block.h:33
void PageInit(Page page, Size pageSize, Size specialSize)
Definition: bufpage.c:42

◆ GinNewBuffer()

Buffer GinNewBuffer ( Relation  index)

Definition at line 292 of file ginutil.c.

References BufferGetPage, ConditionalLockBuffer(), ExclusiveLock, GetFreeIndexPage(), GIN_EXCLUSIVE, GIN_UNLOCK, GinPageIsRecyclable, InvalidBlockNumber, LockBuffer(), LockRelationForExtension(), P_NEW, ReadBuffer(), RELATION_IS_LOCAL, ReleaseBuffer(), and UnlockRelationForExtension().

Referenced by createPostingTree(), ginbuild(), ginPlaceToPage(), and makeSublist().

293 {
294  Buffer buffer;
295  bool needLock;
296 
297  /* First, try to get a page from FSM */
298  for (;;)
299  {
300  BlockNumber blkno = GetFreeIndexPage(index);
301 
302  if (blkno == InvalidBlockNumber)
303  break;
304 
305  buffer = ReadBuffer(index, blkno);
306 
307  /*
308  * We have to guard against the possibility that someone else already
309  * recycled this page; the buffer may be locked if so.
310  */
311  if (ConditionalLockBuffer(buffer))
312  {
313  if (GinPageIsRecyclable(BufferGetPage(buffer)))
314  return buffer; /* OK to use */
315 
316  LockBuffer(buffer, GIN_UNLOCK);
317  }
318 
319  /* Can't use it, so release buffer and try again */
320  ReleaseBuffer(buffer);
321  }
322 
323  /* Must extend the file */
324  needLock = !RELATION_IS_LOCAL(index);
325  if (needLock)
327 
328  buffer = ReadBuffer(index, P_NEW);
329  LockBuffer(buffer, GIN_EXCLUSIVE);
330 
331  if (needLock)
333 
334  return buffer;
335 }
#define GIN_UNLOCK
Definition: gin_private.h:48
#define GinPageIsRecyclable(page)
Definition: ginblock.h:137
#define ExclusiveLock
Definition: lockdefs.h:44
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:542
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3365
#define P_NEW
Definition: bufmgr.h:81
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
bool ConditionalLockBuffer(Buffer buffer)
Definition: bufmgr.c:3628
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:402
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:452
#define GIN_EXCLUSIVE
Definition: gin_private.h:50
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3602
BlockNumber GetFreeIndexPage(Relation rel)
Definition: indexfsm.c:38
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:596
#define InvalidBlockNumber
Definition: block.h:33
int Buffer
Definition: buf.h:23

◆ ginoptions()

bytea* ginoptions ( Datum  reloptions,
bool  validate 
)

Definition at line 603 of file ginutil.c.

References build_reloptions(), lengthof, offsetof, RELOPT_KIND_GIN, RELOPT_TYPE_BOOL, and RELOPT_TYPE_INT.

Referenced by ginhandler().

604 {
605  static const relopt_parse_elt tab[] = {
606  {"fastupdate", RELOPT_TYPE_BOOL, offsetof(GinOptions, useFastUpdate)},
607  {"gin_pending_list_limit", RELOPT_TYPE_INT, offsetof(GinOptions,
608  pendingListCleanupSize)}
609  };
610 
611  return (bytea *) build_reloptions(reloptions, validate,
613  sizeof(GinOptions),
614  tab, lengthof(tab));
615 }
#define lengthof(array)
Definition: c.h:669
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
Definition: c.h:556
#define offsetof(type, field)
Definition: c.h:662

◆ gintuple_get_attrnum()

OffsetNumber gintuple_get_attrnum ( GinState ginstate,
IndexTuple  tuple 
)

Definition at line 218 of file ginutil.c.

References Assert, DatumGetUInt16, FirstOffsetNumber, index_getattr, GinState::oneCol, and GinState::tupdesc.

Referenced by addItemPointersToLeafTuple(), collectMatchBitmap(), collectMatchesForHeapRow(), entryIsMoveRight(), entryLocateEntry(), entryLocateLeafEntry(), gintuple_get_key(), ginVacuumEntryPage(), matchPartialInPendingList(), and processPendingPage().

219 {
220  OffsetNumber colN;
221 
222  if (ginstate->oneCol)
223  {
224  /* column number is not stored explicitly */
225  colN = FirstOffsetNumber;
226  }
227  else
228  {
229  Datum res;
230  bool isnull;
231 
232  /*
233  * First attribute is always int16, so we can safely use any tuple
234  * descriptor to obtain first attribute of tuple
235  */
236  res = index_getattr(tuple, FirstOffsetNumber, ginstate->tupdesc[0],
237  &isnull);
238  Assert(!isnull);
239 
240  colN = DatumGetUInt16(res);
241  Assert(colN >= FirstOffsetNumber && colN <= ginstate->origTupdesc->natts);
242  }
243 
244  return colN;
245 }
#define DatumGetUInt16(X)
Definition: postgres.h:458
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
uintptr_t Datum
Definition: postgres.h:367
TupleDesc tupdesc[INDEX_MAX_KEYS]
Definition: gin_private.h:73
#define Assert(condition)
Definition: c.h:739
#define index_getattr(tup, attnum, tupleDesc, isnull)
Definition: itup.h:100
bool oneCol
Definition: gin_private.h:59

◆ gintuple_get_key()

Datum gintuple_get_key ( GinState ginstate,
IndexTuple  tuple,
GinNullCategory category 
)

Definition at line 251 of file ginutil.c.

References FirstOffsetNumber, GIN_CAT_NORM_KEY, GinGetNullCategory, gintuple_get_attrnum(), index_getattr, OffsetNumberNext, GinState::oneCol, GinState::origTupdesc, and GinState::tupdesc.

Referenced by addItemPointersToLeafTuple(), collectMatchBitmap(), collectMatchesForHeapRow(), entryIsMoveRight(), entryLocateEntry(), entryLocateLeafEntry(), ginVacuumEntryPage(), matchPartialInPendingList(), and processPendingPage().

253 {
254  Datum res;
255  bool isnull;
256 
257  if (ginstate->oneCol)
258  {
259  /*
260  * Single column index doesn't store attribute numbers in tuples
261  */
262  res = index_getattr(tuple, FirstOffsetNumber, ginstate->origTupdesc,
263  &isnull);
264  }
265  else
266  {
267  /*
268  * Since the datum type depends on which index column it's from, we
269  * must be careful to use the right tuple descriptor here.
270  */
271  OffsetNumber colN = gintuple_get_attrnum(ginstate, tuple);
272 
274  ginstate->tupdesc[colN - 1],
275  &isnull);
276  }
277 
278  if (isnull)
279  *category = GinGetNullCategory(tuple, ginstate);
280  else
281  *category = GIN_CAT_NORM_KEY;
282 
283  return res;
284 }
#define GinGetNullCategory(itup, ginstate)
Definition: ginblock.h:221
uint16 OffsetNumber
Definition: off.h:24
OffsetNumber gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple)
Definition: ginutil.c:218
#define GIN_CAT_NORM_KEY
Definition: ginblock.h:209
#define FirstOffsetNumber
Definition: off.h:27
uintptr_t Datum
Definition: postgres.h:367
TupleDesc tupdesc[INDEX_MAX_KEYS]
Definition: gin_private.h:73
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
#define index_getattr(tup, attnum, tupleDesc, isnull)
Definition: itup.h:100
TupleDesc origTupdesc
Definition: gin_private.h:72
bool oneCol
Definition: gin_private.h:59

◆ ginUpdateStats()

void ginUpdateStats ( Relation  index,
const GinStatsData stats,
bool  is_build 
)

Definition at line 651 of file ginutil.c.

References BufferGetPage, END_CRIT_SECTION, GIN_EXCLUSIVE, GIN_METAPAGE_BLKNO, GinPageGetMeta, InvalidBlockNumber, LockBuffer(), MarkBufferDirty(), ginxlogUpdateMeta::metadata, GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, ginxlogUpdateMeta::newRightlink, ginxlogUpdateMeta::node, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, ginxlogUpdateMeta::ntuples, PageSetLSN, ginxlogUpdateMeta::prevTail, RelationData::rd_node, ReadBuffer(), REGBUF_STANDARD, REGBUF_WILL_INIT, RelationNeedsWAL, START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_GIN_UPDATE_META_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by ginbuild(), and ginvacuumcleanup().

652 {
653  Buffer metabuffer;
654  Page metapage;
655  GinMetaPageData *metadata;
656 
657  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
658  LockBuffer(metabuffer, GIN_EXCLUSIVE);
659  metapage = BufferGetPage(metabuffer);
660  metadata = GinPageGetMeta(metapage);
661 
663 
664  metadata->nTotalPages = stats->nTotalPages;
665  metadata->nEntryPages = stats->nEntryPages;
666  metadata->nDataPages = stats->nDataPages;
667  metadata->nEntries = stats->nEntries;
668 
669  /*
670  * Set pd_lower just past the end of the metadata. This is essential,
671  * because without doing so, metadata will be lost if xlog.c compresses
672  * the page. (We must do this here because pre-v11 versions of PG did not
673  * set the metapage's pd_lower correctly, so a pg_upgraded index might
674  * contain the wrong value.)
675  */
676  ((PageHeader) metapage)->pd_lower =
677  ((char *) metadata + sizeof(GinMetaPageData)) - (char *) metapage;
678 
679  MarkBufferDirty(metabuffer);
680 
681  if (RelationNeedsWAL(index) && !is_build)
682  {
683  XLogRecPtr recptr;
684  ginxlogUpdateMeta data;
685 
686  data.node = index->rd_node;
687  data.ntuples = 0;
689  memcpy(&data.metadata, metadata, sizeof(GinMetaPageData));
690 
691  XLogBeginInsert();
692  XLogRegisterData((char *) &data, sizeof(ginxlogUpdateMeta));
694 
695  recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE);
696  PageSetLSN(metapage, recptr);
697  }
698 
699  UnlockReleaseBuffer(metabuffer);
700 
702 }
BlockNumber nEntryPages
Definition: ginblock.h:80
BlockNumber prevTail
Definition: ginxlog.h:172
BlockNumber nEntryPages
Definition: gin.h:45
RelFileNode node
Definition: ginxlog.h:170
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1458
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
#define REGBUF_WILL_INIT
Definition: xloginsert.h:33
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
int64 nEntries
Definition: gin.h:47
BlockNumber nTotalPages
Definition: ginblock.h:79
#define GIN_METAPAGE_BLKNO
Definition: ginblock.h:51
int64 nEntries
Definition: ginblock.h:82
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3388
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:162
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
BlockNumber newRightlink
Definition: ginxlog.h:173
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
#define GIN_EXCLUSIVE
Definition: gin_private.h:50
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3602
BlockNumber nDataPages
Definition: gin.h:46
GinMetaPageData metadata
Definition: ginxlog.h:171
RelFileNode rd_node
Definition: rel.h:54
PageHeaderData * PageHeader
Definition: bufpage.h:166
uint64 XLogRecPtr
Definition: xlogdefs.h:21
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:596
#define InvalidBlockNumber
Definition: block.h:33
BlockNumber nTotalPages
Definition: gin.h:44
#define RelationNeedsWAL(relation)
Definition: rel.h:524
BlockNumber nDataPages
Definition: ginblock.h:81
#define GinPageGetMeta(p)
Definition: ginblock.h:104
void XLogBeginInsert(void)
Definition: xloginsert.c:120
#define PageSetLSN(page, lsn)
Definition: bufpage.h:368
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78

◆ initGinState()

void initGinState ( GinState state,
Relation  index 
)

Definition at line 89 of file ginutil.c.

References GinState::canPartialMatch, TypeCacheEntry::cmp_proc_finfo, GinState::compareFn, GinState::comparePartialFn, GinState::consistentFn, CreateTemplateTupleDesc(), CurrentMemoryContext, elog, ereport, errcode(), errmsg(), ERROR, GinState::extractQueryFn, GinState::extractValueFn, fmgr_info_copy(), FmgrInfo::fn_oid, format_type_be(), GIN_COMPARE_PARTIAL_PROC, GIN_COMPARE_PROC, GIN_CONSISTENT_PROC, GIN_EXTRACTQUERY_PROC, GIN_EXTRACTVALUE_PROC, GIN_TRICONSISTENT_PROC, i, GinState::index, index_getprocid(), index_getprocinfo(), InvalidOid, lookup_type_cache(), MemSet, TupleDescData::natts, OidIsValid, GinState::oneCol, GinState::origTupdesc, RelationData::rd_indcollation, RelationGetDescr, RelationGetRelationName, GinState::supportCollation, GinState::triConsistentFn, GinState::tupdesc, TupleDescAttr, TupleDescInitEntry(), TupleDescInitEntryCollation(), and TYPECACHE_CMP_PROC_FINFO.

Referenced by gin_clean_pending_list(), ginbeginscan(), ginbuild(), ginbulkdelete(), gininsert(), and ginvacuumcleanup().

90 {
91  TupleDesc origTupdesc = RelationGetDescr(index);
92  int i;
93 
94  MemSet(state, 0, sizeof(GinState));
95 
96  state->index = index;
97  state->oneCol = (origTupdesc->natts == 1) ? true : false;
98  state->origTupdesc = origTupdesc;
99 
100  for (i = 0; i < origTupdesc->natts; i++)
101  {
102  Form_pg_attribute attr = TupleDescAttr(origTupdesc, i);
103 
104  if (state->oneCol)
105  state->tupdesc[i] = state->origTupdesc;
106  else
107  {
108  state->tupdesc[i] = CreateTemplateTupleDesc(2);
109 
110  TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 1, NULL,
111  INT2OID, -1, 0);
112  TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 2, NULL,
113  attr->atttypid,
114  attr->atttypmod,
115  attr->attndims);
117  attr->attcollation);
118  }
119 
120  /*
121  * If the compare proc isn't specified in the opclass definition, look
122  * up the index key type's default btree comparator.
123  */
124  if (index_getprocid(index, i + 1, GIN_COMPARE_PROC) != InvalidOid)
125  {
126  fmgr_info_copy(&(state->compareFn[i]),
127  index_getprocinfo(index, i + 1, GIN_COMPARE_PROC),
129  }
130  else
131  {
132  TypeCacheEntry *typentry;
133 
134  typentry = lookup_type_cache(attr->atttypid,
136  if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid))
137  ereport(ERROR,
138  (errcode(ERRCODE_UNDEFINED_FUNCTION),
139  errmsg("could not identify a comparison function for type %s",
140  format_type_be(attr->atttypid))));
141  fmgr_info_copy(&(state->compareFn[i]),
142  &(typentry->cmp_proc_finfo),
144  }
145 
146  /* Opclass must always provide extract procs */
147  fmgr_info_copy(&(state->extractValueFn[i]),
150  fmgr_info_copy(&(state->extractQueryFn[i]),
153 
154  /*
155  * Check opclass capability to do tri-state or binary logic consistent
156  * check.
157  */
158  if (index_getprocid(index, i + 1, GIN_TRICONSISTENT_PROC) != InvalidOid)
159  {
160  fmgr_info_copy(&(state->triConsistentFn[i]),
163  }
164 
165  if (index_getprocid(index, i + 1, GIN_CONSISTENT_PROC) != InvalidOid)
166  {
167  fmgr_info_copy(&(state->consistentFn[i]),
168  index_getprocinfo(index, i + 1, GIN_CONSISTENT_PROC),
170  }
171 
172  if (state->consistentFn[i].fn_oid == InvalidOid &&
173  state->triConsistentFn[i].fn_oid == InvalidOid)
174  {
175  elog(ERROR, "missing GIN support function (%d or %d) for attribute %d of index \"%s\"",
177  i + 1, RelationGetRelationName(index));
178  }
179 
180  /*
181  * Check opclass capability to do partial match.
182  */
184  {
185  fmgr_info_copy(&(state->comparePartialFn[i]),
188  state->canPartialMatch[i] = true;
189  }
190  else
191  {
192  state->canPartialMatch[i] = false;
193  }
194 
195  /*
196  * If the index column has a specified collation, we should honor that
197  * while doing comparisons. However, we may have a collatable storage
198  * type for a noncollatable indexed data type (for instance, hstore
199  * uses text index entries). If there's no index collation then
200  * specify default collation in case the support functions need
201  * collation. This is harmless if the support functions don't care
202  * about collation, so we just do it unconditionally. (We could
203  * alternatively call get_typcollation, but that seems like expensive
204  * overkill --- there aren't going to be any cases where a GIN storage
205  * type has a nondefault collation.)
206  */
207  if (OidIsValid(index->rd_indcollation[i]))
208  state->supportCollation[i] = index->rd_indcollation[i];
209  else
210  state->supportCollation[i] = DEFAULT_COLLATION_OID;
211  }
212 }
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gin_private.h:87
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:794
#define GIN_EXTRACTQUERY_PROC
Definition: gin.h:24
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:44
Relation index
Definition: gin_private.h:58
#define RelationGetDescr(relation)
Definition: rel.h:448
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
bool canPartialMatch[INDEX_MAX_KEYS]
Definition: gin_private.h:85
int errcode(int sqlerrcode)
Definition: elog.c:608
#define MemSet(start, val, len)
Definition: c.h:962
FmgrInfo consistentFn[INDEX_MAX_KEYS]
Definition: gin_private.h:81
char * format_type_be(Oid type_oid)
Definition: format_type.c:326
FmgrInfo extractValueFn[INDEX_MAX_KEYS]
Definition: gin_private.h:79
#define GIN_TRICONSISTENT_PROC
Definition: gin.h:27
#define GIN_COMPARE_PARTIAL_PROC
Definition: gin.h:26
#define OidIsValid(objectId)
Definition: c.h:645
FmgrInfo cmp_proc_finfo
Definition: typcache.h:73
Oid * rd_indcollation
Definition: rel.h:168
#define ERROR
Definition: elog.h:43
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
Definition: tupdesc.c:769
void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
Definition: fmgr.c:610
FmgrInfo comparePartialFn[INDEX_MAX_KEYS]
Definition: gin_private.h:83
#define GIN_CONSISTENT_PROC
Definition: gin.h:25
#define RelationGetRelationName(relation)
Definition: rel.h:456
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
FmgrInfo extractQueryFn[INDEX_MAX_KEYS]
Definition: gin_private.h:80
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:603
#define ereport(elevel, rest)
Definition: elog.h:141
TupleDesc tupdesc[INDEX_MAX_KEYS]
Definition: gin_private.h:73
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:322
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:59
#define GIN_EXTRACTVALUE_PROC
Definition: gin.h:23
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define elog(elevel,...)
Definition: elog.h:228
int i
TupleDesc origTupdesc
Definition: gin_private.h:72
#define TYPECACHE_CMP_PROC_FINFO
Definition: typcache.h:134
FmgrInfo triConsistentFn[INDEX_MAX_KEYS]
Definition: gin_private.h:82
bool oneCol
Definition: gin_private.h:59
int16 AttrNumber
Definition: attnum.h:21
#define GIN_COMPARE_PROC
Definition: gin.h:22
FmgrInfo compareFn[INDEX_MAX_KEYS]
Definition: gin_private.h:78
RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:760