1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* hash.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* header file for postgres hash access method implementation
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
* $Id: hash.h,v 1.39 2001/07/15 22:48:18 tgl Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* modeled after Margo Seltzer's hash implementation for unix.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef HASH_H
|
|
|
|
#define HASH_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/itup.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "access/relscan.h"
|
|
|
|
#include "access/sdir.h"
|
2000-11-21 22:16:06 +01:00
|
|
|
#include "access/xlog.h"
|
2000-06-05 09:29:25 +02:00
|
|
|
#include "fmgr.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* An overflow page is a spare page allocated for storing data whose
|
1996-08-27 23:50:29 +02:00
|
|
|
* bucket doesn't have room to store it. We use overflow pages rather
|
|
|
|
* than just splitting the bucket because there is a linear order in
|
|
|
|
* the way we split buckets. In other words, if there isn't enough space
|
1997-09-07 07:04:48 +02:00
|
|
|
* in the bucket itself, put it in an overflow page.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
* Overflow page addresses are stored in form: (Splitnumber, Page offset).
|
|
|
|
*
|
|
|
|
* A splitnumber is the number of the generation where the table doubles
|
|
|
|
* in size. The ovflpage's offset within the splitnumber; offsets start
|
1997-09-07 07:04:48 +02:00
|
|
|
* at 1.
|
|
|
|
*
|
1996-08-27 23:50:29 +02:00
|
|
|
* We convert the stored bitmap address into a page address with the
|
1997-09-07 07:04:48 +02:00
|
|
|
* macro OADDR_OF(S, O) where S is the splitnumber and O is the page
|
|
|
|
* offset.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef uint32 Bucket;
|
|
|
|
typedef bits16 OverflowPageAddress;
|
|
|
|
typedef uint32 SplitNumber;
|
|
|
|
typedef uint32 PageOffset;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* A valid overflow address will always have a page offset >= 1 */
|
1997-09-07 07:04:48 +02:00
|
|
|
#define InvalidOvflAddress 0
|
|
|
|
|
|
|
|
#define SPLITSHIFT 11
|
|
|
|
#define SPLITMASK 0x7FF
|
|
|
|
#define SPLITNUM(N) ((SplitNumber)(((uint32)(N)) >> SPLITSHIFT))
|
|
|
|
#define OPAGENUM(N) ((PageOffset)((N) & SPLITMASK))
|
|
|
|
#define OADDR_OF(S,O) ((OverflowPageAddress)((uint32)((uint32)(S) << SPLITSHIFT) + (O)))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
#define BUCKET_TO_BLKNO(B) \
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
((Bucket) ((B) + ((B) ? metap->hashm_spares[_hash_log2((B)+1)-1] : 0)) + 1)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define OADDR_TO_BLKNO(B) \
|
|
|
|
((BlockNumber) \
|
|
|
|
(BUCKET_TO_BLKNO ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B))));
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
1996-08-27 23:50:29 +02:00
|
|
|
* hasho_flag tells us which type of page we're looking at. For
|
|
|
|
* example, knowing overflow pages from bucket pages is necessary
|
|
|
|
* information when you're deleting tuples from a page. If all the
|
|
|
|
* tuples are deleted from an overflow page, the overflow is made
|
|
|
|
* available to other buckets by calling _hash_freeovflpage(). If all
|
|
|
|
* the tuples are deleted from a bucket page, no additional action is
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define LH_UNUSED_PAGE (0)
|
|
|
|
#define LH_OVERFLOW_PAGE (1 << 0)
|
|
|
|
#define LH_BUCKET_PAGE (1 << 1)
|
|
|
|
#define LH_BITMAP_PAGE (1 << 2)
|
|
|
|
#define LH_META_PAGE (1 << 3)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HashPageOpaqueData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
bits16 hasho_flag; /* is this page a bucket or ovfl */
|
|
|
|
Bucket hasho_bucket; /* bucket number this pg belongs to */
|
1997-09-07 07:04:48 +02:00
|
|
|
OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */
|
1997-09-08 04:41:22 +02:00
|
|
|
BlockNumber hasho_nextblkno;/* next ovfl blkno */
|
|
|
|
BlockNumber hasho_prevblkno;/* previous ovfl (or bucket) blkno */
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashPageOpaqueData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef HashPageOpaqueData *HashPageOpaque;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* ScanOpaqueData is used to remember which buffers we're currently
|
|
|
|
* examining in the scan. We keep these buffers locked and pinned and
|
|
|
|
* recorded in the opaque entry of the scan in order to avoid doing a
|
|
|
|
* ReadBuffer() for every tuple in the index. This avoids semop() calls,
|
|
|
|
* which are expensive.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HashScanOpaqueData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Buffer hashso_curbuf;
|
|
|
|
Buffer hashso_mrkbuf;
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashScanOpaqueData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef HashScanOpaqueData *HashScanOpaque;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
1996-08-27 23:50:29 +02:00
|
|
|
* Definitions for metapage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HASH_METAPAGE 0 /* metapage is always block 0 */
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HASH_MAGIC 0x6440640
|
1996-08-27 23:50:29 +02:00
|
|
|
#define HASH_VERSION 0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NCACHED is used to set the array sizeof spares[] & bitmaps[].
|
|
|
|
*
|
|
|
|
* Spares[] is used to hold the number overflow pages currently
|
|
|
|
* allocated at a certain splitpoint. For example, if spares[3] = 7
|
|
|
|
* then there are a maximum of 7 ovflpages available at splitpoint 3.
|
|
|
|
* The value in spares[] will change as ovflpages are added within
|
1997-09-07 07:04:48 +02:00
|
|
|
* a splitpoint.
|
|
|
|
*
|
1996-08-27 23:50:29 +02:00
|
|
|
* Within a splitpoint, one can find which ovflpages are available and
|
|
|
|
* which are used by looking at a bitmaps that are stored on the ovfl
|
|
|
|
* pages themselves. There is at least one bitmap for every splitpoint's
|
1997-09-07 07:04:48 +02:00
|
|
|
* ovflpages. Bitmaps[] contains the ovflpage addresses of the ovflpages
|
|
|
|
* that hold the ovflpage bitmaps.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
* The reason that the size is restricted to NCACHED (32) is because
|
|
|
|
* the bitmaps are 16 bits: upper 5 represent the splitpoint, lower 11
|
1997-09-07 07:04:48 +02:00
|
|
|
* indicate the page number within the splitpoint. Since there are
|
|
|
|
* only 5 bits to store the splitpoint, there can only be 32 splitpoints.
|
1996-08-27 23:50:29 +02:00
|
|
|
* Both spares[] and bitmaps[] use splitpoints as there indices, so there
|
1997-09-07 07:04:48 +02:00
|
|
|
* can only be 32 of them.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NCACHED 32
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct HashMetaPageData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
PageHeaderData hashm_phdr; /* pad for page header (do not use) */
|
|
|
|
uint32 hashm_magic; /* magic no. for hash tables */
|
|
|
|
uint32 hashm_version; /* version ID */
|
|
|
|
uint32 hashm_nkeys; /* number of keys stored in the table */
|
|
|
|
uint16 hashm_ffactor; /* fill factor */
|
|
|
|
uint16 hashm_bsize; /* bucket size (bytes) - must be a power
|
1997-09-07 07:04:48 +02:00
|
|
|
* of 2 */
|
1997-09-08 04:41:22 +02:00
|
|
|
uint16 hashm_bshift; /* bucket shift */
|
|
|
|
uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a
|
|
|
|
* power of 2 */
|
|
|
|
uint32 hashm_maxbucket;/* ID of maximum bucket in use */
|
|
|
|
uint32 hashm_highmask; /* mask to modulo into entire table */
|
|
|
|
uint32 hashm_lowmask; /* mask to modulo into lower half of table */
|
|
|
|
uint32 hashm_ovflpoint;/* pageno. from which ovflpgs being
|
|
|
|
* allocated */
|
|
|
|
uint32 hashm_lastfreed;/* last ovflpage freed */
|
|
|
|
uint32 hashm_nmaps; /* Initial number of bitmaps */
|
|
|
|
uint32 hashm_spares[NCACHED]; /* spare pages available at
|
|
|
|
* splitpoints */
|
|
|
|
BlockNumber hashm_mapp[NCACHED]; /* blknumbers of ovfl page maps */
|
|
|
|
RegProcedure hashm_procid; /* hash procedure id from pg_proc */
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashMetaPageData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
typedef HashMetaPageData *HashMetaPage;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool BuildingHash;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct HashItemData
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
IndexTupleData hash_itup;
|
1997-09-08 23:56:23 +02:00
|
|
|
} HashItemData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef HashItemData *HashItem;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Constants
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define DEFAULT_FFACTOR 300
|
|
|
|
#define SPLITMAX 8
|
|
|
|
#define BYTE_TO_BIT 3 /* 2^3 bits/byte */
|
|
|
|
#define INT_TO_BYTE 2 /* 2^2 bytes/int */
|
|
|
|
#define INT_TO_BIT 5 /* 2^5 bits/int */
|
|
|
|
#define ALL_SET ((uint32) ~0)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* bitmap pages do not contain tuples. they do contain the standard
|
1996-08-27 23:50:29 +02:00
|
|
|
* page headers and trailers; however, everything in between is a
|
|
|
|
* giant bit array. the number of bits that fit on a page obviously
|
|
|
|
* depends on the page size and the header/trailer overhead.
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define BMPGSZ_BYTE(metap) ((metap)->hashm_bmsize)
|
|
|
|
#define BMPGSZ_BIT(metap) ((metap)->hashm_bmsize << BYTE_TO_BIT)
|
|
|
|
#define HashPageGetBitmap(pg) \
|
1999-07-19 09:07:29 +02:00
|
|
|
((uint32 *) (((char *) (pg)) + MAXALIGN(sizeof(PageHeaderData))))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The number of bits in an ovflpage bitmap which
|
|
|
|
* tells which ovflpages are empty versus in use (NOT the number of
|
1997-09-07 07:04:48 +02:00
|
|
|
* bits in an overflow page *address* bitmap).
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define BITS_PER_MAP 32 /* Number of bits in ovflpage bitmap */
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* Given the address of the beginning of a big map, clear/set the nth bit */
|
|
|
|
#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
|
|
|
|
#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
|
1997-09-07 07:04:48 +02:00
|
|
|
#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* page locking modes
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HASH_READ 0
|
|
|
|
#define HASH_WRITE 1
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
|
|
|
* In general, the hash code tries to localize its knowledge about page
|
|
|
|
* layout to a couple of routines. However, we need a special value to
|
|
|
|
* indicate "no page number" in those places where we expect page numbers.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define P_NONE 0
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Strategy number. There's only one valid strategy for hashing: equality.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HTEqualStrategyNumber 1
|
|
|
|
#define HTMaxStrategyNumber 1
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* When a new operator class is declared, we require that the user supply
|
|
|
|
* us with an amproc procudure for hashing a key of the new type.
|
|
|
|
* Since we only have one such proc in amproc, it's number 1.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HASHPROC 1
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* public routines */
|
|
|
|
|
2000-06-13 09:35:40 +02:00
|
|
|
extern Datum hashbuild(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashinsert(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashgettuple(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashbeginscan(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashrescan(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashendscan(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashmarkpos(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashrestrpos(PG_FUNCTION_ARGS);
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
extern Datum hashbulkdelete(PG_FUNCTION_ARGS);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
/*
|
|
|
|
* Datatype-specific hash functions in hashfunc.c.
|
|
|
|
*
|
|
|
|
* NOTE: some of these are also used by catcache operations, without
|
|
|
|
* any direct connection to hash indexes.
|
|
|
|
*/
|
2000-06-19 05:55:01 +02:00
|
|
|
extern Datum hashchar(PG_FUNCTION_ARGS);
|
2000-06-05 09:29:25 +02:00
|
|
|
extern Datum hashint2(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashint4(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashint8(PG_FUNCTION_ARGS);
|
2000-06-19 05:55:01 +02:00
|
|
|
extern Datum hashoid(PG_FUNCTION_ARGS);
|
2000-06-05 09:29:25 +02:00
|
|
|
extern Datum hashfloat4(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashfloat8(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashoidvector(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashint2vector(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hashname(PG_FUNCTION_ARGS);
|
2000-06-19 05:55:01 +02:00
|
|
|
extern Datum hashvarlena(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum hash_any(char *keydata, int keylen);
|
2000-06-05 09:29:25 +02:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* private routines */
|
|
|
|
|
|
|
|
/* hashinsert.c */
|
|
|
|
extern InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem);
|
|
|
|
|
|
|
|
|
|
|
|
/* hashovfl.c */
|
1997-09-08 22:59:27 +02:00
|
|
|
extern Buffer _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern int32 _hash_initbitmap(Relation rel, HashMetaPage metap, int32 pnum,
|
1997-09-07 07:04:48 +02:00
|
|
|
int32 nbits, int32 ndx);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void _hash_squeezebucket(Relation rel, HashMetaPage metap,
|
1997-09-07 07:04:48 +02:00
|
|
|
Bucket bucket);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* hashpage.c */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void _hash_metapinit(Relation rel);
|
|
|
|
extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access);
|
|
|
|
extern void _hash_relbuf(Relation rel, Buffer buf, int access);
|
|
|
|
extern void _hash_wrtbuf(Relation rel, Buffer buf);
|
|
|
|
extern void _hash_wrtnorelbuf(Relation rel, Buffer buf);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Page _hash_chgbufaccess(Relation rel, Buffer *bufp, int from_access,
|
1997-09-07 07:04:48 +02:00
|
|
|
int to_access);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void _hash_pageinit(Page page, Size size);
|
|
|
|
extern void _hash_pagedel(Relation rel, ItemPointer tid);
|
|
|
|
extern void _hash_expandtable(Relation rel, Buffer metabuf);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* hashscan.c */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void _hash_regscan(IndexScanDesc scan);
|
|
|
|
extern void _hash_dropscan(IndexScanDesc scan);
|
|
|
|
extern void _hash_adjscans(Relation rel, ItemPointer tid);
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
extern void AtEOXact_hash(void);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* hashsearch.c */
|
1998-09-01 06:40:42 +02:00
|
|
|
extern void _hash_search(Relation rel, int keysz, ScanKey scankey,
|
1997-09-08 22:59:27 +02:00
|
|
|
Buffer *bufP, HashMetaPage metap);
|
1996-08-27 23:50:29 +02:00
|
|
|
extern RetrieveIndexResult _hash_next(IndexScanDesc scan, ScanDirection dir);
|
|
|
|
extern RetrieveIndexResult _hash_first(IndexScanDesc scan, ScanDirection dir);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern bool _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir,
|
1997-09-07 07:04:48 +02:00
|
|
|
Buffer metabuf);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* hashutil.c */
|
1998-09-01 06:40:42 +02:00
|
|
|
extern ScanKey _hash_mkscankey(Relation rel, IndexTuple itup,
|
1997-09-07 07:04:48 +02:00
|
|
|
HashMetaPage metap);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void _hash_freeskey(ScanKey skey);
|
|
|
|
extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup);
|
1996-08-27 23:50:29 +02:00
|
|
|
extern HashItem _hash_formitem(IndexTuple itup);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key);
|
|
|
|
extern uint32 _hash_log2(uint32 num);
|
|
|
|
extern void _hash_checkpage(Page page, int flags);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-11-21 22:16:06 +01:00
|
|
|
|
|
|
|
/* hash.c */
|
|
|
|
extern void hash_redo(XLogRecPtr lsn, XLogRecord *record);
|
|
|
|
extern void hash_undo(XLogRecPtr lsn, XLogRecord *record);
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void hash_desc(char *buf, uint8 xl_info, char *rec);
|
2000-11-21 22:16:06 +01:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* HASH_H */
|