PostgreSQL Source Code  git master
hash.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * hash.h
4  * header file for postgres hash access method implementation
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/hash.h
11  *
12  * NOTES
13  * modeled after Margo Seltzer's hash implementation for unix.
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef HASH_H
18 #define HASH_H
19 
20 #include "access/amapi.h"
21 #include "access/itup.h"
22 #include "access/sdir.h"
23 #include "lib/stringinfo.h"
24 #include "storage/bufmgr.h"
25 #include "storage/lockdefs.h"
26 #include "utils/hashutils.h"
27 #include "utils/hsearch.h"
28 #include "utils/relcache.h"
29 
30 /*
31  * Mapping from hash bucket number to physical block number of bucket's
32  * starting page. Beware of multiple evaluations of argument!
33  */
34 typedef uint32 Bucket;
35 
36 #define InvalidBucket ((Bucket) 0xFFFFFFFF)
37 
38 #define BUCKET_TO_BLKNO(metap,B) \
39  ((BlockNumber) ((B) + ((B) ? (metap)->hashm_spares[_hash_spareindex((B)+1)-1] : 0)) + 1)
40 
41 /*
42  * Special space for hash index pages.
43  *
44  * hasho_flag's LH_PAGE_TYPE bits tell us which type of page we're looking at.
45  * Additional bits in the flag word are used for more transient purposes.
46  *
47  * To test a page's type, do (hasho_flag & LH_PAGE_TYPE) == LH_xxx_PAGE.
48  * However, we ensure that each used page type has a distinct bit so that
49  * we can OR together page types for uses such as the allowable-page-types
50  * argument of _hash_checkpage().
51  */
52 #define LH_UNUSED_PAGE (0)
53 #define LH_OVERFLOW_PAGE (1 << 0)
54 #define LH_BUCKET_PAGE (1 << 1)
55 #define LH_BITMAP_PAGE (1 << 2)
56 #define LH_META_PAGE (1 << 3)
57 #define LH_BUCKET_BEING_POPULATED (1 << 4)
58 #define LH_BUCKET_BEING_SPLIT (1 << 5)
59 #define LH_BUCKET_NEEDS_SPLIT_CLEANUP (1 << 6)
60 #define LH_PAGE_HAS_DEAD_TUPLES (1 << 7)
61 
62 #define LH_PAGE_TYPE \
63  (LH_OVERFLOW_PAGE | LH_BUCKET_PAGE | LH_BITMAP_PAGE | LH_META_PAGE)
64 
65 /*
66  * In an overflow page, hasho_prevblkno stores the block number of the previous
67  * page in the bucket chain; in a bucket page, hasho_prevblkno stores the
68  * hashm_maxbucket value as of the last time the bucket was last split, or
69  * else as of the time the bucket was created. The latter convention is used
70  * to determine whether a cached copy of the metapage is too stale to be used
71  * without needing to lock or pin the metapage.
72  *
73  * hasho_nextblkno is always the block number of the next page in the
74  * bucket chain, or InvalidBlockNumber if there are no more such pages.
75  */
76 typedef struct HashPageOpaqueData
77 {
78  BlockNumber hasho_prevblkno; /* see above */
79  BlockNumber hasho_nextblkno; /* see above */
80  Bucket hasho_bucket; /* bucket number this pg belongs to */
81  uint16 hasho_flag; /* page type code + flag bits, see above */
82  uint16 hasho_page_id; /* for identification of hash indexes */
84 
86 
87 #define H_NEEDS_SPLIT_CLEANUP(opaque) (((opaque)->hasho_flag & LH_BUCKET_NEEDS_SPLIT_CLEANUP) != 0)
88 #define H_BUCKET_BEING_SPLIT(opaque) (((opaque)->hasho_flag & LH_BUCKET_BEING_SPLIT) != 0)
89 #define H_BUCKET_BEING_POPULATED(opaque) (((opaque)->hasho_flag & LH_BUCKET_BEING_POPULATED) != 0)
90 #define H_HAS_DEAD_TUPLES(opaque) (((opaque)->hasho_flag & LH_PAGE_HAS_DEAD_TUPLES) != 0)
91 
92 /*
93  * The page ID is for the convenience of pg_filedump and similar utilities,
94  * which otherwise would have a hard time telling pages of different index
95  * types apart. It should be the last 2 bytes on the page. This is more or
96  * less "free" due to alignment considerations.
97  */
98 #define HASHO_PAGE_ID 0xFF80
99 
100 typedef struct HashScanPosItem /* what we remember about each match */
101 {
102  ItemPointerData heapTid; /* TID of referenced heap item */
103  OffsetNumber indexOffset; /* index item's location within page */
105 
106 typedef struct HashScanPosData
107 {
108  Buffer buf; /* if valid, the buffer is pinned */
109  BlockNumber currPage; /* current hash index page */
110  BlockNumber nextPage; /* next overflow page */
111  BlockNumber prevPage; /* prev overflow or bucket page */
112 
113  /*
114  * The items array is always ordered in index order (ie, increasing
115  * indexoffset). When scanning backwards it is convenient to fill the
116  * array back-to-front, so we start at the last slot and fill downwards.
117  * Hence we need both a first-valid-entry and a last-valid-entry counter.
118  * itemIndex is a cursor showing which entry was last returned to caller.
119  */
120  int firstItem; /* first valid index in items[] */
121  int lastItem; /* last valid index in items[] */
122  int itemIndex; /* current index in items[] */
123 
124  HashScanPosItem items[MaxIndexTuplesPerPage]; /* MUST BE LAST */
126 
127 #define HashScanPosIsPinned(scanpos) \
128 ( \
129  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
130  !BufferIsValid((scanpos).buf)), \
131  BufferIsValid((scanpos).buf) \
132 )
133 
134 #define HashScanPosIsValid(scanpos) \
135 ( \
136  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
137  !BufferIsValid((scanpos).buf)), \
138  BlockNumberIsValid((scanpos).currPage) \
139 )
140 
141 #define HashScanPosInvalidate(scanpos) \
142  do { \
143  (scanpos).buf = InvalidBuffer; \
144  (scanpos).currPage = InvalidBlockNumber; \
145  (scanpos).nextPage = InvalidBlockNumber; \
146  (scanpos).prevPage = InvalidBlockNumber; \
147  (scanpos).firstItem = 0; \
148  (scanpos).lastItem = 0; \
149  (scanpos).itemIndex = 0; \
150  } while (0);
151 
152 /*
153  * HashScanOpaqueData is private state for a hash index scan.
154  */
155 typedef struct HashScanOpaqueData
156 {
157  /* Hash value of the scan key, ie, the hash key we seek */
159 
160  /* remember the buffer associated with primary bucket */
162 
163  /*
164  * remember the buffer associated with primary bucket page of bucket being
165  * split. it is required during the scan of the bucket which is being
166  * populated during split operation.
167  */
169 
170  /* Whether scan starts on bucket being populated due to split */
172 
173  /*
174  * Whether scanning bucket being split? The value of this parameter is
175  * referred only when hashso_buc_populated is true.
176  */
178  /* info about killed items if any (killedItems is NULL if never used) */
179  int *killedItems; /* currPos.items indexes of killed items */
180  int numKilled; /* number of currently stored items */
181 
182  /*
183  * Identify all the matching items on a page and save them in
184  * HashScanPosData
185  */
186  HashScanPosData currPos; /* current position data */
188 
190 
191 /*
192  * Definitions for metapage.
193  */
194 
195 #define HASH_METAPAGE 0 /* metapage is always block 0 */
196 
197 #define HASH_MAGIC 0x6440640
198 #define HASH_VERSION 4
199 
200 /*
201  * spares[] holds the number of overflow pages currently allocated at or
202  * before a certain splitpoint. For example, if spares[3] = 7 then there are
203  * 7 ovflpages before splitpoint 3 (compare BUCKET_TO_BLKNO macro). The
204  * value in spares[ovflpoint] increases as overflow pages are added at the
205  * end of the index. Once ovflpoint increases (ie, we have actually allocated
206  * the bucket pages belonging to that splitpoint) the number of spares at the
207  * prior splitpoint cannot change anymore.
208  *
209  * ovflpages that have been recycled for reuse can be found by looking at
210  * bitmaps that are stored within ovflpages dedicated for the purpose.
211  * The blknos of these bitmap pages are kept in mapp[]; nmaps is the
212  * number of currently existing bitmaps.
213  *
214  * The limitation on the size of spares[] comes from the fact that there's
215  * no point in having more than 2^32 buckets with only uint32 hashcodes.
216  * (Note: The value of HASH_MAX_SPLITPOINTS which is the size of spares[] is
217  * adjusted in such a way to accommodate multi phased allocation of buckets
218  * after HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE).
219  *
220  * There is no particular upper limit on the size of mapp[], other than
221  * needing to fit into the metapage. (With 8K block size, 1024 bitmaps
222  * limit us to 256 GB of overflow space...). For smaller block size we
223  * can not use 1024 bitmaps as it will lead to the meta page data crossing
224  * the block size boundary. So we use BLCKSZ to determine the maximum number
225  * of bitmaps.
226  */
227 #define HASH_MAX_BITMAPS Min(BLCKSZ / 8, 1024)
228 
229 #define HASH_SPLITPOINT_PHASE_BITS 2
230 #define HASH_SPLITPOINT_PHASES_PER_GRP (1 << HASH_SPLITPOINT_PHASE_BITS)
231 #define HASH_SPLITPOINT_PHASE_MASK (HASH_SPLITPOINT_PHASES_PER_GRP - 1)
232 #define HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE 10
233 
234 /* defines max number of splitpoint phases a hash index can have */
235 #define HASH_MAX_SPLITPOINT_GROUP 32
236 #define HASH_MAX_SPLITPOINTS \
237  (((HASH_MAX_SPLITPOINT_GROUP - HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE) * \
238  HASH_SPLITPOINT_PHASES_PER_GRP) + \
239  HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE)
240 
241 typedef struct HashMetaPageData
242 {
243  uint32 hashm_magic; /* magic no. for hash tables */
244  uint32 hashm_version; /* version ID */
245  double hashm_ntuples; /* number of tuples stored in the table */
246  uint16 hashm_ffactor; /* target fill factor (tuples/bucket) */
247  uint16 hashm_bsize; /* index page size (bytes) */
248  uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a power
249  * of 2 */
250  uint16 hashm_bmshift; /* log2(bitmap array size in BITS) */
251  uint32 hashm_maxbucket; /* ID of maximum bucket in use */
252  uint32 hashm_highmask; /* mask to modulo into entire table */
253  uint32 hashm_lowmask; /* mask to modulo into lower half of table */
254  uint32 hashm_ovflpoint; /* splitpoint from which ovflpage being
255  * allocated */
256  uint32 hashm_firstfree; /* lowest-number free ovflpage (bit#) */
257  uint32 hashm_nmaps; /* number of bitmap pages */
258  RegProcedure hashm_procid; /* hash function id from pg_proc */
259  uint32 hashm_spares[HASH_MAX_SPLITPOINTS]; /* spare pages before each
260  * splitpoint */
261  BlockNumber hashm_mapp[HASH_MAX_BITMAPS]; /* blknos of ovfl bitmaps */
263 
265 
266 /*
267  * Maximum size of a hash index item (it's okay to have only one per page)
268  */
269 #define HashMaxItemSize(page) \
270  MAXALIGN_DOWN(PageGetPageSize(page) - \
271  SizeOfPageHeaderData - \
272  sizeof(ItemIdData) - \
273  MAXALIGN(sizeof(HashPageOpaqueData)))
274 
275 #define INDEX_MOVED_BY_SPLIT_MASK INDEX_AM_RESERVED_BIT
276 
277 #define HASH_MIN_FILLFACTOR 10
278 #define HASH_DEFAULT_FILLFACTOR 75
279 
280 /*
281  * Constants
282  */
283 #define BYTE_TO_BIT 3 /* 2^3 bits/byte */
284 #define ALL_SET ((uint32) ~0)
285 
286 /*
287  * Bitmap pages do not contain tuples. They do contain the standard
288  * page headers and trailers; however, everything in between is a
289  * giant bit array. The number of bits that fit on a page obviously
290  * depends on the page size and the header/trailer overhead. We require
291  * the number of bits per page to be a power of 2.
292  */
293 #define BMPGSZ_BYTE(metap) ((metap)->hashm_bmsize)
294 #define BMPGSZ_BIT(metap) ((metap)->hashm_bmsize << BYTE_TO_BIT)
295 #define BMPG_SHIFT(metap) ((metap)->hashm_bmshift)
296 #define BMPG_MASK(metap) (BMPGSZ_BIT(metap) - 1)
297 
298 #define HashPageGetBitmap(page) \
299  ((uint32 *) PageGetContents(page))
300 
301 #define HashGetMaxBitmapSize(page) \
302  (PageGetPageSize((Page) page) - \
303  (MAXALIGN(SizeOfPageHeaderData) + MAXALIGN(sizeof(HashPageOpaqueData))))
304 
305 #define HashPageGetMeta(page) \
306  ((HashMetaPage) PageGetContents(page))
307 
308 /*
309  * The number of bits in an ovflpage bitmap word.
310  */
311 #define BITS_PER_MAP 32 /* Number of bits in uint32 */
312 
313 /* Given the address of the beginning of a bit map, clear/set the nth bit */
314 #define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
315 #define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
316 #define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
317 
318 /*
319  * page-level and high-level locking modes (see README)
320  */
321 #define HASH_READ BUFFER_LOCK_SHARE
322 #define HASH_WRITE BUFFER_LOCK_EXCLUSIVE
323 #define HASH_NOLOCK (-1)
324 
325 /*
326  * When a new operator class is declared, we require that the user supply
327  * us with an amproc function for hashing a key of the new type, returning
328  * a 32-bit hash value. We call this the "standard" hash function. We
329  * also allow an optional "extended" hash function which accepts a salt and
330  * returns a 64-bit hash value. This is highly recommended but, for reasons
331  * of backward compatibility, optional.
332  *
333  * When the salt is 0, the low 32 bits of the value returned by the extended
334  * hash function should match the value that would have been returned by the
335  * standard hash function.
336  */
337 #define HASHSTANDARD_PROC 1
338 #define HASHEXTENDED_PROC 2
339 #define HASHNProcs 2
340 
341 
342 /* public routines */
343 
345  struct IndexInfo *indexInfo);
346 extern void hashbuildempty(Relation index);
347 extern bool hashinsert(Relation rel, Datum *values, bool *isnull,
348  ItemPointer ht_ctid, Relation heapRel,
349  IndexUniqueCheck checkUnique,
350  struct IndexInfo *indexInfo);
351 extern bool hashgettuple(IndexScanDesc scan, ScanDirection dir);
352 extern int64 hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
353 extern IndexScanDesc hashbeginscan(Relation rel, int nkeys, int norderbys);
354 extern void hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
355  ScanKey orderbys, int norderbys);
356 extern void hashendscan(IndexScanDesc scan);
358  IndexBulkDeleteResult *stats,
360  void *callback_state);
362  IndexBulkDeleteResult *stats);
363 extern bytea *hashoptions(Datum reloptions, bool validate);
364 extern bool hashvalidate(Oid opclassoid);
365 
366 /* private routines */
367 
368 /* hashinsert.c */
369 extern void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel);
371  Size itemsize, IndexTuple itup);
372 extern void _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups,
373  OffsetNumber *itup_offsets, uint16 nitups);
374 
375 /* hashovfl.c */
376 extern Buffer _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin);
377 extern BlockNumber _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf,
378  Buffer wbuf, IndexTuple *itups, OffsetNumber *itup_offsets,
379  Size *tups_size, uint16 nitups, BufferAccessStrategy bstrategy);
380 extern void _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage);
381 extern void _hash_squeezebucket(Relation rel,
382  Bucket bucket, BlockNumber bucket_blkno,
383  Buffer bucket_buf,
384  BufferAccessStrategy bstrategy);
386 
387 /* hashpage.c */
388 extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno,
389  int access, int flags);
391  BlockNumber blkno, int flags);
392 extern HashMetaPage _hash_getcachedmetap(Relation rel, Buffer *metabuf,
393  bool force_refresh);
395  int access,
396  HashMetaPage *cachedmetap);
397 extern Buffer _hash_getinitbuf(Relation rel, BlockNumber blkno);
398 extern void _hash_initbuf(Buffer buf, uint32 max_bucket, uint32 num_bucket,
399  uint32 flag, bool initpage);
400 extern Buffer _hash_getnewbuf(Relation rel, BlockNumber blkno,
401  ForkNumber forkNum);
403  int access, int flags,
404  BufferAccessStrategy bstrategy);
405 extern void _hash_relbuf(Relation rel, Buffer buf);
406 extern void _hash_dropbuf(Relation rel, Buffer buf);
407 extern void _hash_dropscanbuf(Relation rel, HashScanOpaque so);
408 extern uint32 _hash_init(Relation rel, double num_tuples,
409  ForkNumber forkNum);
410 extern void _hash_init_metabuffer(Buffer buf, double num_tuples,
411  RegProcedure procid, uint16 ffactor, bool initpage);
412 extern void _hash_pageinit(Page page, Size size);
413 extern void _hash_expandtable(Relation rel, Buffer metabuf);
414 extern void _hash_finish_split(Relation rel, Buffer metabuf, Buffer obuf,
415  Bucket obucket, uint32 maxbucket, uint32 highmask,
416  uint32 lowmask);
417 
418 /* hashsearch.c */
419 extern bool _hash_next(IndexScanDesc scan, ScanDirection dir);
420 extern bool _hash_first(IndexScanDesc scan, ScanDirection dir);
421 
422 /* hashsort.c */
423 typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
424 
425 extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
426 extern void _h_spooldestroy(HSpool *hspool);
427 extern void _h_spool(HSpool *hspool, ItemPointer self,
428  Datum *values, bool *isnull);
429 extern void _h_indexbuild(HSpool *hspool, Relation heapRel);
430 
431 /* hashutil.c */
432 extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup);
434 extern uint32 _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype);
435 extern Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket,
436  uint32 highmask, uint32 lowmask);
437 extern uint32 _hash_log2(uint32 num);
438 extern uint32 _hash_spareindex(uint32 num_bucket);
439 extern uint32 _hash_get_totalbuckets(uint32 splitpoint_phase);
440 extern void _hash_checkpage(Relation rel, Buffer buf, int flags);
443  Datum *user_values, bool *user_isnull,
444  Datum *index_values, bool *index_isnull);
445 extern OffsetNumber _hash_binsearch(Page page, uint32 hash_value);
446 extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
450  uint32 lowmask, uint32 maxbucket);
451 extern void _hash_kill_items(IndexScanDesc scan);
452 
453 /* hash.c */
454 extern void hashbucketcleanup(Relation rel, Bucket cur_bucket,
455  Buffer bucket_buf, BlockNumber bucket_blkno,
456  BufferAccessStrategy bstrategy,
457  uint32 maxbucket, uint32 highmask, uint32 lowmask,
458  double *tuples_removed, double *num_index_tuples,
459  bool split_cleanup,
460  IndexBulkDeleteCallback callback, void *callback_state);
461 
462 #endif /* HASH_H */
bool _hash_convert_tuple(Relation index, Datum *user_values, bool *user_isnull, Datum *index_values, bool *index_isnull)
Definition: hashutil.c:326
void hashendscan(IndexScanDesc scan)
Definition: hash.c:424
HashScanOpaqueData * HashScanOpaque
Definition: hash.h:189
uint16 hashm_bmshift
Definition: hash.h:250
uint16 hasho_page_id
Definition: hash.h:82
IndexScanDesc hashbeginscan(Relation rel, int nkeys, int norderbys)
Definition: hash.c:360
Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access, int flags)
Definition: hashpage.c:69
BlockNumber _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf, Buffer wbuf, IndexTuple *itups, OffsetNumber *itup_offsets, Size *tups_size, uint16 nitups, BufferAccessStrategy bstrategy)
Definition: hashovfl.c:489
RegProcedure hashm_procid
Definition: hash.h:258
void _hash_pageinit(Page page, Size size)
Definition: hashpage.c:598
bool hashvalidate(Oid opclassoid)
Definition: hashvalidate.c:44
uint32 _hash_log2(uint32 num)
Definition: hashutil.c:141
bytea * hashoptions(Datum reloptions, bool validate)
Definition: hashutil.c:290
int64 hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: hash.c:328
Buffer _hash_getbucketbuf_from_hashkey(Relation rel, uint32 hashkey, int access, HashMetaPage *cachedmetap)
Definition: hashpage.c:1558
bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
Definition: hashutil.c:31
regproc RegProcedure
Definition: c.h:505
uint32 hashm_magic
Definition: hash.h:243
HashMetaPage _hash_getcachedmetap(Relation rel, Buffer *metabuf, bool force_refresh)
Definition: hashpage.c:1500
void hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: hash.c:390
uint16 hashm_ffactor
Definition: hash.h:246
uint32 hashm_highmask
Definition: hash.h:252
HashMetaPageData * HashMetaPage
Definition: hash.h:264
void _hash_init_metabuffer(Buffer buf, double num_tuples, RegProcedure procid, uint16 ffactor, bool initpage)
Definition: hashpage.c:497
IndexBuildResult * hashbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: hash.c:108
uint32 BlockNumber
Definition: block.h:31
unsigned int Oid
Definition: postgres_ext.h:31
bool hashgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: hash.c:276
void _hash_squeezebucket(Relation rel, Bucket bucket, BlockNumber bucket_blkno, Buffer bucket_buf, BufferAccessStrategy bstrategy)
Definition: hashovfl.c:805
uint32 hashm_lowmask
Definition: hash.h:253
void _h_spool(HSpool *hspool, ItemPointer self, Datum *values, bool *isnull)
Definition: hashsort.c:107
void _hash_initbuf(Buffer buf, uint32 max_bucket, uint32 num_bucket, uint32 flag, bool initpage)
Definition: hashpage.c:156
void _hash_dropscanbuf(Relation rel, HashScanOpaque so)
Definition: hashpage.c:288
Buffer _hash_getinitbuf(Relation rel, BlockNumber blkno)
Definition: hashpage.c:134
bool hashinsert(Relation rel, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, struct IndexInfo *indexInfo)
Definition: hash.c:245
#define HASH_MAX_SPLITPOINTS
Definition: hash.h:236
uint32 _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
Definition: hashutil.c:102
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
uint32 Bucket
Definition: hash.h:34
IndexUniqueCheck
Definition: genam.h:112
int * killedItems
Definition: hash.h:179
bool _hash_next(IndexScanDesc scan, ScanDirection dir)
Definition: hashsearch.c:48
unsigned short uint16
Definition: c.h:357
void _hash_finish_split(Relation rel, Buffer metabuf, Buffer obuf, Bucket obucket, uint32 maxbucket, uint32 highmask, uint32 lowmask)
Definition: hashpage.c:1354
BlockNumber hasho_prevblkno
Definition: hash.h:78
Buffer _hash_getnewbuf(Relation rel, BlockNumber blkno, ForkNumber forkNum)
Definition: hashpage.c:197
uint32 _hash_spareindex(uint32 num_bucket)
Definition: hashutil.c:157
void _hash_checkpage(Relation rel, Buffer buf, int flags)
Definition: hashutil.c:225
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
uint32 hashm_version
Definition: hash.h:244
uint32 hashm_nmaps
Definition: hash.h:257
struct HashMetaPageData HashMetaPageData
Buffer _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
Definition: hashovfl.c:111
IndexBulkDeleteResult * hashvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: hash.c:641
static char * buf
Definition: pg_test_fsync.c:68
char * flag(int b)
Definition: test-ctype.c:33
void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel)
Definition: hashinsert.c:36
ScanDirection
Definition: sdir.h:22
OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, Size itemsize, IndexTuple itup)
Definition: hashinsert.c:268
void _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage)
Definition: hashovfl.c:740
unsigned int uint32
Definition: c.h:358
BlockNumber currPage
Definition: hash.h:109
Buffer hashso_bucket_buf
Definition: hash.h:161
uint32 _hash_get_totalbuckets(uint32 splitpoint_phase)
Definition: hashutil.c:189
ForkNumber
Definition: relpath.h:40
void _hash_relbuf(Relation rel, Buffer buf)
Definition: hashpage.c:265
#define HASH_MAX_BITMAPS
Definition: hash.h:227
void _hash_expandtable(Relation rel, Buffer metabuf)
Definition: hashpage.c:616
bool _hash_first(IndexScanDesc scan, ScanDirection dir)
Definition: hashsearch.c:292
uint32 hashm_ovflpoint
Definition: hash.h:254
uint16 hashm_bsize
Definition: hash.h:247
uint32 _hash_init(Relation rel, double num_tuples, ForkNumber forkNum)
Definition: hashpage.c:326
BlockNumber _hash_get_newblock_from_oldbucket(Relation rel, Bucket old_bucket)
Definition: hashutil.c:469
uintptr_t Datum
Definition: postgres.h:367
BlockNumber _hash_get_oldblock_from_newbucket(Relation rel, Bucket new_bucket)
Definition: hashutil.c:430
double hashm_ntuples
Definition: hash.h:245
bool hashso_buc_populated
Definition: hash.h:171
Buffer buf
Definition: hash.h:108
uint32 hashm_firstfree
Definition: hash.h:256
uint32 hashso_sk_hash
Definition: hash.h:158
void hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf, BlockNumber bucket_blkno, BufferAccessStrategy bstrategy, uint32 maxbucket, uint32 highmask, uint32 lowmask, double *tuples_removed, double *num_index_tuples, bool split_cleanup, IndexBulkDeleteCallback callback, void *callback_state)
Definition: hash.c:680
uint32 _hash_get_indextuple_hashkey(IndexTuple itup)
Definition: hashutil.c:299
Bucket _hash_get_newbucket_from_oldbucket(Relation rel, Bucket old_bucket, uint32 lowmask, uint32 maxbucket)
Definition: hashutil.c:502
struct HashScanPosData HashScanPosData
void hashbuildempty(Relation index)
Definition: hash.c:194
void _h_spooldestroy(HSpool *hspool)
Definition: hashsort.c:97
Bucket hasho_bucket
Definition: hash.h:80
int lastItem
Definition: hash.h:121
struct HashScanPosItem HashScanPosItem
size_t Size
Definition: c.h:466
void _hash_dropbuf(Relation rel, Buffer buf)
Definition: hashpage.c:276
HashPageOpaqueData * HashPageOpaque
Definition: hash.h:85
OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value)
Definition: hashutil.c:396
HSpool * _h_spoolinit(Relation heap, Relation index, uint32 num_buckets)
Definition: hashsort.c:58
Buffer _hash_getbuf_with_condlock_cleanup(Relation rel, BlockNumber blkno, int flags)
Definition: hashpage.c:95
struct HashScanOpaqueData HashScanOpaqueData
uint32 hashm_maxbucket
Definition: hash.h:251
HashScanPosData currPos
Definition: hash.h:186
struct HashPageOpaqueData HashPageOpaqueData
uint16 hasho_flag
Definition: hash.h:81
bool hashso_buc_split
Definition: hash.h:177
static Datum values[MAXATTR]
Definition: bootstrap.c:167
Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket, uint32 highmask, uint32 lowmask)
Definition: hashutil.c:125
#define MaxIndexTuplesPerPage
Definition: itup.h:145
OffsetNumber indexOffset
Definition: hash.h:103
void _h_indexbuild(HSpool *hspool, Relation heapRel)
Definition: hashsort.c:118
void _hash_kill_items(IndexScanDesc scan)
Definition: hashutil.c:544
Buffer hashso_split_bucket_buf
Definition: hash.h:168
Buffer _hash_getbuf_with_strategy(Relation rel, BlockNumber blkno, int access, int flags, BufferAccessStrategy bstrategy)
Definition: hashpage.c:238
BlockNumber nextPage
Definition: hash.h:110
BlockNumber hasho_nextblkno
Definition: hash.h:79
uint16 hashm_bmsize
Definition: hash.h:248
uint32 _hash_datum2hashkey(Relation rel, Datum key)
Definition: hashutil.c:82
Definition: c.h:549
ItemPointerData heapTid
Definition: hash.h:102
OffsetNumber _hash_binsearch(Page page, uint32 hash_value)
Definition: hashutil.c:358
uint32 _hash_ovflblkno_to_bitno(HashMetaPage metap, BlockNumber ovflblkno)
Definition: hashovfl.c:61
int itemIndex
Definition: hash.h:122
IndexBulkDeleteResult * hashbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: hash.c:455
void _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups, OffsetNumber *itup_offsets, uint16 nitups)
Definition: hashinsert.c:299
int firstItem
Definition: hash.h:120
BlockNumber prevPage
Definition: hash.h:111
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:84