PostgreSQL Source Code  git master
blutils.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * blutils.c
4  * Bloom index utilities.
5  *
6  * Portions Copyright (c) 2016-2019, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1990-1993, Regents of the University of California
8  *
9  * IDENTIFICATION
10  * contrib/bloom/blutils.c
11  *
12  *-------------------------------------------------------------------------
13  */
14 #include "postgres.h"
15 
16 #include "access/amapi.h"
17 #include "access/generic_xlog.h"
18 #include "access/reloptions.h"
19 #include "bloom.h"
20 #include "catalog/index.h"
21 #include "miscadmin.h"
22 #include "storage/bufmgr.h"
23 #include "storage/freespace.h"
24 #include "storage/indexfsm.h"
25 #include "storage/lmgr.h"
26 #include "utils/memutils.h"
27 
28 /* Signature dealing macros - note i is assumed to be of type int */
29 #define GETWORD(x,i) ( *( (BloomSignatureWord *)(x) + ( (i) / SIGNWORDBITS ) ) )
30 #define CLRBIT(x,i) GETWORD(x,i) &= ~( 0x01 << ( (i) % SIGNWORDBITS ) )
31 #define SETBIT(x,i) GETWORD(x,i) |= ( 0x01 << ( (i) % SIGNWORDBITS ) )
32 #define GETBIT(x,i) ( (GETWORD(x,i) >> ( (i) % SIGNWORDBITS )) & 0x01 )
33 
35 
36 /* Kind of relation options for bloom index */
38 
39 /* parse table for fillRelOptions */
41 
42 static int32 myRand(void);
43 static void mySrand(uint32 seed);
44 
45 /*
46  * Module initialize function: initialize info about Bloom relation options.
47  *
48  * Note: keep this in sync with makeDefaultBloomOptions().
49  */
50 void
51 _PG_init(void)
52 {
53  int i;
54  char buf[16];
55 
57 
58  /* Option for length of signature */
60  "Length of signature in bits",
63  bl_relopt_tab[0].optname = "length";
64  bl_relopt_tab[0].opttype = RELOPT_TYPE_INT;
65  bl_relopt_tab[0].offset = offsetof(BloomOptions, bloomLength);
66 
67  /* Number of bits for each possible index column: col1, col2, ... */
68  for (i = 0; i < INDEX_MAX_KEYS; i++)
69  {
70  snprintf(buf, sizeof(buf), "col%d", i + 1);
72  "Number of bits generated for each index column",
75  bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
76  buf);
77  bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
78  bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) + sizeof(int) * i;
79  }
80 }
81 
82 /*
83  * Construct a default set of Bloom options.
84  */
85 static BloomOptions *
87 {
88  BloomOptions *opts;
89  int i;
90 
91  opts = (BloomOptions *) palloc0(sizeof(BloomOptions));
92  /* Convert DEFAULT_BLOOM_LENGTH from # of bits to # of words */
94  for (i = 0; i < INDEX_MAX_KEYS; i++)
95  opts->bitSize[i] = DEFAULT_BLOOM_BITS;
96  SET_VARSIZE(opts, sizeof(BloomOptions));
97  return opts;
98 }
99 
100 /*
101  * Bloom handler function: return IndexAmRoutine with access method parameters
102  * and callbacks.
103  */
104 Datum
106 {
107  IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
108 
109  amroutine->amstrategies = BLOOM_NSTRATEGIES;
110  amroutine->amsupport = BLOOM_NPROC;
111  amroutine->amcanorder = false;
112  amroutine->amcanorderbyop = false;
113  amroutine->amcanbackward = false;
114  amroutine->amcanunique = false;
115  amroutine->amcanmulticol = true;
116  amroutine->amoptionalkey = true;
117  amroutine->amsearcharray = false;
118  amroutine->amsearchnulls = false;
119  amroutine->amstorage = false;
120  amroutine->amclusterable = false;
121  amroutine->ampredlocks = false;
122  amroutine->amcanparallel = false;
123  amroutine->amcaninclude = false;
124  amroutine->amkeytype = InvalidOid;
125 
126  amroutine->ambuild = blbuild;
127  amroutine->ambuildempty = blbuildempty;
128  amroutine->aminsert = blinsert;
129  amroutine->ambulkdelete = blbulkdelete;
130  amroutine->amvacuumcleanup = blvacuumcleanup;
131  amroutine->amcanreturn = NULL;
132  amroutine->amcostestimate = blcostestimate;
133  amroutine->amoptions = bloptions;
134  amroutine->amproperty = NULL;
135  amroutine->ambuildphasename = NULL;
136  amroutine->amvalidate = blvalidate;
137  amroutine->ambeginscan = blbeginscan;
138  amroutine->amrescan = blrescan;
139  amroutine->amgettuple = NULL;
140  amroutine->amgetbitmap = blgetbitmap;
141  amroutine->amendscan = blendscan;
142  amroutine->ammarkpos = NULL;
143  amroutine->amrestrpos = NULL;
144  amroutine->amestimateparallelscan = NULL;
145  amroutine->aminitparallelscan = NULL;
146  amroutine->amparallelrescan = NULL;
147 
148  PG_RETURN_POINTER(amroutine);
149 }
150 
151 /*
152  * Fill BloomState structure for particular index.
153  */
154 void
156 {
157  int i;
158 
159  state->nColumns = index->rd_att->natts;
160 
161  /* Initialize hash function for each attribute */
162  for (i = 0; i < index->rd_att->natts; i++)
163  {
164  fmgr_info_copy(&(state->hashFn[i]),
165  index_getprocinfo(index, i + 1, BLOOM_HASH_PROC),
167  state->collations[i] = index->rd_indcollation[i];
168  }
169 
170  /* Initialize amcache if needed with options from metapage */
171  if (!index->rd_amcache)
172  {
173  Buffer buffer;
174  Page page;
175  BloomMetaPageData *meta;
176  BloomOptions *opts;
177 
178  opts = MemoryContextAlloc(index->rd_indexcxt, sizeof(BloomOptions));
179 
180  buffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO);
181  LockBuffer(buffer, BUFFER_LOCK_SHARE);
182 
183  page = BufferGetPage(buffer);
184 
185  if (!BloomPageIsMeta(page))
186  elog(ERROR, "Relation is not a bloom index");
187  meta = BloomPageGetMeta(BufferGetPage(buffer));
188 
189  if (meta->magickNumber != BLOOM_MAGICK_NUMBER)
190  elog(ERROR, "Relation is not a bloom index");
191 
192  *opts = meta->opts;
193 
194  UnlockReleaseBuffer(buffer);
195 
196  index->rd_amcache = (void *) opts;
197  }
198 
199  memcpy(&state->opts, index->rd_amcache, sizeof(state->opts));
201  sizeof(BloomSignatureWord) * state->opts.bloomLength;
202 }
203 
204 /*
205  * Random generator copied from FreeBSD. Using own random generator here for
206  * two reasons:
207  *
208  * 1) In this case random numbers are used for on-disk storage. Usage of
209  * PostgreSQL number generator would obstruct it from all possible changes.
210  * 2) Changing seed of PostgreSQL random generator would be undesirable side
211  * effect.
212  */
213 static int32 next;
214 
215 static int32
216 myRand(void)
217 {
218  /*----------
219  * Compute x = (7^5 * x) mod (2^31 - 1)
220  * without overflowing 31 bits:
221  * (2^31 - 1) = 127773 * (7^5) + 2836
222  * From "Random number generators: good ones are hard to find",
223  * Park and Miller, Communications of the ACM, vol. 31, no. 10,
224  * October 1988, p. 1195.
225  *----------
226  */
227  int32 hi,
228  lo,
229  x;
230 
231  /* Must be in [1, 0x7ffffffe] range at this point. */
232  hi = next / 127773;
233  lo = next % 127773;
234  x = 16807 * lo - 2836 * hi;
235  if (x < 0)
236  x += 0x7fffffff;
237  next = x;
238  /* Transform to [0, 0x7ffffffd] range. */
239  return (x - 1);
240 }
241 
242 static void
244 {
245  next = seed;
246  /* Transform to [1, 0x7ffffffe] range. */
247  next = (next % 0x7ffffffe) + 1;
248 }
249 
250 /*
251  * Add bits of given value to the signature.
252  */
253 void
255 {
256  uint32 hashVal;
257  int nBit,
258  j;
259 
260  /*
261  * init generator with "column's" number to get "hashed" seed for new
262  * value. We don't want to map the same numbers from different columns
263  * into the same bits!
264  */
265  mySrand(attno);
266 
267  /*
268  * Init hash sequence to map our value into bits. the same values in
269  * different columns will be mapped into different bits because of step
270  * above
271  */
272  hashVal = DatumGetInt32(FunctionCall1Coll(&state->hashFn[attno], state->collations[attno], value));
273  mySrand(hashVal ^ myRand());
274 
275  for (j = 0; j < state->opts.bitSize[attno]; j++)
276  {
277  /* prevent multiple evaluation in SETBIT macro */
278  nBit = myRand() % (state->opts.bloomLength * SIGNWORDBITS);
279  SETBIT(sign, nBit);
280  }
281 }
282 
283 /*
284  * Make bloom tuple from values.
285  */
286 BloomTuple *
288 {
289  int i;
290  BloomTuple *res = (BloomTuple *) palloc0(state->sizeOfBloomTuple);
291 
292  res->heapPtr = *iptr;
293 
294  /* Blooming each column */
295  for (i = 0; i < state->nColumns; i++)
296  {
297  /* skip nulls */
298  if (isnull[i])
299  continue;
300 
301  signValue(state, res->sign, values[i], i);
302  }
303 
304  return res;
305 }
306 
307 /*
308  * Add new bloom tuple to the page. Returns true if new tuple was successfully
309  * added to the page. Returns false if it doesn't fit on the page.
310  */
311 bool
313 {
314  BloomTuple *itup;
315  BloomPageOpaque opaque;
316  Pointer ptr;
317 
318  /* We shouldn't be pointed to an invalid page */
319  Assert(!PageIsNew(page) && !BloomPageIsDeleted(page));
320 
321  /* Does new tuple fit on the page? */
322  if (BloomPageGetFreeSpace(state, page) < state->sizeOfBloomTuple)
323  return false;
324 
325  /* Copy new tuple to the end of page */
326  opaque = BloomPageGetOpaque(page);
327  itup = BloomPageGetTuple(state, page, opaque->maxoff + 1);
328  memcpy((Pointer) itup, (Pointer) tuple, state->sizeOfBloomTuple);
329 
330  /* Adjust maxoff and pd_lower */
331  opaque->maxoff++;
332  ptr = (Pointer) BloomPageGetTuple(state, page, opaque->maxoff + 1);
333  ((PageHeader) page)->pd_lower = ptr - page;
334 
335  /* Assert we didn't overrun available space */
336  Assert(((PageHeader) page)->pd_lower <= ((PageHeader) page)->pd_upper);
337 
338  return true;
339 }
340 
341 /*
342  * Allocate a new page (either by recycling, or by extending the index file)
343  * The returned buffer is already pinned and exclusive-locked
344  * Caller is responsible for initializing the page by calling BloomInitPage
345  */
346 Buffer
348 {
349  Buffer buffer;
350  bool needLock;
351 
352  /* First, try to get a page from FSM */
353  for (;;)
354  {
355  BlockNumber blkno = GetFreeIndexPage(index);
356 
357  if (blkno == InvalidBlockNumber)
358  break;
359 
360  buffer = ReadBuffer(index, blkno);
361 
362  /*
363  * We have to guard against the possibility that someone else already
364  * recycled this page; the buffer may be locked if so.
365  */
366  if (ConditionalLockBuffer(buffer))
367  {
368  Page page = BufferGetPage(buffer);
369 
370  if (PageIsNew(page))
371  return buffer; /* OK to use, if never initialized */
372 
373  if (BloomPageIsDeleted(page))
374  return buffer; /* OK to use */
375 
377  }
378 
379  /* Can't use it, so release buffer and try again */
380  ReleaseBuffer(buffer);
381  }
382 
383  /* Must extend the file */
384  needLock = !RELATION_IS_LOCAL(index);
385  if (needLock)
387 
388  buffer = ReadBuffer(index, P_NEW);
390 
391  if (needLock)
393 
394  return buffer;
395 }
396 
397 /*
398  * Initialize any page of a bloom index.
399  */
400 void
402 {
403  BloomPageOpaque opaque;
404 
405  PageInit(page, BLCKSZ, sizeof(BloomPageOpaqueData));
406 
407  opaque = BloomPageGetOpaque(page);
408  memset(opaque, 0, sizeof(BloomPageOpaqueData));
409  opaque->flags = flags;
410  opaque->bloom_page_id = BLOOM_PAGE_ID;
411 }
412 
413 /*
414  * Fill in metapage for bloom index.
415  */
416 void
418 {
419  BloomOptions *opts;
420  BloomMetaPageData *metadata;
421 
422  /*
423  * Choose the index's options. If reloptions have been assigned, use
424  * those, otherwise create default options.
425  */
426  opts = (BloomOptions *) index->rd_options;
427  if (!opts)
428  opts = makeDefaultBloomOptions();
429 
430  /*
431  * Initialize contents of meta page, including a copy of the options,
432  * which are now frozen for the life of the index.
433  */
434  BloomInitPage(metaPage, BLOOM_META);
435  metadata = BloomPageGetMeta(metaPage);
436  memset(metadata, 0, sizeof(BloomMetaPageData));
437  metadata->magickNumber = BLOOM_MAGICK_NUMBER;
438  metadata->opts = *opts;
439  ((PageHeader) metaPage)->pd_lower += sizeof(BloomMetaPageData);
440 
441  /* If this fails, probably FreeBlockNumberArray size calc is wrong: */
442  Assert(((PageHeader) metaPage)->pd_lower <= ((PageHeader) metaPage)->pd_upper);
443 }
444 
445 /*
446  * Initialize metapage for bloom index.
447  */
448 void
450 {
451  Buffer metaBuffer;
452  Page metaPage;
454 
455  /*
456  * Make a new page; since it is first page it should be associated with
457  * block number 0 (BLOOM_METAPAGE_BLKNO).
458  */
459  metaBuffer = BloomNewBuffer(index);
461 
462  /* Initialize contents of meta page */
463  state = GenericXLogStart(index);
464  metaPage = GenericXLogRegisterBuffer(state, metaBuffer,
466  BloomFillMetapage(index, metaPage);
467  GenericXLogFinish(state);
468 
469  UnlockReleaseBuffer(metaBuffer);
470 }
471 
472 /*
473  * Parse reloptions for bloom index, producing a BloomOptions struct.
474  */
475 bytea *
476 bloptions(Datum reloptions, bool validate)
477 {
478  BloomOptions *rdopts;
479 
480  /* Parse the user-given reloptions */
481  rdopts = (BloomOptions *) build_reloptions(reloptions, validate,
483  sizeof(BloomOptions),
485  lengthof(bl_relopt_tab));
486 
487  /* Convert signature length from # of bits to # to words, rounding up */
488  if (rdopts)
489  rdopts->bloomLength = (rdopts->bloomLength + SIGNWORDBITS - 1) / SIGNWORDBITS;
490 
491  return (bytea *) rdopts;
492 }
ambeginscan_function ambeginscan
Definition: amapi.h:221
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define BLOOM_METAPAGE_BLKNO
Definition: bloom.h:77
#define BUFFER_LOCK_UNLOCK
Definition: bufmgr.h:86
#define SETBIT(x, i)
Definition: blutils.c:31
#define BloomPageIsDeleted(page)
Definition: bloom.h:63
ambulkdelete_function ambulkdelete
Definition: amapi.h:213
relopt_type opttype
Definition: reloptions.h:147
bool amcanmulticol
Definition: amapi.h:183
#define MAX_BLOOM_LENGTH
Definition: bloom.h:91
uint16 amsupport
Definition: amapi.h:173
IndexBuildResult * blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
Definition: blinsert.c:122
BloomOptions opts
Definition: bloom.h:141
#define BLOOM_PAGE_ID
Definition: bloom.h:56
static int32 next
Definition: blutils.c:213
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
Definition: indexam.c:794
amgettuple_function amgettuple
Definition: amapi.h:223
#define DatumGetInt32(X)
Definition: postgres.h:472
bool amcanorderbyop
Definition: amapi.h:177
amproperty_function amproperty
Definition: amapi.h:218
#define ExclusiveLock
Definition: lockdefs.h:44
static BloomOptions * makeDefaultBloomOptions(void)
Definition: blutils.c:86
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:543
#define BloomPageIsMeta(page)
Definition: bloom.h:61
FmgrInfo hashFn[INDEX_MAX_KEYS]
Definition: bloom.h:139
amparallelrescan_function amparallelrescan
Definition: amapi.h:232
#define BLOOM_NPROC
Definition: bloom.h:25
bool amstorage
Definition: amapi.h:191
static struct @145 value
#define DEFAULT_BLOOM_BITS
Definition: bloom.h:96
bool ampredlocks
Definition: amapi.h:195
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3365
#define P_NEW
Definition: bufmgr.h:81
OffsetNumber maxoff
Definition: bloom.h:34
aminsert_function aminsert
Definition: amapi.h:212
#define lengthof(array)
Definition: c.h:663
#define BUFFER_LOCK_EXCLUSIVE
Definition: bufmgr.h:88
PG_FUNCTION_INFO_V1(blhandler)
void add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
Definition: reloptions.c:739
Oid amkeytype
Definition: amapi.h:201
int bitSize[INDEX_MAX_KEYS]
Definition: bloom.h:104
Oid collations[INDEX_MAX_KEYS]
Definition: bloom.h:140
void blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Definition: blcost.c:23
bool amoptionalkey
Definition: amapi.h:185
Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)
Definition: generic_xlog.c:295
amvalidate_function amvalidate
Definition: amapi.h:220
uint16 bloom_page_id
Definition: bloom.h:39
void _PG_init(void)
Definition: blutils.c:51
signed int int32
Definition: c.h:347
IndexBulkDeleteResult * blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: blvacuum.c:169
uint16 flags
Definition: bloom.h:35
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:1554
#define DEFAULT_BLOOM_LENGTH
Definition: bloom.h:90
Buffer BloomNewBuffer(Relation index)
Definition: blutils.c:347
bool blvalidate(Oid opclassoid)
Definition: blvalidate.c:32
Definition: type.h:89
void blendscan(IndexScanDesc scan)
Definition: blscan.c:68
uint16 BloomSignatureWord
Definition: bloom.h:83
unsigned short uint16
Definition: c.h:358
char * Pointer
Definition: c.h:336
amgetbitmap_function amgetbitmap
Definition: amapi.h:224
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3388
#define BloomPageGetOpaque(page)
Definition: bloom.h:59
Oid * rd_indcollation
Definition: rel.h:168
#define ERROR
Definition: elog.h:43
ambuild_function ambuild
Definition: amapi.h:210
static relopt_kind bl_relopt_kind
Definition: blutils.c:37
amoptions_function amoptions
Definition: amapi.h:217
void initBloomState(BloomState *state, Relation index)
Definition: blutils.c:155
static relopt_parse_elt bl_relopt_tab[INDEX_MAX_KEYS+1]
Definition: blutils.c:40
#define SIGNWORDBITS
Definition: bloom.h:85
bool amcaninclude
Definition: amapi.h:199
void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
Definition: fmgr.c:610
char sign
Definition: informix.c:688
amcostestimate_function amcostestimate
Definition: amapi.h:216
bool amcanunique
Definition: amapi.h:181
#define BloomPageGetFreeSpace(state, page)
Definition: bloom.h:151
IndexBulkDeleteResult * blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: blvacuum.c:34
static char * buf
Definition: pg_test_fsync.c:67
amvacuumcleanup_function amvacuumcleanup
Definition: amapi.h:214
amendscan_function amendscan
Definition: amapi.h:225
bool amcanbackward
Definition: amapi.h:179
void BloomFillMetapage(Relation index, Page metaPage)
Definition: blutils.c:417
unsigned int uint32
Definition: c.h:359
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
#define BloomPageGetTuple(state, page, offset)
Definition: bloom.h:70
int64 blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: blscan.c:81
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define BloomPageGetMeta(page)
Definition: bloom.h:135
amrescan_function amrescan
Definition: amapi.h:222
bool amcanparallel
Definition: amapi.h:197
bool ConditionalLockBuffer(Buffer buffer)
Definition: bufmgr.c:3628
MemoryContext TopMemoryContext
Definition: mcxt.c:44
#define BLOOM_NSTRATEGIES
Definition: bloom.h:29
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:402
bool amsearchnulls
Definition: amapi.h:189
#define BLOOMTUPLEHDRSZ
Definition: bloom.h:165
void * palloc0(Size size)
Definition: mcxt.c:980
BloomOptions opts
Definition: bloom.h:125
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
Definition: lmgr.c:452
uintptr_t Datum
Definition: postgres.h:367
void blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: blscan.c:48
void signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno)
Definition: blutils.c:254
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
Definition: fmgr.c:1130
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3602
bool amclusterable
Definition: amapi.h:193
const char * optname
Definition: reloptions.h:146
int32 nColumns
Definition: bloom.h:142
TupleDesc rd_att
Definition: rel.h:84
void BloomInitMetapage(Relation index)
Definition: blutils.c:449
bool amsearcharray
Definition: amapi.h:187
#define InvalidOid
Definition: postgres_ext.h:36
BlockNumber GetFreeIndexPage(Relation rel)
Definition: indexfsm.c:38
#define makeNode(_type_)
Definition: nodes.h:573
PageHeaderData * PageHeader
Definition: bufpage.h:166
#define Assert(condition)
Definition: c.h:733
BloomTuple * BloomFormTuple(BloomState *state, ItemPointer iptr, Datum *values, bool *isnull)
Definition: blutils.c:287
static int32 myRand(void)
Definition: blutils.c:216
Definition: regguts.h:298
XLogRecPtr GenericXLogFinish(GenericXLogState *state)
Definition: generic_xlog.c:333
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:596
static void mySrand(uint32 seed)
Definition: blutils.c:243
bool blinsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, IndexInfo *indexInfo)
Definition: blinsert.c:198
#define INDEX_MAX_KEYS
#define InvalidBlockNumber
Definition: block.h:33
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
BloomSignatureWord sign[FLEXIBLE_ARRAY_MEMBER]
Definition: bloom.h:162
void blbuildempty(Relation index)
Definition: blinsert.c:165
int bloomLength
Definition: bloom.h:103
relopt_kind add_reloption_kind(void)
Definition: reloptions.c:618
uint32 magickNumber
Definition: bloom.h:122
static Datum values[MAXATTR]
Definition: bootstrap.c:167
uint16 amstrategies
Definition: amapi.h:171
#define AccessExclusiveLock
Definition: lockdefs.h:45
void BloomInitPage(Page page, uint16 flags)
Definition: blutils.c:401
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:2613
IndexScanDesc blbeginscan(Relation r, int nkeys, int norderbys)
Definition: blscan.c:28
ItemPointerData heapPtr
Definition: bloom.h:161
#define MAX_BLOOM_BITS
Definition: bloom.h:97
#define PageIsNew(page)
Definition: bufpage.h:229
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1173
#define BLOOM_META
Definition: bloom.h:45
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:796
relopt_kind
Definition: reloptions.h:39
#define elog(elevel,...)
Definition: elog.h:228
ambuildempty_function ambuildempty
Definition: amapi.h:211
MemoryContext rd_indexcxt
Definition: rel.h:155
bytea * bloptions(Datum reloptions, bool validate)
Definition: blutils.c:476
int i
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:87
bool BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
Definition: blutils.c:312
Definition: c.h:550
#define PG_FUNCTION_ARGS
Definition: fmgr.h:188
Datum blhandler(PG_FUNCTION_ARGS)
Definition: blutils.c:105
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329
struct BloomMetaPageData BloomMetaPageData
void * rd_amcache
Definition: rel.h:179
#define BLOOM_MAGICK_NUMBER
Definition: bloom.h:130
Size sizeOfBloomTuple
Definition: bloom.h:148
#define snprintf
Definition: port.h:192
int Buffer
Definition: buf.h:23
amcanreturn_function amcanreturn
Definition: amapi.h:215
#define BLOOM_HASH_PROC
Definition: bloom.h:24
#define GENERIC_XLOG_FULL_IMAGE
Definition: generic_xlog.h:26
bytea * rd_options
Definition: rel.h:126
#define offsetof(type, field)
Definition: c.h:656
GenericXLogState * GenericXLogStart(Relation relation)
Definition: generic_xlog.c:267
Pointer Page
Definition: bufpage.h:78
aminitparallelscan_function aminitparallelscan
Definition: amapi.h:231
amrestrpos_function amrestrpos
Definition: amapi.h:227
void PageInit(Page page, Size pageSize, Size specialSize)
Definition: bufpage.c:42