PostgreSQL Source Code
git master
|
#include "access/amapi.h"
#include "access/itup.h"
#include "access/sdir.h"
#include "catalog/pg_am_d.h"
#include "lib/stringinfo.h"
#include "storage/bufmgr.h"
#include "storage/lockdefs.h"
#include "utils/hashutils.h"
#include "utils/hsearch.h"
#include "utils/relcache.h"
Go to the source code of this file.
Data Structures | |
struct | HashPageOpaqueData |
struct | HashScanPosItem |
struct | HashScanPosData |
struct | HashScanOpaqueData |
struct | HashMetaPageData |
struct | HashOptions |
Typedefs | |
typedef uint32 | Bucket |
typedef struct HashPageOpaqueData | HashPageOpaqueData |
typedef HashPageOpaqueData * | HashPageOpaque |
typedef struct HashScanPosItem | HashScanPosItem |
typedef struct HashScanPosData | HashScanPosData |
typedef struct HashScanOpaqueData | HashScanOpaqueData |
typedef HashScanOpaqueData * | HashScanOpaque |
typedef struct HashMetaPageData | HashMetaPageData |
typedef HashMetaPageData * | HashMetaPage |
typedef struct HashOptions | HashOptions |
typedef struct HSpool | HSpool |
#define ALL_SET ((uint32) ~0) |
Definition at line 300 of file hash.h.
Referenced by _hash_addovflpage().
#define BITS_PER_MAP 32 /* Number of bits in uint32 */ |
Definition at line 327 of file hash.h.
Referenced by _hash_addovflpage(), and _hash_firstfreebit().
#define BMPG_MASK | ( | metap | ) | (BMPGSZ_BIT(metap) - 1) |
Definition at line 312 of file hash.h.
Referenced by _hash_addovflpage(), _hash_freeovflpage(), _hash_init_metabuffer(), and hash_bitmap_info().
#define BMPG_SHIFT | ( | metap | ) | ((metap)->hashm_bmshift) |
Definition at line 311 of file hash.h.
Referenced by _hash_addovflpage(), _hash_freeovflpage(), _hash_init_metabuffer(), and hash_bitmap_info().
#define BMPGSZ_BIT | ( | metap | ) | ((metap)->hashm_bmsize << BYTE_TO_BIT) |
Definition at line 310 of file hash.h.
Referenced by _hash_addovflpage().
#define BUCKET_TO_BLKNO | ( | metap, | |
B | |||
) | ((BlockNumber) ((B) + ((B) ? (metap)->hashm_spares[_hash_spareindex((B)+1)-1] : 0)) + 1) |
Definition at line 39 of file hash.h.
Referenced by _hash_expandtable(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getbucketbuf_from_hashkey(), _hash_init(), and hashbulkdelete().
#define BYTE_TO_BIT 3 /* 2^3 bits/byte */ |
Definition at line 299 of file hash.h.
Referenced by _hash_init_metabuffer().
#define CLRBIT | ( | A, | |
N | |||
) | ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) |
#define H_BUCKET_BEING_POPULATED | ( | opaque | ) | (((opaque)->hasho_flag & LH_BUCKET_BEING_POPULATED) != 0) |
Definition at line 90 of file hash.h.
Referenced by _hash_first().
#define H_BUCKET_BEING_SPLIT | ( | opaque | ) | (((opaque)->hasho_flag & LH_BUCKET_BEING_SPLIT) != 0) |
Definition at line 89 of file hash.h.
Referenced by _hash_doinsert(), _hash_expandtable(), and hashbulkdelete().
#define H_HAS_DEAD_TUPLES | ( | opaque | ) | (((opaque)->hasho_flag & LH_PAGE_HAS_DEAD_TUPLES) != 0) |
Definition at line 91 of file hash.h.
Referenced by _hash_doinsert(), and hashbucketcleanup().
#define H_NEEDS_SPLIT_CLEANUP | ( | opaque | ) | (((opaque)->hasho_flag & LH_BUCKET_NEEDS_SPLIT_CLEANUP) != 0) |
Definition at line 88 of file hash.h.
Referenced by _hash_expandtable(), and hashbulkdelete().
#define HASH_MAGIC 0x6440640 |
Definition at line 198 of file hash.h.
Referenced by _hash_checkpage(), _hash_init_metabuffer(), and verify_hash_page().
#define HASH_MAX_BITMAPS Min(BLCKSZ / 8, 1024) |
Definition at line 228 of file hash.h.
Referenced by _hash_addovflpage(), _hash_init(), and hash_metapage_info().
#define HASH_MAX_SPLITPOINTS |
Definition at line 237 of file hash.h.
Referenced by _hash_init_metabuffer(), and hash_metapage_info().
#define HASH_METAPAGE 0 /* metapage is always block 0 */ |
Definition at line 196 of file hash.h.
Referenced by _hash_doinsert(), _hash_freeovflpage(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getcachedmetap(), _hash_init(), hash_bitmap_info(), hashbulkdelete(), pgstat_relation(), and pgstathashindex().
#define HASH_NOLOCK (-1) |
Definition at line 339 of file hash.h.
Referenced by _hash_doinsert(), _hash_getbuf(), _hash_getbuf_with_strategy(), and hashbulkdelete().
#define HASH_READ BUFFER_LOCK_SHARE |
Definition at line 337 of file hash.h.
Referenced by _hash_finish_split(), _hash_first(), _hash_freeovflpage(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getbucketbuf_from_hashkey(), _hash_getcachedmetap(), _hash_kill_items(), _hash_next(), _hash_readnext(), _hash_readprev(), _hash_splitbucket(), hash_bitmap_info(), pgstat_hash_page(), and pgstathashindex().
#define HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE 10 |
Definition at line 233 of file hash.h.
Referenced by _hash_get_totalbuckets(), and _hash_spareindex().
#define HASH_SPLITPOINT_PHASE_BITS 2 |
Definition at line 230 of file hash.h.
Referenced by _hash_get_totalbuckets(), and _hash_spareindex().
#define HASH_SPLITPOINT_PHASE_MASK (HASH_SPLITPOINT_PHASES_PER_GRP - 1) |
Definition at line 232 of file hash.h.
Referenced by _hash_get_totalbuckets(), and _hash_spareindex().
#define HASH_SPLITPOINT_PHASES_PER_GRP (1 << HASH_SPLITPOINT_PHASE_BITS) |
#define HASH_VERSION 4 |
Definition at line 199 of file hash.h.
Referenced by _hash_checkpage(), _hash_init_metabuffer(), and verify_hash_page().
#define HASH_WRITE BUFFER_LOCK_EXCLUSIVE |
Definition at line 338 of file hash.h.
Referenced by _hash_addovflpage(), _hash_doinsert(), _hash_freeovflpage(), _hash_getbucketbuf_from_hashkey(), _hash_getnewbuf(), _hash_squeezebucket(), and hashbucketcleanup().
#define HASHEXTENDED_PROC 2 |
Definition at line 354 of file hash.h.
Referenced by assignProcTypes(), check_hash_func_signature(), hashvalidate(), lookup_type_cache(), match_clause_to_partition_key(), and RelationBuildPartitionKey().
#define HashGetFillFactor | ( | relation | ) |
#define HashGetMaxBitmapSize | ( | page | ) |
Definition at line 317 of file hash.h.
Referenced by _hash_init_metabuffer().
#define HashGetTargetPageUsage | ( | relation | ) | (BLCKSZ * HashGetFillFactor(relation) / 100) |
Definition at line 279 of file hash.h.
Referenced by _hash_init().
#define HashMaxItemSize | ( | page | ) |
Definition at line 285 of file hash.h.
Referenced by _hash_doinsert().
#define HASHNProcs 2 |
Definition at line 355 of file hash.h.
Referenced by hashhandler().
#define HASHO_PAGE_ID 0xFF80 |
Definition at line 99 of file hash.h.
Referenced by _hash_addovflpage(), _hash_alloc_buckets(), _hash_expandtable(), _hash_freeovflpage(), _hash_init_metabuffer(), _hash_initbitmapbuffer(), _hash_initbuf(), hash_xlog_squeeze_page(), and verify_hash_page().
#define HashPageGetBitmap | ( | page | ) | ((uint32 *) PageGetContents(page)) |
Definition at line 314 of file hash.h.
Referenced by _hash_addovflpage(), _hash_freeovflpage(), _hash_initbitmapbuffer(), hash_bitmap_info(), hash_xlog_add_ovfl_page(), and hash_xlog_squeeze_page().
#define HashPageGetMeta | ( | page | ) | ((HashMetaPage) PageGetContents(page)) |
Definition at line 321 of file hash.h.
Referenced by _hash_addovflpage(), _hash_checkpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getcachedmetap(), _hash_init(), _hash_init_metabuffer(), _hash_vacuum_one_page(), hash_bitmap_info(), hash_metapage_info(), hash_xlog_add_ovfl_page(), hash_xlog_init_bitmap_page(), hash_xlog_insert(), hash_xlog_split_allocate_page(), hash_xlog_squeeze_page(), hash_xlog_update_meta_page(), hash_xlog_vacuum_one_page(), hashbulkdelete(), pgstathashindex(), and verify_hash_page().
#define HashScanPosInvalidate | ( | scanpos | ) |
Definition at line 142 of file hash.h.
Referenced by _hash_next(), hashbeginscan(), and hashrescan().
#define HashScanPosIsPinned | ( | scanpos | ) |
Definition at line 128 of file hash.h.
Referenced by _hash_kill_items().
#define HashScanPosIsValid | ( | scanpos | ) |
Definition at line 135 of file hash.h.
Referenced by _hash_kill_items(), hashendscan(), hashgettuple(), and hashrescan().
#define HASHSTANDARD_PROC 1 |
Definition at line 353 of file hash.h.
Referenced by _hash_datum2hashkey(), _hash_datum2hashkey_type(), _hash_init(), assignProcTypes(), check_hash_func_signature(), get_op_hash_functions(), hashvalidate(), and lookup_type_cache().
#define INDEX_MOVED_BY_SPLIT_MASK INDEX_AM_RESERVED_BIT |
Definition at line 291 of file hash.h.
Referenced by _hash_load_qualified_items(), and _hash_splitbucket().
#define InvalidBucket ((Bucket) 0xFFFFFFFF) |
Definition at line 37 of file hash.h.
Referenced by hashbucketcleanup().
#define ISSET | ( | A, | |
N | |||
) | ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) |
Definition at line 332 of file hash.h.
Referenced by _hash_freeovflpage(), and hash_bitmap_info().
#define LH_BITMAP_PAGE (1 << 2) |
Definition at line 56 of file hash.h.
Referenced by _hash_addovflpage(), _hash_freeovflpage(), _hash_initbitmapbuffer(), hash_bitmap_info(), hash_page_type(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define LH_BUCKET_BEING_POPULATED (1 << 4) |
Definition at line 58 of file hash.h.
Referenced by _hash_expandtable(), and _hash_splitbucket().
#define LH_BUCKET_BEING_SPLIT (1 << 5) |
Definition at line 59 of file hash.h.
Referenced by _hash_expandtable(), and _hash_splitbucket().
#define LH_BUCKET_NEEDS_SPLIT_CLEANUP (1 << 6) |
Definition at line 60 of file hash.h.
Referenced by _hash_splitbucket(), hash_xlog_split_cleanup(), and hashbucketcleanup().
#define LH_BUCKET_PAGE (1 << 1) |
Definition at line 55 of file hash.h.
Referenced by _hash_addovflpage(), _hash_expandtable(), _hash_finish_split(), _hash_first(), _hash_freeovflpage(), _hash_getbucketbuf_from_hashkey(), _hash_init(), _hash_next(), _hash_pgaddmultitup(), _hash_pgaddtup(), _hash_readpage(), _hash_readprev(), hash_mask(), hash_page_items(), hash_page_stats(), hash_page_type(), hashbulkdelete(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define LH_META_PAGE (1 << 3) |
Definition at line 57 of file hash.h.
Referenced by _hash_addovflpage(), _hash_checkpage(), _hash_doinsert(), _hash_expandtable(), _hash_freeovflpage(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getcachedmetap(), _hash_init_metabuffer(), hash_bitmap_info(), hash_metapage_info(), hash_page_type(), hashbulkdelete(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define LH_OVERFLOW_PAGE (1 << 0) |
Definition at line 54 of file hash.h.
Referenced by _hash_addovflpage(), _hash_doinsert(), _hash_finish_split(), _hash_freeovflpage(), _hash_kill_items(), _hash_next(), _hash_pgaddmultitup(), _hash_pgaddtup(), _hash_readnext(), _hash_readpage(), _hash_readprev(), _hash_splitbucket(), _hash_squeezebucket(), hash_mask(), hash_page_items(), hash_page_stats(), hash_page_type(), hash_xlog_add_ovfl_page(), hashbucketcleanup(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define LH_PAGE_HAS_DEAD_TUPLES (1 << 7) |
Definition at line 61 of file hash.h.
Referenced by _hash_kill_items(), _hash_vacuum_one_page(), hash_mask(), hash_xlog_delete(), hash_xlog_vacuum_one_page(), and hashbucketcleanup().
#define LH_PAGE_TYPE (LH_OVERFLOW_PAGE | LH_BUCKET_PAGE | LH_BITMAP_PAGE | LH_META_PAGE) |
Definition at line 63 of file hash.h.
Referenced by _hash_addovflpage(), _hash_doinsert(), hash_mask(), hash_page_type(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define LH_UNUSED_PAGE (0) |
Definition at line 53 of file hash.h.
Referenced by _hash_alloc_buckets(), _hash_freeovflpage(), hash_mask(), hash_xlog_squeeze_page(), pgstat_hash_page(), pgstathashindex(), and verify_hash_page().
#define SETBIT | ( | A, | |
N | |||
) | ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) |
typedef HashMetaPageData* HashMetaPage |
typedef struct HashMetaPageData HashMetaPageData |
typedef struct HashOptions HashOptions |
typedef HashPageOpaqueData* HashPageOpaque |
typedef struct HashPageOpaqueData HashPageOpaqueData |
typedef HashScanOpaqueData* HashScanOpaque |
typedef struct HashScanOpaqueData HashScanOpaqueData |
typedef struct HashScanPosData HashScanPosData |
typedef struct HashScanPosItem HashScanPosItem |
Definition at line 118 of file hashsort.c.
References _hash_doinsert(), _hash_get_indextuple_hashkey(), _hash_hashkey2bucket(), Assert, HSpool::high_mask, HSpool::index, HSpool::low_mask, HSpool::max_buckets, pgstat_progress_update_param(), PROGRESS_CREATEIDX_TUPLES_DONE, HSpool::sortstate, tuplesort_getindextuple(), and tuplesort_performsort().
Referenced by hashbuild().
void _h_spool | ( | HSpool * | hspool, |
ItemPointer | self, | ||
Datum * | values, | ||
bool * | isnull | ||
) |
Definition at line 107 of file hashsort.c.
References HSpool::index, HSpool::sortstate, and tuplesort_putindextuplevalues().
Referenced by hashbuildCallback().
void _h_spooldestroy | ( | HSpool * | hspool | ) |
Definition at line 97 of file hashsort.c.
References pfree(), HSpool::sortstate, and tuplesort_end().
Referenced by hashbuild().
Definition at line 58 of file hashsort.c.
References _hash_log2(), HSpool::high_mask, HSpool::index, HSpool::low_mask, maintenance_work_mem, HSpool::max_buckets, palloc0(), HSpool::sortstate, and tuplesort_begin_index_hash().
Referenced by hashbuild().
Definition at line 111 of file hashovfl.c.
References _hash_checkpage(), _hash_firstfreebit(), _hash_getbuf(), _hash_getinitbuf(), _hash_getnewbuf(), _hash_initbitmapbuffer(), _hash_relbuf(), ALL_SET, Assert, bit(), bitno_to_blkno(), BITS_PER_MAP, BlockNumberIsValid, xl_hash_add_ovfl_page::bmpage_found, BMPG_MASK, BMPG_SHIFT, BMPGSZ_BIT, xl_hash_add_ovfl_page::bmsize, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage, BufferIsValid, END_CRIT_SECTION, ereport, errcode(), errmsg(), ERROR, HASH_MAX_BITMAPS, HASH_WRITE, HashMetaPageData::hashm_bmsize, HashMetaPageData::hashm_firstfree, HashMetaPageData::hashm_mapp, HashMetaPageData::hashm_nmaps, HashMetaPageData::hashm_ovflpoint, HashMetaPageData::hashm_spares, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, HashPageGetBitmap, HashPageGetMeta, i, InvalidBlockNumber, InvalidBuffer, LH_BITMAP_PAGE, LH_BUCKET_PAGE, LH_META_PAGE, LH_OVERFLOW_PAGE, LH_PAGE_TYPE, LockBuffer(), MAIN_FORKNUM, MarkBufferDirty(), PageGetSpecialPointer, PageSetLSN, REGBUF_STANDARD, REGBUF_WILL_INIT, RelationGetRelationName, RelationNeedsWAL, SETBIT, SizeOfHashAddOvflPage, START_CRIT_SECTION, XLOG_HASH_ADD_OVFL_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by _hash_doinsert(), and _hash_splitbucket().
OffsetNumber _hash_binsearch | ( | Page | page, |
uint32 | hash_value | ||
) |
Definition at line 365 of file hashutil.c.
References _hash_get_indextuple_hashkey(), Assert, FirstOffsetNumber, lower(), OffsetNumberIsValid, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, and upper().
Referenced by _hash_pgaddmultitup(), _hash_pgaddtup(), and _hash_readpage().
OffsetNumber _hash_binsearch_last | ( | Page | page, |
uint32 | hash_value | ||
) |
Definition at line 403 of file hashutil.c.
References _hash_get_indextuple_hashkey(), Assert, FirstOffsetNumber, lower(), OffsetNumberIsValid, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, and upper().
Referenced by _hash_readpage().
Definition at line 225 of file hashutil.c.
References BufferGetBlockNumber(), BufferGetPage, ereport, errcode(), errhint(), errmsg(), ERROR, HASH_MAGIC, HASH_VERSION, HashMetaPageData::hashm_magic, HashMetaPageData::hashm_version, HashPageOpaqueData::hasho_flag, HashPageGetMeta, LH_META_PAGE, MAXALIGN, PageGetSpecialPointer, PageGetSpecialSize, PageIsNew, and RelationGetRelationName.
Referenced by _hash_addovflpage(), _hash_expandtable(), _hash_freeovflpage(), _hash_getbuf(), _hash_getbuf_with_condlock_cleanup(), _hash_getbuf_with_strategy(), _hash_pgaddmultitup(), _hash_pgaddtup(), _hash_readpage(), and hashbulkdelete().
bool _hash_checkqual | ( | IndexScanDesc | scan, |
IndexTuple | itup | ||
) |
Definition at line 31 of file hashutil.c.
References DatumGetBool, FunctionCall2Coll(), index_getattr, IndexScanDescData::indexRelation, sort-test::key, IndexScanDescData::keyData, IndexScanDescData::numberOfKeys, RelationGetDescr, ScanKeyData::sk_argument, ScanKeyData::sk_attno, ScanKeyData::sk_collation, ScanKeyData::sk_flags, ScanKeyData::sk_func, SK_ISNULL, and test().
Referenced by _hash_load_qualified_items().
bool _hash_convert_tuple | ( | Relation | index, |
Datum * | user_values, | ||
bool * | user_isnull, | ||
Datum * | index_values, | ||
bool * | index_isnull | ||
) |
Definition at line 333 of file hashutil.c.
References _hash_datum2hashkey(), and UInt32GetDatum.
Referenced by hashbuildCallback(), and hashinsert().
Definition at line 82 of file hashutil.c.
References DatumGetUInt32, FunctionCall1Coll(), HASHSTANDARD_PROC, index_getprocinfo(), and RelationData::rd_indcollation.
Referenced by _hash_convert_tuple(), and _hash_first().
Definition at line 102 of file hashutil.c.
References DatumGetUInt32, elog, ERROR, get_opfamily_proc(), HASHSTANDARD_PROC, OidFunctionCall1Coll(), RelationData::rd_indcollation, RelationData::rd_opfamily, RegProcedureIsValid, and RelationGetRelationName.
Referenced by _hash_first().
void _hash_doinsert | ( | Relation | rel, |
IndexTuple | itup, | ||
Relation | heapRel | ||
) |
Definition at line 36 of file hashinsert.c.
References _hash_addovflpage(), _hash_dropbuf(), _hash_expandtable(), _hash_finish_split(), _hash_get_indextuple_hashkey(), _hash_getbucketbuf_from_hashkey(), _hash_getbuf(), _hash_pgaddtup(), _hash_relbuf(), _hash_vacuum_one_page(), Assert, BlockNumberIsValid, buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage, CheckForSerializableConflictIn(), END_CRIT_SECTION, ereport, errcode(), errhint(), errmsg(), ERROR, H_BUCKET_BEING_SPLIT, H_HAS_DEAD_TUPLES, HASH_METAPAGE, HASH_NOLOCK, HASH_WRITE, HashMetaPageData::hashm_ffactor, HashMetaPageData::hashm_highmask, HashMetaPageData::hashm_lowmask, HashMetaPageData::hashm_maxbucket, HashMetaPageData::hashm_ntuples, HashMaxItemSize, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageGetMeta, IndexTupleSize, InvalidBuffer, IsBufferCleanupOK(), LH_META_PAGE, LH_OVERFLOW_PAGE, LH_PAGE_TYPE, LockBuffer(), MarkBufferDirty(), MAXALIGN, xl_hash_insert::offnum, PageGetFreeSpace(), PageGetSpecialPointer, PageSetLSN, REGBUF_STANDARD, RelationNeedsWAL, SizeOfHashInsert, START_CRIT_SECTION, XLOG_HASH_INSERT, XLogBeginInsert(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by _h_indexbuild(), hashbuildCallback(), and hashinsert().
Definition at line 275 of file hashpage.c.
References ReleaseBuffer().
Referenced by _hash_doinsert(), _hash_dropscanbuf(), _hash_expandtable(), _hash_finish_split(), _hash_first(), _hash_getbucketbuf_from_hashkey(), _hash_next(), _hash_readprev(), and hashbulkdelete().
void _hash_dropscanbuf | ( | Relation | rel, |
HashScanOpaque | so | ||
) |
Definition at line 287 of file hashpage.c.
References _hash_dropbuf(), HashScanPosData::buf, BufferIsValid, HashScanOpaqueData::currPos, HashScanOpaqueData::hashso_buc_populated, HashScanOpaqueData::hashso_buc_split, HashScanOpaqueData::hashso_bucket_buf, HashScanOpaqueData::hashso_split_bucket_buf, and InvalidBuffer.
Referenced by _hash_next(), hashendscan(), and hashrescan().
Definition at line 615 of file hashpage.c.
References _hash_alloc_buckets(), _hash_checkpage(), _hash_dropbuf(), _hash_finish_split(), _hash_get_totalbuckets(), _hash_getbuf_with_condlock_cleanup(), _hash_getnewbuf(), _hash_relbuf(), _hash_spareindex(), _hash_splitbucket(), Assert, BUCKET_TO_BLKNO, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage, END_CRIT_SECTION, xl_hash_split_allocate_page::flags, H_BUCKET_BEING_SPLIT, H_NEEDS_SPLIT_CLEANUP, hashbucketcleanup(), HashMetaPageData::hashm_ffactor, HashMetaPageData::hashm_highmask, HashMetaPageData::hashm_lowmask, HashMetaPageData::hashm_maxbucket, HashMetaPageData::hashm_ntuples, HashMetaPageData::hashm_ovflpoint, HashMetaPageData::hashm_spares, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, HashPageGetMeta, InvalidBlockNumber, IsBufferCleanupOK(), LH_BUCKET_BEING_POPULATED, LH_BUCKET_BEING_SPLIT, LH_BUCKET_PAGE, LH_META_PAGE, LockBuffer(), MAIN_FORKNUM, MarkBufferDirty(), xl_hash_split_allocate_page::new_bucket, xl_hash_split_allocate_page::new_bucket_flag, xl_hash_split_allocate_page::old_bucket_flag, PageGetSpecialPointer, PageSetLSN, REGBUF_STANDARD, REGBUF_WILL_INIT, RelationNeedsWAL, SizeOfHashSplitAllocPage, START_CRIT_SECTION, XLH_SPLIT_META_UPDATE_MASKS, XLH_SPLIT_META_UPDATE_SPLITPOINT, XLOG_HASH_SPLIT_ALLOCATE_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by _hash_doinsert().
void _hash_finish_split | ( | Relation | rel, |
Buffer | metabuf, | ||
Buffer | obuf, | ||
Bucket | obucket, | ||
uint32 | maxbucket, | ||
uint32 | highmask, | ||
uint32 | lowmask | ||
) |
Definition at line 1353 of file hashpage.c.
References _hash_dropbuf(), _hash_get_newblock_from_oldbucket(), _hash_getbuf(), _hash_relbuf(), _hash_splitbucket(), Assert, BlockNumberIsValid, BUFFER_LOCK_UNLOCK, BufferGetPage, ConditionalLockBufferForCleanup(), CurrentMemoryContext, HASHCTL::entrysize, FirstOffsetNumber, HASH_BLOBS, HASH_CONTEXT, hash_create(), hash_destroy(), HASH_ELEM, HASH_ENTER, HASH_READ, hash_search(), HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_nextblkno, HASHCTL::hcxt, InvalidBuffer, HASHCTL::keysize, LH_BUCKET_PAGE, LH_OVERFLOW_PAGE, LockBuffer(), OffsetNumberNext, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetSpecialPointer, and IndexTupleData::t_tid.
Referenced by _hash_doinsert(), and _hash_expandtable().
bool _hash_first | ( | IndexScanDesc | scan, |
ScanDirection | dir | ||
) |
Definition at line 292 of file hashsearch.c.
References _hash_datum2hashkey(), _hash_datum2hashkey_type(), _hash_dropbuf(), _hash_get_oldblock_from_newbucket(), _hash_getbucketbuf_from_hashkey(), _hash_getbuf(), _hash_readnext(), _hash_readpage(), Assert, BlockNumberIsValid, buf, HashScanPosData::buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage, BufferIsInvalid, cur, HashScanOpaqueData::currPos, ereport, errcode(), errmsg(), ERROR, H_BUCKET_BEING_POPULATED, HASH_READ, HashScanOpaqueData::hashso_buc_populated, HashScanOpaqueData::hashso_buc_split, HashScanOpaqueData::hashso_bucket_buf, HashScanOpaqueData::hashso_sk_hash, HashScanOpaqueData::hashso_split_bucket_buf, HTEqualStrategyNumber, IndexScanDescData::indexRelation, InvalidBuffer, InvalidOid, HashScanPosData::itemIndex, HashScanPosData::items, IndexScanDescData::keyData, LH_BUCKET_PAGE, LockBuffer(), IndexScanDescData::numberOfKeys, IndexScanDescData::opaque, PageGetSpecialPointer, pgstat_count_index_scan, PredicateLockPage(), RelationData::rd_opcintype, ScanDirectionIsBackward, SK_ISNULL, TestForOldSnapshot(), IndexScanDescData::xs_heaptid, and IndexScanDescData::xs_snapshot.
Referenced by hashgetbitmap(), and hashgettuple().
BlockNumber _hash_freeovflpage | ( | Relation | rel, |
Buffer | bucketbuf, | ||
Buffer | ovflbuf, | ||
Buffer | wbuf, | ||
IndexTuple * | itups, | ||
OffsetNumber * | itup_offsets, | ||
Size * | tups_size, | ||
uint16 | nitups, | ||
BufferAccessStrategy | bstrategy | ||
) |
Definition at line 489 of file hashovfl.c.
References _hash_checkpage(), _hash_getbuf(), _hash_getbuf_with_strategy(), _hash_ovflblkno_to_bitno(), _hash_pageinit(), _hash_pgaddmultitup(), _hash_relbuf(), Assert, BlockNumberIsValid, BMPG_MASK, BMPG_SHIFT, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage, BufferGetPageSize, BufferIsValid, CLRBIT, elog, END_CRIT_SECTION, ERROR, HASH_METAPAGE, HASH_READ, HASH_WRITE, HASH_XLOG_FREE_OVFL_BUFS, HashMetaPageData::hashm_firstfree, HashMetaPageData::hashm_mapp, HashMetaPageData::hashm_nmaps, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, HashPageGetBitmap, HashPageGetMeta, i, InvalidBlockNumber, InvalidBuffer, xl_hash_squeeze_page::is_prev_bucket_same_wrt, xl_hash_squeeze_page::is_prim_bucket_same_wrt, ISSET, LH_BITMAP_PAGE, LH_BUCKET_PAGE, LH_META_PAGE, LH_OVERFLOW_PAGE, LH_UNUSED_PAGE, LockBuffer(), MarkBufferDirty(), xl_hash_squeeze_page::nextblkno, xl_hash_squeeze_page::ntups, PageGetSpecialPointer, PageSetLSN, PG_USED_FOR_ASSERTS_ONLY, xl_hash_squeeze_page::prevblkno, REGBUF_NO_IMAGE, REGBUF_STANDARD, RelationNeedsWAL, SizeOfHashSqueezePage, START_CRIT_SECTION, XLOG_HASH_SQUEEZE_PAGE, XLogBeginInsert(), XLogEnsureRecordSpace(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by _hash_squeezebucket().
uint32 _hash_get_indextuple_hashkey | ( | IndexTuple | itup | ) |
Definition at line 306 of file hashutil.c.
References IndexInfoFindDataOffset, and IndexTupleData::t_info.
Referenced by _h_indexbuild(), _hash_binsearch(), _hash_binsearch_last(), _hash_doinsert(), _hash_load_qualified_items(), _hash_pgaddmultitup(), _hash_pgaddtup(), _hash_splitbucket(), hash_page_items(), and hashbucketcleanup().
BlockNumber _hash_get_newblock_from_oldbucket | ( | Relation | rel, |
Bucket | old_bucket | ||
) |
Definition at line 476 of file hashutil.c.
References _hash_get_newbucket_from_oldbucket(), _hash_getbuf(), _hash_relbuf(), BUCKET_TO_BLKNO, BufferGetPage, HASH_METAPAGE, HASH_READ, HashMetaPageData::hashm_lowmask, HashMetaPageData::hashm_maxbucket, HashPageGetMeta, and LH_META_PAGE.
Referenced by _hash_finish_split().
Bucket _hash_get_newbucket_from_oldbucket | ( | Relation | rel, |
Bucket | old_bucket, | ||
uint32 | lowmask, | ||
uint32 | maxbucket | ||
) |
Definition at line 509 of file hashutil.c.
References CALC_NEW_BUCKET.
Referenced by _hash_get_newblock_from_oldbucket(), and hashbucketcleanup().
BlockNumber _hash_get_oldblock_from_newbucket | ( | Relation | rel, |
Bucket | new_bucket | ||
) |
Definition at line 437 of file hashutil.c.
References _hash_getbuf(), _hash_relbuf(), BUCKET_TO_BLKNO, BufferGetPage, fls(), HASH_METAPAGE, HASH_READ, HashPageGetMeta, and LH_META_PAGE.
Referenced by _hash_first().
Definition at line 189 of file hashutil.c.
References HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE, HASH_SPLITPOINT_PHASE_BITS, and HASH_SPLITPOINT_PHASE_MASK.
Referenced by _hash_expandtable(), _hash_init_metabuffer(), _hash_ovflblkno_to_bitno(), and bitno_to_blkno().
Buffer _hash_getbucketbuf_from_hashkey | ( | Relation | rel, |
uint32 | hashkey, | ||
int | access, | ||
HashMetaPage * | cachedmetap | ||
) |
Definition at line 1557 of file hashpage.c.
References _hash_dropbuf(), _hash_getbuf(), _hash_getcachedmetap(), _hash_hashkey2bucket(), _hash_relbuf(), Assert, BUCKET_TO_BLKNO, buf, BufferGetPage, BufferIsValid, HASH_READ, HASH_WRITE, HashMetaPageData::hashm_highmask, HashMetaPageData::hashm_lowmask, HashMetaPageData::hashm_maxbucket, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_prevblkno, InvalidBlockNumber, InvalidBuffer, LH_BUCKET_PAGE, and PageGetSpecialPointer.
Referenced by _hash_doinsert(), and _hash_first().
Buffer _hash_getbuf | ( | Relation | rel, |
BlockNumber | blkno, | ||
int | access, | ||
int | flags | ||
) |
Definition at line 68 of file hashpage.c.
References _hash_checkpage(), buf, elog, ERROR, HASH_NOLOCK, LockBuffer(), P_NEW, and ReadBuffer().
Referenced by _hash_addovflpage(), _hash_doinsert(), _hash_finish_split(), _hash_first(), _hash_freeovflpage(), _hash_get_newblock_from_oldbucket(), _hash_get_oldblock_from_newbucket(), _hash_getbucketbuf_from_hashkey(), _hash_getcachedmetap(), _hash_kill_items(), _hash_next(), _hash_readnext(), _hash_readprev(), _hash_splitbucket(), hash_bitmap_info(), hashbulkdelete(), and pgstathashindex().
Buffer _hash_getbuf_with_condlock_cleanup | ( | Relation | rel, |
BlockNumber | blkno, | ||
int | flags | ||
) |
Definition at line 94 of file hashpage.c.
References _hash_checkpage(), buf, ConditionalLockBufferForCleanup(), elog, ERROR, InvalidBuffer, P_NEW, ReadBuffer(), and ReleaseBuffer().
Referenced by _hash_expandtable().
Buffer _hash_getbuf_with_strategy | ( | Relation | rel, |
BlockNumber | blkno, | ||
int | access, | ||
int | flags, | ||
BufferAccessStrategy | bstrategy | ||
) |
Definition at line 237 of file hashpage.c.
References _hash_checkpage(), buf, elog, ERROR, HASH_NOLOCK, LockBuffer(), MAIN_FORKNUM, P_NEW, RBM_NORMAL, and ReadBufferExtended().
Referenced by _hash_freeovflpage(), _hash_squeezebucket(), hashbucketcleanup(), and pgstat_hash_page().
HashMetaPage _hash_getcachedmetap | ( | Relation | rel, |
Buffer * | metabuf, | ||
bool | force_refresh | ||
) |
Definition at line 1499 of file hashpage.c.
References _hash_getbuf(), Assert, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetPage, BufferIsValid, HASH_METAPAGE, HASH_READ, HashPageGetMeta, LH_META_PAGE, LockBuffer(), MemoryContextAlloc(), RelationData::rd_amcache, and RelationData::rd_indexcxt.
Referenced by _hash_getbucketbuf_from_hashkey(), and hashbulkdelete().
Buffer _hash_getinitbuf | ( | Relation | rel, |
BlockNumber | blkno | ||
) |
Definition at line 133 of file hashpage.c.
References _hash_pageinit(), buf, BufferGetPage, BufferGetPageSize, elog, ERROR, MAIN_FORKNUM, P_NEW, RBM_ZERO_AND_LOCK, and ReadBufferExtended().
Referenced by _hash_addovflpage().
Buffer _hash_getnewbuf | ( | Relation | rel, |
BlockNumber | blkno, | ||
ForkNumber | forkNum | ||
) |
Definition at line 196 of file hashpage.c.
References _hash_pageinit(), buf, BufferGetBlockNumber(), BufferGetPage, BufferGetPageSize, elog, ERROR, HASH_WRITE, LockBuffer(), P_NEW, RBM_NORMAL, RBM_ZERO_AND_LOCK, ReadBufferExtended(), RelationGetNumberOfBlocksInFork(), and RelationGetRelationName.
Referenced by _hash_addovflpage(), _hash_expandtable(), and _hash_init().
Definition at line 125 of file hashutil.c.
Referenced by _h_indexbuild(), _hash_getbucketbuf_from_hashkey(), _hash_splitbucket(), comparetup_index_hash(), and hashbucketcleanup().
uint32 _hash_init | ( | Relation | rel, |
double | num_tuples, | ||
ForkNumber | forkNum | ||
) |
Definition at line 325 of file hashpage.c.
References _hash_getnewbuf(), _hash_init_metabuffer(), _hash_initbitmapbuffer(), _hash_initbuf(), _hash_relbuf(), xl_hash_init_bitmap_page::bmsize, BUCKET_TO_BLKNO, buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage, CHECK_FOR_INTERRUPTS, elog, ereport, errcode(), errmsg(), ERROR, xl_hash_init_meta_page::ffactor, HASH_MAX_BITMAPS, HASH_METAPAGE, HashGetTargetPageUsage, HashMetaPageData::hashm_bmsize, HashMetaPageData::hashm_ffactor, HashMetaPageData::hashm_mapp, HashMetaPageData::hashm_maxbucket, HashMetaPageData::hashm_nmaps, HashMetaPageData::hashm_procid, HashPageGetMeta, HASHSTANDARD_PROC, i, index_getprocid(), INIT_FORKNUM, LH_BUCKET_PAGE, LockBuffer(), log_newpage(), MarkBufferDirty(), MAXALIGN, xl_hash_init_meta_page::num_tuples, PageSetLSN, xl_hash_init_meta_page::procid, RelationData::rd_node, REGBUF_STANDARD, REGBUF_WILL_INIT, RelationGetNumberOfBlocksInFork(), RelationGetRelationName, RelationNeedsWAL, SizeOfHashInitBitmapPage, SizeOfHashInitMetaPage, XLOG_HASH_INIT_BITMAP_PAGE, XLOG_HASH_INIT_META_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().
Referenced by hashbuild(), and hashbuildempty().
void _hash_init_metabuffer | ( | Buffer | buf, |
double | num_tuples, | ||
RegProcedure | procid, | ||
uint16 | ffactor, | ||
bool | initpage | ||
) |
Definition at line 496 of file hashpage.c.
References _hash_get_totalbuckets(), _hash_log2(), _hash_pageinit(), _hash_spareindex(), Assert, BMPG_MASK, BMPG_SHIFT, BufferGetPage, BufferGetPageSize, BYTE_TO_BIT, HASH_MAGIC, HASH_MAX_SPLITPOINTS, HASH_VERSION, HashGetMaxBitmapSize, HashMetaPageData::hashm_bmshift, HashMetaPageData::hashm_bmsize, HashMetaPageData::hashm_bsize, HashMetaPageData::hashm_ffactor, HashMetaPageData::hashm_firstfree, HashMetaPageData::hashm_highmask, HashMetaPageData::hashm_lowmask, HashMetaPageData::hashm_magic, HashMetaPageData::hashm_mapp, HashMetaPageData::hashm_maxbucket, HashMetaPageData::hashm_nmaps, HashMetaPageData::hashm_ntuples, HashMetaPageData::hashm_ovflpoint, HashMetaPageData::hashm_procid, HashMetaPageData::hashm_spares, HashMetaPageData::hashm_version, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, HashPageGetMeta, i, InvalidBlockNumber, LH_META_PAGE, MemSet, and PageGetSpecialPointer.
Referenced by _hash_init(), and hash_xlog_init_meta_page().
Definition at line 740 of file hashovfl.c.
References _hash_pageinit(), BufferGetPage, BufferGetPageSize, HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, HashPageGetBitmap, InvalidBlockNumber, LH_BITMAP_PAGE, MemSet, and PageGetSpecialPointer.
Referenced by _hash_addovflpage(), _hash_init(), hash_xlog_add_ovfl_page(), and hash_xlog_init_bitmap_page().
Definition at line 155 of file hashpage.c.
References _hash_pageinit(), BufferGetPage, BufferGetPageSize, flag(), HashPageOpaqueData::hasho_bucket, HashPageOpaqueData::hasho_flag, HashPageOpaqueData::hasho_nextblkno, HashPageOpaqueData::hasho_page_id, HASHO_PAGE_ID, HashPageOpaqueData::hasho_prevblkno, InvalidBlockNumber, and PageGetSpecialPointer.
Referenced by _hash_init(), hash_xlog_add_ovfl_page(), and hash_xlog_split_allocate_page().
void _hash_kill_items | ( | IndexScanDesc | scan | ) |
Definition at line 551 of file hashutil.c.
References _hash_getbuf(), _hash_relbuf(), Assert, buf, HashScanPosData::buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetPage, HashScanPosData::currPage, HashScanOpaqueData::currPos, HashScanPosData::firstItem, HASH_READ, HashScanPosIsPinned, HashScanPosIsValid, HashScanOpaqueData::hashso_bucket_buf, HashScanPosItem::heapTid, i, HashScanPosItem::indexOffset, IndexScanDescData::indexRelation, ItemIdMarkDead, ItemPointerEquals(), HashScanPosData::items, HashScanOpaqueData::killedItems, LH_OVERFLOW_PAGE, LH_PAGE_HAS_DEAD_TUPLES, LockBuffer(), MarkBufferDirtyHint(), HashScanOpaqueData::numKilled, OffsetNumberNext, IndexScanDescData::opaque, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageGetSpecialPointer, and IndexTupleData::t_tid.
Referenced by _hash_next(), _hash_readpage(), hashendscan(), and hashrescan().
Definition at line 141 of file hashutil.c.
References i.
Referenced by _h_spoolinit(), _hash_init_metabuffer(), and _hash_spareindex().
bool _hash_next | ( | IndexScanDesc | scan, |
ScanDirection | dir | ||
) |
Definition at line 48 of file hashsearch.c.
References _hash_dropbuf(), _hash_dropscanbuf(), _hash_getbuf(), _hash_kill_items(), _hash_readpage(), BlockNumberIsValid, buf, BufferGetPage, HashScanOpaqueData::currPos, HashScanPosData::firstItem, HASH_READ, HashScanPosInvalidate, HashScanOpaqueData::hashso_bucket_buf, HashScanOpaqueData::hashso_split_bucket_buf, IndexScanDescData::indexRelation, HashScanPosData::itemIndex, HashScanPosData::items, HashScanPosData::lastItem, LH_BUCKET_PAGE, LH_OVERFLOW_PAGE, HashScanPosData::nextPage, HashScanOpaqueData::numKilled, IndexScanDescData::opaque, HashScanPosData::prevPage, ScanDirectionIsForward, TestForOldSnapshot(), IndexScanDescData::xs_heaptid, and IndexScanDescData::xs_snapshot.
Referenced by hashgetbitmap(), and hashgettuple().
uint32 _hash_ovflblkno_to_bitno | ( | HashMetaPage | metap, |
BlockNumber | ovflblkno | ||
) |
Definition at line 61 of file hashovfl.c.
References _hash_get_totalbuckets(), ereport, errcode(), errmsg(), ERROR, HashMetaPageData::hashm_ovflpoint, HashMetaPageData::hashm_spares, and i.
Referenced by _hash_freeovflpage(), and hash_bitmap_info().