24#define CALC_NEW_BUCKET(old_bucket, lowmask) \
25 old_bucket | (lowmask + 1)
44 while (scanKeySize > 0)
62 datum,
key->sk_argument);
113 elog(
ERROR,
"missing support function %d(%u,%u) for index \"%s\"",
130 bucket = hashkey & highmask;
131 if (bucket > maxbucket)
132 bucket = bucket & lowmask;
150 return splitpoint_group;
162 (((num_bucket - 1) >>
166 return splitpoint_phases;
178 uint32 phases_within_splitpoint_group;
181 return (1 << splitpoint_phase);
190 total_buckets = (1 << (splitpoint_group - 1));
193 phases_within_splitpoint_group =
198 phases_within_splitpoint_group);
200 return total_buckets;
222 (
errcode(ERRCODE_INDEX_CORRUPTED),
223 errmsg(
"index \"%s\" contains unexpected zero page at block %u",
226 errhint(
"Please REINDEX it.")));
233 (
errcode(ERRCODE_INDEX_CORRUPTED),
234 errmsg(
"index \"%s\" contains corrupted page at block %u",
237 errhint(
"Please REINDEX it.")));
245 (
errcode(ERRCODE_INDEX_CORRUPTED),
246 errmsg(
"index \"%s\" contains corrupted page at block %u",
249 errhint(
"Please REINDEX it.")));
261 (
errcode(ERRCODE_INDEX_CORRUPTED),
262 errmsg(
"index \"%s\" is not a hash index",
267 (
errcode(ERRCODE_INDEX_CORRUPTED),
268 errmsg(
"index \"%s\" has wrong hash version",
270 errhint(
"Please REINDEX it.")));
300 return *((
uint32 *) attp);
319 Datum *user_values,
bool *user_isnull,
320 Datum *index_values,
bool *index_isnull)
333 index_isnull[0] =
false;
370 if (hashkey < hash_value)
408 if (hashkey > hash_value)
439 old_bucket = new_bucket & mask;
500 if (new_bucket > maxbucket)
502 lowmask = lowmask >> 1;
548 bool killedsomething =
false;
549 bool havePin =
false;
579 for (
i = 0;
i < numKilled;
i++)
587 itemIndex <= so->currPos.lastItem);
589 while (offnum <= maxoff)
598 killedsomething =
true;
BlockNumber BufferGetBlockNumber(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
#define BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
static Page BufferGetPage(Buffer buffer)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
static uint16 PageGetSpecialSize(Page page)
#define RegProcedureIsValid(p)
#define Assert(condition)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
#define HashPageGetOpaque(page)
#define HASHSTANDARD_PROC
#define HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE
#define HashScanPosIsPinned(scanpos)
#define HashPageGetMeta(page)
#define BUCKET_TO_BLKNO(metap, B)
#define HASH_SPLITPOINT_PHASE_MASK
HashScanOpaqueData * HashScanOpaque
#define HashScanPosIsValid(scanpos)
#define HASH_SPLITPOINT_PHASE_BITS
#define LH_PAGE_HAS_DEAD_TUPLES
void _hash_relbuf(Relation rel, Buffer buf)
Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access, int flags)
uint32 _hash_spareindex(uint32 num_bucket)
BlockNumber _hash_get_newblock_from_oldbucket(Relation rel, Bucket old_bucket)
uint32 _hash_get_totalbuckets(uint32 splitpoint_phase)
uint32 _hash_get_indextuple_hashkey(IndexTuple itup)
bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
OffsetNumber _hash_binsearch(Page page, uint32 hash_value)
uint32 _hash_datum2hashkey(Relation rel, Datum key)
Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket, uint32 highmask, uint32 lowmask)
OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value)
void _hash_checkpage(Relation rel, Buffer buf, int flags)
Bucket _hash_get_newbucket_from_oldbucket(Relation rel, Bucket old_bucket, uint32 lowmask, uint32 maxbucket)
bytea * hashoptions(Datum reloptions, bool validate)
BlockNumber _hash_get_oldblock_from_newbucket(Relation rel, Bucket new_bucket)
uint32 _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
void _hash_kill_items(IndexScanDesc scan)
#define CALC_NEW_BUCKET(old_bucket, lowmask)
bool _hash_convert_tuple(Relation index, Datum *user_values, bool *user_isnull, Datum *index_values, bool *index_isnull)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
#define ItemIdMarkDead(itemId)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
IndexTupleData * IndexTuple
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static Size IndexInfoFindDataOffset(unsigned short t_info)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
#define OffsetNumberIsValid(offsetNumber)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
static int pg_leftmost_one_pos32(uint32 word)
static uint32 pg_ceil_log2_32(uint32 num)
static uint32 DatumGetUInt32(Datum X)
static bool DatumGetBool(Datum X)
static Datum UInt32GetDatum(uint32 X)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
HashScanPosItem items[MaxIndexTuplesPerPage]
struct ScanKeyData * keyData