mirror of https://github.com/postgres/postgres
parent
9247b29228
commit
5a8820efcd
@ -0,0 +1,61 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* attnum.h-- |
||||||
|
* POSTGRES attribute number definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: attnum.h,v 1.1 1996/08/27 21:50:07 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef ATTNUM_H |
||||||
|
#define ATTNUM_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* user defined attribute numbers start at 1. -ay 2/95 |
||||||
|
*/ |
||||||
|
typedef int16 AttrNumber; |
||||||
|
|
||||||
|
#define InvalidAttrNumber 0 |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* support macros |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
/*
|
||||||
|
* AttributeNumberIsValid -- |
||||||
|
* True iff the attribute number is valid. |
||||||
|
*/ |
||||||
|
#define AttributeNumberIsValid(attributeNumber) \ |
||||||
|
((bool) ((attributeNumber) != InvalidAttrNumber)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* AttrNumberIsForUserDefinedAttr -- |
||||||
|
* True iff the attribute number corresponds to an user defined attribute. |
||||||
|
*/ |
||||||
|
#define AttrNumberIsForUserDefinedAttr(attributeNumber) \ |
||||||
|
((bool) ((attributeNumber) > 0)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* AttrNumberGetAttrOffset -- |
||||||
|
* Returns the attribute offset for an attribute number. |
||||||
|
* |
||||||
|
* Note: |
||||||
|
* Assumes the attribute number is for an user defined attribute. |
||||||
|
*/ |
||||||
|
#define AttrNumberGetAttrOffset(attNum) \ |
||||||
|
(AssertMacro(AttrNumberIsForUserDefinedAttr(attNum)) ? \
|
||||||
|
((attNum - 1)) : 0) |
||||||
|
|
||||||
|
/*
|
||||||
|
* AttributeOffsetGetAttributeNumber -- |
||||||
|
* Returns the attribute number for an attribute offset. |
||||||
|
*/ |
||||||
|
#define AttrOffsetGetAttrNumber(attributeOffset) \ |
||||||
|
((AttrNumber) (1 + attributeOffset)) |
||||||
|
|
||||||
|
#endif /* ATTNUM_H */ |
@ -0,0 +1,43 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* funcindex.h-- |
||||||
|
*
|
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: funcindex.h,v 1.1 1996/08/27 21:50:08 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef _FUNC_INDEX_INCLUDED_ |
||||||
|
#define _FUNC_INDEX_INCLUDED_ |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
|
||||||
|
typedef struct { |
||||||
|
int nargs; |
||||||
|
Oid arglist[8]; |
||||||
|
Oid procOid; |
||||||
|
NameData funcName; |
||||||
|
} FuncIndexInfo; |
||||||
|
|
||||||
|
typedef FuncIndexInfo *FuncIndexInfoPtr; |
||||||
|
|
||||||
|
/*
|
||||||
|
* some marginally useful macro definitions |
||||||
|
*/ |
||||||
|
/* #define FIgetname(FINFO) (&((FINFO)->funcName.data[0]))*/ |
||||||
|
#define FIgetname(FINFO) (FINFO)->funcName.data |
||||||
|
#define FIgetnArgs(FINFO) (FINFO)->nargs |
||||||
|
#define FIgetProcOid(FINFO) (FINFO)->procOid |
||||||
|
#define FIgetArg(FINFO, argnum) (FINFO)->arglist[argnum] |
||||||
|
#define FIgetArglist(FINFO) (FINFO)->arglist |
||||||
|
|
||||||
|
#define FIsetnArgs(FINFO, numargs) ((FINFO)->nargs = numargs) |
||||||
|
#define FIsetProcOid(FINFO, id) ((FINFO)->procOid = id) |
||||||
|
#define FIsetArg(FINFO, argnum, argtype) ((FINFO)->arglist[argnum] = argtype) |
||||||
|
|
||||||
|
#define FIisFunctionalIndex(FINFO) (FINFO->procOid != InvalidOid) |
||||||
|
|
||||||
|
#endif /* FUNCINDEX_H */ |
@ -0,0 +1,61 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* genam.h-- |
||||||
|
* POSTGRES general access method definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: genam.h,v 1.1 1996/08/27 21:50:09 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef GENAM_H |
||||||
|
#define GENAM_H |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
|
||||||
|
#include "access/attnum.h" |
||||||
|
#include "access/htup.h" |
||||||
|
#include "access/istrat.h" |
||||||
|
#include "access/itup.h" |
||||||
|
#include "access/relscan.h" |
||||||
|
#include "access/skey.h" |
||||||
|
#include "access/sdir.h" |
||||||
|
#include "access/funcindex.h" |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* generalized index_ interface routines |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
extern Relation index_open(Oid relationId); |
||||||
|
extern Relation index_openr(char *relationName); |
||||||
|
extern void index_close(Relation relation); |
||||||
|
extern InsertIndexResult index_insert(Relation relation, |
||||||
|
Datum *datum, char *nulls, |
||||||
|
ItemPointer heap_t_ctid); |
||||||
|
extern void index_delete(Relation relation, ItemPointer indexItem); |
||||||
|
extern IndexScanDesc index_beginscan(Relation relation, bool scanFromEnd, |
||||||
|
uint16 numberOfKeys, ScanKey key); |
||||||
|
extern void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key); |
||||||
|
extern void index_endscan(IndexScanDesc scan); |
||||||
|
extern void index_markpos(IndexScanDesc scan); |
||||||
|
extern void index_restrpos(IndexScanDesc scan); |
||||||
|
extern RetrieveIndexResult index_getnext(IndexScanDesc scan, |
||||||
|
ScanDirection direction); |
||||||
|
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum, |
||||||
|
uint16 procnum); |
||||||
|
extern Datum GetIndexValue(HeapTuple tuple, TupleDesc hTupDesc, |
||||||
|
int attOff, AttrNumber attrNums[], FuncIndexInfo *fInfo, |
||||||
|
bool *attNull, Buffer buffer); |
||||||
|
|
||||||
|
/* in genam.c */ |
||||||
|
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd, |
||||||
|
uint16 numberOfKeys, ScanKey key); |
||||||
|
extern void IndexScanRestart(IndexScanDesc scan, bool scanFromEnd, |
||||||
|
ScanKey key); |
||||||
|
extern void IndexScanEnd(IndexScanDesc scan); |
||||||
|
extern void IndexScanMarkPosition(IndexScanDesc scan); |
||||||
|
extern void IndexScanRestorePosition(IndexScanDesc scan); |
||||||
|
|
||||||
|
#endif /* GENAM_H */ |
@ -0,0 +1,152 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* gist.h-- |
||||||
|
* common declarations for the GiST access method code. |
||||||
|
* |
||||||
|
* |
||||||
|
* |
||||||
|
*
|
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef GIST_H |
||||||
|
#define GIST_H |
||||||
|
|
||||||
|
#include "utils/rel.h" |
||||||
|
#include "storage/off.h" |
||||||
|
#include "storage/block.h" |
||||||
|
#include "storage/bufpage.h" |
||||||
|
#include "access/skey.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
** You can have as many strategies as you please in GiSTs, as |
||||||
|
** long as your consistent method can handle them |
||||||
|
*/ |
||||||
|
#define GISTNStrategies 100 |
||||||
|
|
||||||
|
/*
|
||||||
|
** Helper routines |
||||||
|
*/ |
||||||
|
#define GISTNProcs 8 |
||||||
|
#define GIST_CONSISTENT_PROC 1 |
||||||
|
#define GIST_UNION_PROC 2 |
||||||
|
#define GIST_COMPRESS_PROC 3 |
||||||
|
#define GIST_DECOMPRESS_PROC 4 |
||||||
|
#define GIST_PENALTY_PROC 5 |
||||||
|
#define GIST_PICKSPLIT_PROC 6 |
||||||
|
#define GIST_EQUAL_PROC 7 |
||||||
|
#define GIST_INFO_PROC 8 |
||||||
|
|
||||||
|
#define F_LEAF (1 << 0) |
||||||
|
|
||||||
|
typedef struct GISTPageOpaqueData { |
||||||
|
uint32 flags; |
||||||
|
} GISTPageOpaqueData; |
||||||
|
|
||||||
|
typedef GISTPageOpaqueData *GISTPageOpaque; |
||||||
|
|
||||||
|
#define GIST_LEAF(entry) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF) |
||||||
|
|
||||||
|
/*
|
||||||
|
* When we descend a tree, we keep a stack of parent pointers. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct GISTSTACK { |
||||||
|
struct GISTSTACK *gs_parent; |
||||||
|
OffsetNumber gs_child; |
||||||
|
BlockNumber gs_blk; |
||||||
|
} GISTSTACK; |
||||||
|
|
||||||
|
typedef struct GISTSTATE { |
||||||
|
func_ptr consistentFn; |
||||||
|
func_ptr unionFn; |
||||||
|
func_ptr compressFn; |
||||||
|
func_ptr decompressFn; |
||||||
|
func_ptr penaltyFn; |
||||||
|
func_ptr picksplitFn; |
||||||
|
func_ptr equalFn; |
||||||
|
bool haskeytype; |
||||||
|
bool keytypbyval; |
||||||
|
} GISTSTATE; |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** When we're doing a scan, we need to keep track of the parent stack |
||||||
|
** for the marked and current items.
|
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct GISTScanOpaqueData { |
||||||
|
struct GISTSTACK *s_stack; |
||||||
|
struct GISTSTACK *s_markstk; |
||||||
|
uint16 s_flags; |
||||||
|
struct GISTSTATE *giststate; |
||||||
|
} GISTScanOpaqueData; |
||||||
|
|
||||||
|
typedef GISTScanOpaqueData *GISTScanOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
** When we're doing a scan and updating a tree at the same time, the |
||||||
|
** updates may affect the scan. We use the flags entry of the scan's |
||||||
|
** opaque space to record our actual position in response to updates |
||||||
|
** that we can't handle simply by adjusting pointers. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define GS_CURBEFORE ((uint16) (1 << 0)) |
||||||
|
#define GS_MRKBEFORE ((uint16) (1 << 1)) |
||||||
|
|
||||||
|
/* root page of a gist */ |
||||||
|
#define GISTP_ROOT 0 |
||||||
|
|
||||||
|
/*
|
||||||
|
** When we update a relation on which we're doing a scan, we need to |
||||||
|
** check the scan and fix it if the update affected any of the pages it |
||||||
|
** touches. Otherwise, we can miss records that we should see. The only |
||||||
|
** times we need to do this are for deletions and splits. See the code in |
||||||
|
** gistscan.c for how the scan is fixed. These two constants tell us what sort |
||||||
|
** of operation changed the index. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define GISTOP_DEL 0 |
||||||
|
#define GISTOP_SPLIT 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
** This is the Split Vector to be returned by the PickSplit method. |
||||||
|
*/ |
||||||
|
typedef struct GIST_SPLITVEC { |
||||||
|
OffsetNumber *spl_left; /* array of entries that go left */ |
||||||
|
int spl_nleft; /* size of this array */ |
||||||
|
char *spl_ldatum; /* Union of keys in spl_left */ |
||||||
|
OffsetNumber *spl_right; /* array of entries that go right */ |
||||||
|
int spl_nright; /* size of the array */ |
||||||
|
char *spl_rdatum; /* Union of keys in spl_right */ |
||||||
|
} GIST_SPLITVEC; |
||||||
|
|
||||||
|
/*
|
||||||
|
** An entry on a GiST node. Contains the key (pred), as well as
|
||||||
|
** its own location (rel,page,offset) which can supply the matching |
||||||
|
** pointer. The size of the pred is in bytes, and leafkey is a flag to |
||||||
|
** tell us if the entry is in a leaf node. |
||||||
|
*/ |
||||||
|
typedef struct GISTENTRY { |
||||||
|
char *pred; |
||||||
|
Relation rel; |
||||||
|
Page page; |
||||||
|
OffsetNumber offset; |
||||||
|
int bytes; |
||||||
|
bool leafkey; |
||||||
|
} GISTENTRY; |
||||||
|
|
||||||
|
/*
|
||||||
|
** macro to initialize a GISTENTRY |
||||||
|
*/ |
||||||
|
#define gistentryinit(e, pr, r, pg, o, b, l)\ |
||||||
|
{(e).pred = pr; (e).rel = r; (e).page = pg; (e).offset = o; (e).bytes = b; (e).leafkey = l;} |
||||||
|
|
||||||
|
/* defined in gist.c */ |
||||||
|
extern void gistfreestack(GISTSTACK *s); |
||||||
|
extern void initGISTstate(GISTSTATE *giststate, Relation index); |
||||||
|
extern void gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
|
||||||
|
Relation r, Page pg, OffsetNumber o, int b, bool l) ; |
||||||
|
extern void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
|
||||||
|
Relation r, Page pg, OffsetNumber o, int b, bool l) ; |
||||||
|
#endif /* GIST_H */ |
@ -0,0 +1,16 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* gistscan.h-- |
||||||
|
* routines defined in access/gisr/gistscan.c |
||||||
|
* |
||||||
|
* |
||||||
|
* |
||||||
|
* rtscan.h,v 1.2 1995/06/14 00:06:58 jolly Exp |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef GISTSCAN_H |
||||||
|
|
||||||
|
void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); |
||||||
|
|
||||||
|
#endif /* GISTSCAN_H */ |
@ -0,0 +1,14 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* giststrat.h-- |
||||||
|
* routines defined in access/gist/giststrat.c |
||||||
|
* |
||||||
|
* |
||||||
|
* |
||||||
|
* rtstrat.h,v 1.2 1995/02/12 02:54:51 andrew Exp |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef GISTSTRAT_H |
||||||
|
|
||||||
|
#endif /* GISTSTRAT_H */ |
@ -0,0 +1,337 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* hash.h-- |
||||||
|
* header file for postgres hash access method implementation
|
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: hash.h,v 1.1 1996/08/27 21:50:12 scrappy Exp $ |
||||||
|
* |
||||||
|
* NOTES |
||||||
|
* modeled after Margo Seltzer's hash implementation for unix.
|
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef HASH_H |
||||||
|
#define HASH_H |
||||||
|
|
||||||
|
#include "access/itup.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* An overflow page is a spare page allocated for storing data whose
|
||||||
|
* 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 |
||||||
|
* in the bucket itself, put it in an overflow page.
|
||||||
|
* |
||||||
|
* 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 |
||||||
|
* at 1.
|
||||||
|
*
|
||||||
|
* We convert the stored bitmap address into a page address with the |
||||||
|
* macro OADDR_OF(S, O) where S is the splitnumber and O is the page
|
||||||
|
* offset.
|
||||||
|
*/ |
||||||
|
typedef uint32 Bucket; |
||||||
|
typedef bits16 OverflowPageAddress; |
||||||
|
typedef uint32 SplitNumber; |
||||||
|
typedef uint32 PageOffset; |
||||||
|
|
||||||
|
/* A valid overflow address will always have a page offset >= 1 */ |
||||||
|
#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))) |
||||||
|
|
||||||
|
#define BUCKET_TO_BLKNO(B) \ |
||||||
|
((Bucket) ((B) + ((B) ? metap->SPARES[_hash_log2((B)+1)-1] : 0)) + 1) |
||||||
|
#define OADDR_TO_BLKNO(B) \ |
||||||
|
((BlockNumber) \
|
||||||
|
(BUCKET_TO_BLKNO ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)))); |
||||||
|
|
||||||
|
/*
|
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#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) |
||||||
|
|
||||||
|
typedef struct HashPageOpaqueData { |
||||||
|
bits16 hasho_flag; /* is this page a bucket or ovfl */ |
||||||
|
Bucket hasho_bucket; /* bucket number this pg belongs to */ |
||||||
|
OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */ |
||||||
|
BlockNumber hasho_nextblkno; /* next ovfl blkno */ |
||||||
|
BlockNumber hasho_prevblkno; /* previous ovfl (or bucket) blkno */ |
||||||
|
} HashPageOpaqueData; |
||||||
|
|
||||||
|
typedef HashPageOpaqueData *HashPageOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct HashScanOpaqueData { |
||||||
|
Buffer hashso_curbuf; |
||||||
|
Buffer hashso_mrkbuf; |
||||||
|
} HashScanOpaqueData; |
||||||
|
|
||||||
|
typedef HashScanOpaqueData *HashScanOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Definitions for metapage. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define HASH_METAPAGE 0 /* metapage is always block 0 */ |
||||||
|
|
||||||
|
#define HASH_MAGIC 0x6440640 |
||||||
|
#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 |
||||||
|
* a splitpoint.
|
||||||
|
*
|
||||||
|
* 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 |
||||||
|
* ovflpages. Bitmaps[] contains the ovflpage addresses of the ovflpages
|
||||||
|
* that hold the ovflpage bitmaps.
|
||||||
|
* |
||||||
|
* The reason that the size is restricted to NCACHED (32) is because |
||||||
|
* the bitmaps are 16 bits: upper 5 represent the splitpoint, lower 11 |
||||||
|
* indicate the page number within the splitpoint. Since there are
|
||||||
|
* only 5 bits to store the splitpoint, there can only be 32 splitpoints.
|
||||||
|
* Both spares[] and bitmaps[] use splitpoints as there indices, so there |
||||||
|
* can only be 32 of them.
|
||||||
|
*/ |
||||||
|
|
||||||
|
#define NCACHED 32 |
||||||
|
|
||||||
|
|
||||||
|
typedef struct HashMetaPageData { |
||||||
|
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 of 2 */ |
||||||
|
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 */ |
||||||
|
} HashMetaPageData; |
||||||
|
|
||||||
|
typedef HashMetaPageData *HashMetaPage; |
||||||
|
|
||||||
|
/* Short hands for accessing structure */ |
||||||
|
#define BSHIFT hashm_bshift |
||||||
|
#define OVFL_POINT hashm_ovflpoint |
||||||
|
#define LAST_FREED hashm_lastfreed |
||||||
|
#define MAX_BUCKET hashm_maxbucket |
||||||
|
#define FFACTOR hashm_ffactor |
||||||
|
#define HIGH_MASK hashm_highmask |
||||||
|
#define LOW_MASK hashm_lowmask |
||||||
|
#define NKEYS hashm_nkeys |
||||||
|
#define SPARES hashm_spares |
||||||
|
|
||||||
|
extern bool BuildingHash; |
||||||
|
|
||||||
|
typedef struct HashItemData { |
||||||
|
IndexTupleData hash_itup; |
||||||
|
} HashItemData; |
||||||
|
|
||||||
|
typedef HashItemData *HashItem; |
||||||
|
|
||||||
|
/*
|
||||||
|
* Constants |
||||||
|
*/ |
||||||
|
#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) |
||||||
|
|
||||||
|
/*
|
||||||
|
* bitmap pages do not contain tuples. they do contain the standard |
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
#define BMPGSZ_BYTE(metap) ((metap)->hashm_bmsize) |
||||||
|
#define BMPGSZ_BIT(metap) ((metap)->hashm_bmsize << BYTE_TO_BIT) |
||||||
|
#define HashPageGetBitmap(pg) \ |
||||||
|
((uint32 *) (((char *) (pg)) + DOUBLEALIGN(sizeof(PageHeaderData)))) |
||||||
|
|
||||||
|
/*
|
||||||
|
* The number of bits in an ovflpage bitmap which |
||||||
|
* tells which ovflpages are empty versus in use (NOT the number of |
||||||
|
* bits in an overflow page *address* bitmap).
|
||||||
|
*/ |
||||||
|
#define BITS_PER_MAP 32 /* Number of bits in ovflpage bitmap */ |
||||||
|
|
||||||
|
/* 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))) |
||||||
|
#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) |
||||||
|
|
||||||
|
/*
|
||||||
|
* page locking modes |
||||||
|
*/ |
||||||
|
#define HASH_READ 0 |
||||||
|
#define HASH_WRITE 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define P_NONE 0 |
||||||
|
|
||||||
|
/*
|
||||||
|
* Strategy number. There's only one valid strategy for hashing: equality. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define HTEqualStrategyNumber 1 |
||||||
|
#define HTMaxStrategyNumber 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define HASHPROC 1 |
||||||
|
|
||||||
|
/* public routines */ |
||||||
|
|
||||||
|
extern void hashbuild(Relation heap, Relation index, int natts, |
||||||
|
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount, |
||||||
|
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo); |
||||||
|
extern InsertIndexResult hashinsert(Relation rel, Datum *datum, char *nulls, |
||||||
|
ItemPointer ht_ctid); |
||||||
|
extern char *hashgettuple(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern char *hashbeginscan(Relation rel, bool fromEnd, uint16 keysz, |
||||||
|
ScanKey scankey); |
||||||
|
extern void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); |
||||||
|
extern void hashendscan(IndexScanDesc scan); |
||||||
|
extern void hashmarkpos(IndexScanDesc scan); |
||||||
|
extern void hashrestrpos(IndexScanDesc scan); |
||||||
|
extern void hashdelete(Relation rel, ItemPointer tid); |
||||||
|
|
||||||
|
/* hashfunc.c */ |
||||||
|
extern uint32 hashint2(int16 key); |
||||||
|
extern uint32 hashint4(uint32 key); |
||||||
|
extern uint32 hashfloat4(float32 keyp); |
||||||
|
extern uint32 hashfloat8(float64 keyp); |
||||||
|
extern uint32 hashoid(Oid key); |
||||||
|
extern uint32 hashchar(char key); |
||||||
|
extern uint32 hashchar2(uint16 intkey); |
||||||
|
extern uint32 hashchar4(uint32 intkey); |
||||||
|
extern uint32 hashchar8(char *key); |
||||||
|
extern uint32 hashchar16(char *key); |
||||||
|
extern uint32 hashtext(struct varlena *key); |
||||||
|
|
||||||
|
/* private routines */ |
||||||
|
|
||||||
|
/* hashinsert.c */ |
||||||
|
extern InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem); |
||||||
|
|
||||||
|
|
||||||
|
/* hashovfl.c */ |
||||||
|
extern Buffer _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf); |
||||||
|
extern Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf); |
||||||
|
extern int32 _hash_initbitmap(Relation rel, HashMetaPage metap, int32 pnum, |
||||||
|
int32 nbits, int32 ndx); |
||||||
|
extern void _hash_squeezebucket(Relation rel, HashMetaPage metap, |
||||||
|
Bucket bucket); |
||||||
|
|
||||||
|
|
||||||
|
/* hashpage.c */ |
||||||
|
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); |
||||||
|
extern Page _hash_chgbufaccess(Relation rel, Buffer *bufp, int from_access, |
||||||
|
int to_access); |
||||||
|
extern void _hash_pageinit(Page page, Size size); |
||||||
|
extern void _hash_pagedel(Relation rel, ItemPointer tid); |
||||||
|
extern void _hash_expandtable(Relation rel, Buffer metabuf); |
||||||
|
|
||||||
|
|
||||||
|
/* hashscan.c */ |
||||||
|
extern void _hash_regscan(IndexScanDesc scan); |
||||||
|
extern void _hash_dropscan(IndexScanDesc scan); |
||||||
|
extern void _hash_adjscans(Relation rel, ItemPointer tid); |
||||||
|
|
||||||
|
|
||||||
|
/* hashsearch.c */ |
||||||
|
extern void _hash_search(Relation rel, int keysz, ScanKey scankey, |
||||||
|
Buffer *bufP, HashMetaPage metap); |
||||||
|
extern RetrieveIndexResult _hash_next(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern RetrieveIndexResult _hash_first(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern bool _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir, |
||||||
|
Buffer metabuf); |
||||||
|
|
||||||
|
|
||||||
|
/* hashstrat.c */ |
||||||
|
extern StrategyNumber _hash_getstrat(Relation rel, AttrNumber attno, |
||||||
|
RegProcedure proc); |
||||||
|
extern bool _hash_invokestrat(Relation rel, AttrNumber attno, |
||||||
|
StrategyNumber strat, Datum left, Datum right); |
||||||
|
|
||||||
|
|
||||||
|
/* hashutil.c */ |
||||||
|
extern ScanKey _hash_mkscankey(Relation rel, IndexTuple itup, |
||||||
|
HashMetaPage metap); |
||||||
|
extern void _hash_freeskey(ScanKey skey); |
||||||
|
extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup); |
||||||
|
extern HashItem _hash_formitem(IndexTuple itup); |
||||||
|
extern Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key); |
||||||
|
extern uint32 _hash_log2(uint32 num); |
||||||
|
extern void _hash_checkpage(Page page, int flags); |
||||||
|
|
||||||
|
#endif /* HASH_H */ |
@ -0,0 +1,149 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* heapam.h-- |
||||||
|
* POSTGRES heap access method definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: heapam.h,v 1.1 1996/08/27 21:50:13 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef HEAPAM_H |
||||||
|
#define HEAPAM_H |
||||||
|
|
||||||
|
#include <sys/types.h> |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
|
||||||
|
#include "access/attnum.h" |
||||||
|
#include "access/htup.h" |
||||||
|
#include "access/relscan.h" |
||||||
|
#include "access/skey.h" |
||||||
|
#include "utils/tqual.h" |
||||||
|
#include "access/tupdesc.h" |
||||||
|
#include "storage/smgr.h" |
||||||
|
#include "utils/rel.h" |
||||||
|
|
||||||
|
/* ----------------------------------------------------------------
|
||||||
|
* heap access method statistics |
||||||
|
* ---------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct HeapAccessStatisticsData { |
||||||
|
time_t init_global_timestamp; /* time global statistics started */ |
||||||
|
time_t local_reset_timestamp; /* last time local reset was done */ |
||||||
|
time_t last_request_timestamp; /* last time stats were requested */ |
||||||
|
|
||||||
|
int global_open;
|
||||||
|
int global_openr; |
||||||
|
int global_close; |
||||||
|
int global_beginscan; |
||||||
|
int global_rescan; |
||||||
|
int global_endscan; |
||||||
|
int global_getnext; |
||||||
|
int global_fetch; |
||||||
|
int global_insert; |
||||||
|
int global_delete; |
||||||
|
int global_replace;
|
||||||
|
int global_markpos;
|
||||||
|
int global_restrpos; |
||||||
|
int global_BufferGetRelation; |
||||||
|
int global_RelationIdGetRelation; |
||||||
|
int global_RelationIdGetRelation_Buf; |
||||||
|
int global_RelationNameGetRelation; |
||||||
|
int global_getreldesc; |
||||||
|
int global_heapgettup; |
||||||
|
int global_RelationPutHeapTuple; |
||||||
|
int global_RelationPutLongHeapTuple; |
||||||
|
|
||||||
|
int local_open;
|
||||||
|
int local_openr; |
||||||
|
int local_close; |
||||||
|
int local_beginscan; |
||||||
|
int local_rescan; |
||||||
|
int local_endscan; |
||||||
|
int local_getnext; |
||||||
|
int local_fetch; |
||||||
|
int local_insert; |
||||||
|
int local_delete; |
||||||
|
int local_replace;
|
||||||
|
int local_markpos;
|
||||||
|
int local_restrpos; |
||||||
|
int local_BufferGetRelation; |
||||||
|
int local_RelationIdGetRelation; |
||||||
|
int local_RelationIdGetRelation_Buf; |
||||||
|
int local_RelationNameGetRelation; |
||||||
|
int local_getreldesc; |
||||||
|
int local_heapgettup; |
||||||
|
int local_RelationPutHeapTuple; |
||||||
|
int local_RelationPutLongHeapTuple; |
||||||
|
} HeapAccessStatisticsData; |
||||||
|
|
||||||
|
typedef HeapAccessStatisticsData *HeapAccessStatistics; |
||||||
|
|
||||||
|
#define IncrHeapAccessStat(x) \ |
||||||
|
(heap_access_stats == NULL ? 0 : (heap_access_stats->x)++) |
||||||
|
|
||||||
|
extern HeapAccessStatistics heap_access_stats; /* in stats.c */ |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* function prototypes for heap access method |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
/* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */ |
||||||
|
#include "catalog/heap.h" |
||||||
|
|
||||||
|
/* heapam.c */ |
||||||
|
extern void doinsert(Relation relation, HeapTuple tup); |
||||||
|
extern void SetHeapAccessMethodImmediateInvalidation(bool on); |
||||||
|
|
||||||
|
extern Relation heap_open(Oid relationId); |
||||||
|
extern Relation heap_openr(char *relationName); |
||||||
|
extern void heap_close(Relation relation); |
||||||
|
extern HeapScanDesc heap_beginscan(Relation relation, int atend, |
||||||
|
TimeQual timeQual, unsigned nkeys, ScanKey key); |
||||||
|
extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key); |
||||||
|
extern void heap_endscan(HeapScanDesc sdesc); |
||||||
|
extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer *b); |
||||||
|
extern HeapTuple heap_fetch(Relation relation, TimeQual timeQual, |
||||||
|
ItemPointer tid, Buffer *b); |
||||||
|
extern Oid heap_insert(Relation relation, HeapTuple tup); |
||||||
|
extern void heap_delete(Relation relation, ItemPointer tid); |
||||||
|
extern int heap_replace(Relation relation, ItemPointer otid, |
||||||
|
HeapTuple tup); |
||||||
|
extern void heap_markpos(HeapScanDesc sdesc); |
||||||
|
extern void heap_restrpos(HeapScanDesc sdesc); |
||||||
|
|
||||||
|
/* in common/heaptuple.c */ |
||||||
|
extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]); |
||||||
|
extern void DataFill(char *data, TupleDesc tupleDesc, |
||||||
|
Datum value[], char nulls[], char *infomask, |
||||||
|
bits8 *bit); |
||||||
|
extern int heap_attisnull(HeapTuple tup, int attnum); |
||||||
|
extern int heap_sysattrlen(AttrNumber attno); |
||||||
|
extern bool heap_sysattrbyval(AttrNumber attno); |
||||||
|
extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum); |
||||||
|
extern char *fastgetattr(HeapTuple tup, unsigned attnum, |
||||||
|
TupleDesc att, bool *isnull); |
||||||
|
extern char *heap_getattr(HeapTuple tup, Buffer b, int attnum, |
||||||
|
TupleDesc att, bool *isnull); |
||||||
|
extern HeapTuple heap_copytuple(HeapTuple tuple); |
||||||
|
extern void heap_deformtuple(HeapTuple tuple, TupleDesc tdesc, |
||||||
|
Datum values[], char nulls[]); |
||||||
|
extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
|
||||||
|
Datum value[], char nulls[]); |
||||||
|
extern HeapTuple heap_modifytuple(HeapTuple tuple, Buffer buffer, |
||||||
|
Relation relation, Datum replValue[], char replNull[], char repl[]); |
||||||
|
HeapTuple heap_addheader(uint32 natts, int structlen, char *structure); |
||||||
|
|
||||||
|
/* in common/heap/stats.c */ |
||||||
|
extern void InitHeapAccessStatistics(void); |
||||||
|
extern void ResetHeapAccessStatistics(void); |
||||||
|
extern HeapAccessStatistics GetHeapAccessStatistics(void); |
||||||
|
extern void PrintHeapAccessStatistics(HeapAccessStatistics stats); |
||||||
|
extern void PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats); |
||||||
|
extern void initam(void); |
||||||
|
|
||||||
|
#endif /* HEAPAM_H */ |
@ -0,0 +1,26 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* hio.h-- |
||||||
|
* POSTGRES heap access method input/output definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: hio.h,v 1.1 1996/08/27 21:50:14 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef HIO_H |
||||||
|
#define HIO_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
|
||||||
|
#include "storage/block.h" |
||||||
|
#include "access/htup.h" |
||||||
|
#include "utils/rel.h" |
||||||
|
|
||||||
|
extern void RelationPutHeapTuple(Relation relation, BlockNumber blockIndex, |
||||||
|
HeapTuple tuple); |
||||||
|
extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); |
||||||
|
|
||||||
|
#endif /* HIO_H */ |
@ -0,0 +1,115 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* htup.h-- |
||||||
|
* POSTGRES heap tuple definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: htup.h,v 1.1 1996/08/27 21:50:14 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef HTUP_H |
||||||
|
#define HTUP_H |
||||||
|
|
||||||
|
#include "access/attnum.h" |
||||||
|
#include "storage/bufpage.h" /* just to reduce levels of #include */ |
||||||
|
#include "storage/itemptr.h" |
||||||
|
#include "utils/nabstime.h" |
||||||
|
|
||||||
|
#define MinHeapTupleBitmapSize 32 /* 8 * 4 */ |
||||||
|
|
||||||
|
/* check these, they are likely to be more severely limited by t_hoff */ |
||||||
|
|
||||||
|
#define MaxHeapAttributeNumber 1600 /* 8 * 200 */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* to avoid wasting space, the attributes should be layed out in such a |
||||||
|
* way to reduce structure padding. |
||||||
|
*/ |
||||||
|
typedef struct HeapTupleData { |
||||||
|
|
||||||
|
unsigned int t_len; /* length of entire tuple */ |
||||||
|
|
||||||
|
ItemPointerData t_ctid; /* current TID of this tuple */ |
||||||
|
|
||||||
|
ItemPointerData t_chain; /* replaced tuple TID */ |
||||||
|
|
||||||
|
Oid t_oid; /* OID of this tuple -- 4 bytes */ |
||||||
|
|
||||||
|
CommandId t_cmin; /* insert CID stamp -- 2 bytes each */ |
||||||
|
CommandId t_cmax; /* delete CommandId stamp */ |
||||||
|
|
||||||
|
TransactionId t_xmin; /* insert XID stamp -- 4 bytes each */ |
||||||
|
TransactionId t_xmax; /* delete XID stamp */ |
||||||
|
|
||||||
|
AbsoluteTime t_tmin; /* time stamps -- 4 bytes each */ |
||||||
|
AbsoluteTime t_tmax;
|
||||||
|
|
||||||
|
int16 t_natts; /* number of attributes */ |
||||||
|
char t_vtype; /* not used - padding */ |
||||||
|
|
||||||
|
char t_infomask; /* whether tuple as null or variable
|
||||||
|
* length attributes |
||||||
|
*/ |
||||||
|
|
||||||
|
uint8 t_hoff; /* sizeof tuple header */ |
||||||
|
|
||||||
|
bits8 t_bits[MinHeapTupleBitmapSize / 8]; |
||||||
|
/* bit map of domains */ |
||||||
|
|
||||||
|
/* MORE DATA FOLLOWS AT END OF STRUCT */ |
||||||
|
} HeapTupleData;
|
||||||
|
|
||||||
|
typedef HeapTupleData *HeapTuple; |
||||||
|
|
||||||
|
|
||||||
|
#define SelfItemPointerAttributeNumber (-1) |
||||||
|
#define ObjectIdAttributeNumber (-2) |
||||||
|
#define MinTransactionIdAttributeNumber (-3) |
||||||
|
#define MinCommandIdAttributeNumber (-4) |
||||||
|
#define MaxTransactionIdAttributeNumber (-5) |
||||||
|
#define MaxCommandIdAttributeNumber (-6) |
||||||
|
#define ChainItemPointerAttributeNumber (-7) |
||||||
|
#define AnchorItemPointerAttributeNumber (-8) |
||||||
|
#define MinAbsoluteTimeAttributeNumber (-9) |
||||||
|
#define MaxAbsoluteTimeAttributeNumber (-10) |
||||||
|
#define VersionTypeAttributeNumber (-11) |
||||||
|
#define FirstLowInvalidHeapAttributeNumber (-12) |
||||||
|
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* support macros |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define GETSTRUCT(TUP) (((char *)(TUP)) + ((HeapTuple)(TUP))->t_hoff) |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BITMAPLEN(NATTS) -
|
||||||
|
* Computes minimum size of bitmap given number of domains. |
||||||
|
*/ |
||||||
|
#define BITMAPLEN(NATTS) \ |
||||||
|
((((((int)(NATTS) - 1) >> 3) + 4 - (MinHeapTupleBitmapSize >> 3)) \
|
||||||
|
& ~03) + (MinHeapTupleBitmapSize >> 3)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* HeapTupleIsValid |
||||||
|
* True iff the heap tuple is valid. |
||||||
|
*/ |
||||||
|
#define HeapTupleIsValid(tuple) PointerIsValid(tuple) |
||||||
|
|
||||||
|
/*
|
||||||
|
* information stored in t_infomask: |
||||||
|
*/ |
||||||
|
#define HEAP_HASNULL 0x01 /* has null attribute(s) */ |
||||||
|
#define HEAP_HASVARLENA 0x02 /* has variable length attribute(s) */ |
||||||
|
|
||||||
|
#define HeapTupleNoNulls(tuple) \ |
||||||
|
(!(((HeapTuple) (tuple))->t_infomask & HEAP_HASNULL)) |
||||||
|
|
||||||
|
#define HeapTupleAllFixed(tuple) \ |
||||||
|
(!(((HeapTuple) (tuple))->t_infomask & HEAP_HASVARLENA)) |
||||||
|
|
||||||
|
#endif /* HTUP_H */ |
@ -0,0 +1,34 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* ibit.h-- |
||||||
|
* POSTGRES index valid attribute bit map definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: ibit.h,v 1.1 1996/08/27 21:50:15 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef IBIT_H |
||||||
|
#define IBIT_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
#include "utils/memutils.h" |
||||||
|
|
||||||
|
typedef struct IndexAttributeBitMapData { |
||||||
|
char bits[(MaxIndexAttributeNumber + MaxBitsPerByte - 1) |
||||||
|
/ MaxBitsPerByte]; |
||||||
|
} IndexAttributeBitMapData; |
||||||
|
|
||||||
|
typedef IndexAttributeBitMapData *IndexAttributeBitMap; |
||||||
|
|
||||||
|
#define IndexAttributeBitMapSize sizeof(IndexAttributeBitMapData) |
||||||
|
|
||||||
|
/*
|
||||||
|
* IndexAttributeBitMapIsValid -- |
||||||
|
* True iff attribute bit map is valid. |
||||||
|
*/ |
||||||
|
#define IndexAttributeBitMapIsValid(bits) PointerIsValid(bits) |
||||||
|
|
||||||
|
#endif /* IBIT_H */ |
@ -0,0 +1,32 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* iqual.h-- |
||||||
|
* Index scan key qualification definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: iqual.h,v 1.1 1996/08/27 21:50:16 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef IQUAL_H |
||||||
|
#define IQUAL_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
|
||||||
|
#include "storage/itemid.h" |
||||||
|
#include "utils/rel.h" |
||||||
|
#include "access/skey.h" |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* index tuple qualification support |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
extern int NIndexTupleProcessed; |
||||||
|
|
||||||
|
extern bool index_keytest(IndexTuple tuple, TupleDesc tupdesc, |
||||||
|
int scanKeySize, ScanKey key); |
||||||
|
|
||||||
|
#endif /* IQUAL_H */ |
@ -0,0 +1,80 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* istrat.h-- |
||||||
|
* POSTGRES index strategy definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: istrat.h,v 1.1 1996/08/27 21:50:17 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef ISTRAT_H |
||||||
|
#define ISTRAT_H |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
#include "access/attnum.h" |
||||||
|
#include "access/skey.h" |
||||||
|
#include "access/strat.h" |
||||||
|
#include "utils/rel.h" /* for Relation */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* StrategyNumberIsValid -- |
||||||
|
* True iff the strategy number is valid. |
||||||
|
*/ |
||||||
|
#define StrategyNumberIsValid(strategyNumber) \ |
||||||
|
((bool) ((strategyNumber) != InvalidStrategy)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* StrategyNumberIsInBounds -- |
||||||
|
* True iff strategy number is within given bounds. |
||||||
|
* |
||||||
|
* Note: |
||||||
|
* Assumes StrategyNumber is an unsigned type. |
||||||
|
* Assumes the bounded interval to be (0,max]. |
||||||
|
*/ |
||||||
|
#define StrategyNumberIsInBounds(strategyNumber, maxStrategyNumber) \ |
||||||
|
((bool)(InvalidStrategy < (strategyNumber) && \
|
||||||
|
(strategyNumber) <= (maxStrategyNumber))) |
||||||
|
|
||||||
|
/*
|
||||||
|
* StrategyMapIsValid -- |
||||||
|
* True iff the index strategy mapping is valid. |
||||||
|
*/ |
||||||
|
#define StrategyMapIsValid(map) PointerIsValid(map) |
||||||
|
|
||||||
|
/*
|
||||||
|
* IndexStrategyIsValid -- |
||||||
|
* True iff the index strategy is valid. |
||||||
|
*/ |
||||||
|
#define IndexStrategyIsValid(s) PointerIsValid(s) |
||||||
|
|
||||||
|
extern ScanKey StrategyMapGetScanKeyEntry(StrategyMap map, |
||||||
|
StrategyNumber strategyNumber); |
||||||
|
extern StrategyMap IndexStrategyGetStrategyMap(IndexStrategy indexStrategy, |
||||||
|
StrategyNumber maxStrategyNum, AttrNumber attrNum); |
||||||
|
|
||||||
|
extern Size |
||||||
|
AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber, |
||||||
|
StrategyNumber maxStrategyNumber); |
||||||
|
extern bool StrategyOperatorIsValid(StrategyOperator operator, |
||||||
|
StrategyNumber maxStrategy); |
||||||
|
extern bool StrategyTermIsValid(StrategyTerm term, |
||||||
|
StrategyNumber maxStrategy); |
||||||
|
extern bool StrategyExpressionIsValid(StrategyExpression expression, |
||||||
|
StrategyNumber maxStrategy); |
||||||
|
extern bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); |
||||||
|
extern StrategyNumber RelationGetStrategy(Relation relation, |
||||||
|
AttrNumber attributeNumber, StrategyEvaluation evaluation, |
||||||
|
RegProcedure procedure); |
||||||
|
extern bool RelationInvokeStrategy(Relation relation, |
||||||
|
StrategyEvaluation evaluation, AttrNumber attributeNumber, |
||||||
|
StrategyNumber strategy, Datum left, Datum right); |
||||||
|
extern void IndexSupportInitialize(IndexStrategy indexStrategy, |
||||||
|
RegProcedure *indexSupport, Oid indexObjectId, |
||||||
|
Oid accessMethodObjectId, StrategyNumber maxStrategyNumber, |
||||||
|
StrategyNumber maxSupportNumber, AttrNumber maxAttributeNumber); |
||||||
|
|
||||||
|
|
||||||
|
#endif /* ISTRAT_H */ |
@ -0,0 +1,104 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* itup.h-- |
||||||
|
* POSTGRES index tuple definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: itup.h,v 1.1 1996/08/27 21:50:18 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef ITUP_H |
||||||
|
#define ITUP_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
#include "access/ibit.h" |
||||||
|
#include "access/tupdesc.h" /* for TupleDesc */ |
||||||
|
#include "storage/itemptr.h" |
||||||
|
|
||||||
|
#define MaxIndexAttributeNumber 7 |
||||||
|
|
||||||
|
typedef struct IndexTupleData { |
||||||
|
ItemPointerData t_tid; /* reference TID to base tuple */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* t_info is layed out in the following fashion: |
||||||
|
* |
||||||
|
* 15th (leftmost) bit: "has nulls" bit |
||||||
|
* 14th bit: "has varlenas" bit |
||||||
|
* 13th bit: "has rules" bit - (removed ay 11/94) |
||||||
|
* bits 12-0 bit: size of tuple. |
||||||
|
*/ |
||||||
|
|
||||||
|
unsigned short t_info; /* various info about tuple */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* please make sure sizeof(IndexTupleData) is MAXALIGN'ed. |
||||||
|
* See IndexInfoFindDataOffset() for the reason. |
||||||
|
*/ |
||||||
|
|
||||||
|
} IndexTupleData; /* MORE DATA FOLLOWS AT END OF STRUCT */ |
||||||
|
|
||||||
|
typedef IndexTupleData *IndexTuple; |
||||||
|
|
||||||
|
|
||||||
|
typedef struct InsertIndexResultData { |
||||||
|
ItemPointerData pointerData; |
||||||
|
} InsertIndexResultData; |
||||||
|
|
||||||
|
typedef InsertIndexResultData *InsertIndexResult; |
||||||
|
|
||||||
|
|
||||||
|
typedef struct RetrieveIndexResultData { |
||||||
|
ItemPointerData index_iptr; |
||||||
|
ItemPointerData heap_iptr; |
||||||
|
} RetrieveIndexResultData; |
||||||
|
|
||||||
|
typedef RetrieveIndexResultData *RetrieveIndexResult; |
||||||
|
|
||||||
|
|
||||||
|
/*-----------------
|
||||||
|
* PredInfo - |
||||||
|
* used for partial indices |
||||||
|
*----------------- |
||||||
|
*/ |
||||||
|
typedef struct PredInfo { |
||||||
|
Node *pred; |
||||||
|
Node *oldPred; |
||||||
|
} PredInfo; |
||||||
|
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* externs
|
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
#define INDEX_SIZE_MASK 0x1FFF |
||||||
|
#define INDEX_NULL_MASK 0x8000 |
||||||
|
#define INDEX_VAR_MASK 0x4000 |
||||||
|
|
||||||
|
#define IndexTupleSize(itup) (((IndexTuple) (itup))->t_info & 0x1FFF) |
||||||
|
#define IndexTupleDSize(itup) ((itup).t_info & 0x1FFF) |
||||||
|
#define IndexTupleNoNulls(itup) (!(((IndexTuple) (itup))->t_info & 0x8000)) |
||||||
|
#define IndexTupleAllFixed(itup) (!(((IndexTuple) (itup))->t_info & 0x4000)) |
||||||
|
|
||||||
|
#define IndexTupleHasMinHeader(itup) (IndexTupleNoNulls(itup)) |
||||||
|
|
||||||
|
|
||||||
|
/* indextuple.h */ |
||||||
|
extern IndexTuple index_formtuple(TupleDesc tupleDescriptor, |
||||||
|
Datum value[], char null[]); |
||||||
|
extern char *fastgetiattr(IndexTuple tup, int attnum, |
||||||
|
TupleDesc att, bool *isnull); |
||||||
|
extern Datum index_getattr(IndexTuple tuple, AttrNumber attNum, |
||||||
|
TupleDesc tupDesc, bool *isNullOutP); |
||||||
|
extern RetrieveIndexResult |
||||||
|
FormRetrieveIndexResult(ItemPointer indexItemPointer, |
||||||
|
ItemPointer heapItemPointer); |
||||||
|
extern void CopyIndexTuple(IndexTuple source, IndexTuple *target); |
||||||
|
|
||||||
|
|
||||||
|
#endif /* ITUP_H */ |
||||||
|
|
@ -0,0 +1,271 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* nbtree.h-- |
||||||
|
* header file for postgres btree access method implementation. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: nbtree.h,v 1.1 1996/08/27 21:50:19 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef NBTREE_H |
||||||
|
#define NBTREE_H |
||||||
|
|
||||||
|
#include "access/attnum.h" |
||||||
|
#include "access/itup.h" |
||||||
|
#include "access/htup.h" |
||||||
|
#include "access/tupdesc.h" |
||||||
|
|
||||||
|
#include "access/istrat.h" |
||||||
|
#include "access/funcindex.h" |
||||||
|
#include "access/relscan.h" |
||||||
|
#include "access/sdir.h" |
||||||
|
#include "nodes/pg_list.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* BTPageOpaqueData -- At the end of every page, we store a pointer |
||||||
|
* to both siblings in the tree. See Lehman and Yao's paper for more |
||||||
|
* info. In addition, we need to know what sort of page this is |
||||||
|
* (leaf or internal), and whether the page is available for reuse. |
||||||
|
* |
||||||
|
* Lehman and Yao's algorithm requires a ``high key'' on every page. |
||||||
|
* The high key on a page is guaranteed to be greater than or equal |
||||||
|
* to any key that appears on this page. Our insertion algorithm |
||||||
|
* guarantees that we can use the initial least key on our right |
||||||
|
* sibling as the high key. We allocate space for the line pointer |
||||||
|
* to the high key in the opaque data at the end of the page. |
||||||
|
* |
||||||
|
* Rightmost pages in the tree have no high key. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct BTPageOpaqueData { |
||||||
|
BlockNumber btpo_prev; |
||||||
|
BlockNumber btpo_next; |
||||||
|
uint16 btpo_flags; |
||||||
|
|
||||||
|
#define BTP_LEAF (1 << 0) |
||||||
|
#define BTP_ROOT (1 << 1) |
||||||
|
#define BTP_FREE (1 << 2) |
||||||
|
#define BTP_META (1 << 3) |
||||||
|
|
||||||
|
} BTPageOpaqueData; |
||||||
|
|
||||||
|
typedef BTPageOpaqueData *BTPageOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* 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. |
||||||
|
* |
||||||
|
* And it's used to remember actual scankey info (we need in it |
||||||
|
* if some scankeys evaled at runtime. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct BTScanOpaqueData { |
||||||
|
Buffer btso_curbuf; |
||||||
|
Buffer btso_mrkbuf; |
||||||
|
uint16 qual_ok; /* 0 for quals like key == 1 && key > 2 */ |
||||||
|
uint16 numberOfKeys; /* number of key attributes */ |
||||||
|
ScanKey keyData; /* key descriptor */ |
||||||
|
} BTScanOpaqueData; |
||||||
|
|
||||||
|
typedef BTScanOpaqueData *BTScanOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* BTItems are what we store in the btree. Each item has an index |
||||||
|
* tuple, including key and pointer values. In addition, we must |
||||||
|
* guarantee that all tuples in the index are unique, in order to |
||||||
|
* satisfy some assumptions in Lehman and Yao. The way that we do |
||||||
|
* this is by generating a new OID for every insertion that we do in |
||||||
|
* the tree. This adds eight bytes to the size of btree index |
||||||
|
* tuples. Note that we do not use the OID as part of a composite |
||||||
|
* key; the OID only serves as a unique identifier for a given index |
||||||
|
* tuple (logical position within a page). |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct BTItemData { |
||||||
|
Oid bti_oid; |
||||||
|
int32 bti_dummy; /* padding to make bti_itup
|
||||||
|
* align at 8-byte boundary |
||||||
|
*/ |
||||||
|
IndexTupleData bti_itup; |
||||||
|
} BTItemData; |
||||||
|
|
||||||
|
typedef BTItemData *BTItem; |
||||||
|
|
||||||
|
/*
|
||||||
|
* BTStackData -- As we descend a tree, we push the (key, pointer) |
||||||
|
* pairs from internal nodes onto a private stack. If we split a |
||||||
|
* leaf, we use this stack to walk back up the tree and insert data |
||||||
|
* into parent nodes (and possibly to split them, too). Lehman and |
||||||
|
* Yao's update algorithm guarantees that under no circumstances can |
||||||
|
* our private stack give us an irredeemably bad picture up the tree. |
||||||
|
* Again, see the paper for details. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct BTStackData { |
||||||
|
BlockNumber bts_blkno; |
||||||
|
OffsetNumber bts_offset; |
||||||
|
BTItem bts_btitem; |
||||||
|
struct BTStackData *bts_parent; |
||||||
|
} BTStackData; |
||||||
|
|
||||||
|
typedef BTStackData *BTStack; |
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to be able to tell the difference between read and write |
||||||
|
* requests for pages, in order to do locking correctly. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define BT_READ 0 |
||||||
|
#define BT_WRITE 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
* Similarly, the difference between insertion and non-insertion binary |
||||||
|
* searches on a given page makes a difference when we're descending the |
||||||
|
* tree. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define BT_INSERTION 0 |
||||||
|
#define BT_DESCENT 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
* In general, the btree 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define P_NONE 0 |
||||||
|
#define P_LEFTMOST(opaque) ((opaque)->btpo_prev == P_NONE) |
||||||
|
#define P_RIGHTMOST(opaque) ((opaque)->btpo_next == P_NONE) |
||||||
|
|
||||||
|
#define P_HIKEY ((OffsetNumber) 1) |
||||||
|
#define P_FIRSTKEY ((OffsetNumber) 2) |
||||||
|
|
||||||
|
/*
|
||||||
|
* Strategy numbers -- ordering of these is <, <=, =, >=, >
|
||||||
|
*/ |
||||||
|
|
||||||
|
#define BTLessStrategyNumber 1 |
||||||
|
#define BTLessEqualStrategyNumber 2 |
||||||
|
#define BTEqualStrategyNumber 3 |
||||||
|
#define BTGreaterEqualStrategyNumber 4 |
||||||
|
#define BTGreaterStrategyNumber 5 |
||||||
|
#define BTMaxStrategyNumber 5 |
||||||
|
|
||||||
|
/*
|
||||||
|
* When a new operator class is declared, we require that the user |
||||||
|
* supply us with an amproc procedure for determining whether, for |
||||||
|
* two keys a and b, a < b, a = b, or a > b. This routine must |
||||||
|
* return < 0, 0, > 0, respectively, in these three cases. Since we |
||||||
|
* only have one such proc in amproc, it's number 1. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define BTORDER_PROC 1 |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtinsert.c |
||||||
|
*/ |
||||||
|
extern InsertIndexResult _bt_doinsert(Relation rel, BTItem btitem); |
||||||
|
extern bool _bt_itemcmp(Relation rel, Size keysz, BTItem item1, BTItem item2, |
||||||
|
StrategyNumber strat); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtpage.c |
||||||
|
*/ |
||||||
|
extern void _bt_metapinit(Relation rel); |
||||||
|
extern void _bt_checkmeta(Relation rel); |
||||||
|
extern Buffer _bt_getroot(Relation rel, int access); |
||||||
|
extern Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access); |
||||||
|
extern void _bt_relbuf(Relation rel, Buffer buf, int access); |
||||||
|
extern void _bt_wrtbuf(Relation rel, Buffer buf); |
||||||
|
extern void _bt_wrtnorelbuf(Relation rel, Buffer buf); |
||||||
|
extern void _bt_pageinit(Page page, Size size); |
||||||
|
extern void _bt_metaproot(Relation rel, BlockNumber rootbknum); |
||||||
|
extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access); |
||||||
|
extern void _bt_setpagelock(Relation rel, BlockNumber blkno, int access); |
||||||
|
extern void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); |
||||||
|
extern void _bt_pagedel(Relation rel, ItemPointer tid); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtree.c |
||||||
|
*/ |
||||||
|
extern bool BuildingBtree; /* in nbtree.c */ |
||||||
|
|
||||||
|
extern void btbuild(Relation heap, Relation index, int natts, |
||||||
|
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount, |
||||||
|
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo); |
||||||
|
extern InsertIndexResult btinsert(Relation rel, Datum *datum, char *nulls, |
||||||
|
ItemPointer ht_ctid); |
||||||
|
extern char *btgettuple(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern char *btbeginscan(Relation rel, bool fromEnd, uint16 keysz, |
||||||
|
ScanKey scankey); |
||||||
|
|
||||||
|
extern void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); |
||||||
|
extern void btmovescan(IndexScanDesc scan, Datum v); |
||||||
|
extern void btendscan(IndexScanDesc scan); |
||||||
|
extern void btmarkpos(IndexScanDesc scan); |
||||||
|
extern void btrestrpos(IndexScanDesc scan); |
||||||
|
extern void btdelete(Relation rel, ItemPointer tid); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtscan.c |
||||||
|
*/ |
||||||
|
extern void _bt_regscan(IndexScanDesc scan); |
||||||
|
extern void _bt_dropscan(IndexScanDesc scan); |
||||||
|
extern void _bt_adjscans(Relation rel, ItemPointer tid); |
||||||
|
extern void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, |
||||||
|
OffsetNumber offno); |
||||||
|
extern bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, |
||||||
|
OffsetNumber offno); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtsearch.c |
||||||
|
*/ |
||||||
|
extern BTStack _bt_search(Relation rel, int keysz, ScanKey scankey, |
||||||
|
Buffer *bufP); |
||||||
|
extern Buffer _bt_moveright(Relation rel, Buffer buf, int keysz, |
||||||
|
ScanKey scankey, int access); |
||||||
|
extern bool _bt_skeycmp(Relation rel, Size keysz, ScanKey scankey, |
||||||
|
Page page, ItemId itemid, StrategyNumber strat); |
||||||
|
extern OffsetNumber _bt_binsrch(Relation rel, Buffer buf, int keysz, |
||||||
|
ScanKey scankey, int srchtype); |
||||||
|
extern RetrieveIndexResult _bt_next(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern RetrieveIndexResult _bt_first(IndexScanDesc scan, ScanDirection dir); |
||||||
|
extern bool _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtstrat.c |
||||||
|
*/ |
||||||
|
extern StrategyNumber _bt_getstrat(Relation rel, AttrNumber attno, |
||||||
|
RegProcedure proc); |
||||||
|
extern bool _bt_invokestrat(Relation rel, AttrNumber attno, |
||||||
|
StrategyNumber strat, Datum left, Datum right); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtutils.c |
||||||
|
*/ |
||||||
|
extern ScanKey _bt_mkscankey(Relation rel, IndexTuple itup); |
||||||
|
extern void _bt_freeskey(ScanKey skey); |
||||||
|
extern void _bt_freestack(BTStack stack); |
||||||
|
extern void _bt_orderkeys(Relation relation, uint16 *numberOfKeys, |
||||||
|
ScanKey key, uint16 *qual_ok); |
||||||
|
extern bool _bt_checkqual(IndexScanDesc scan, IndexTuple itup); |
||||||
|
extern BTItem _bt_formitem(IndexTuple itup); |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in nbtsort.c |
||||||
|
*/ |
||||||
|
extern void *_bt_spoolinit(Relation index, int ntapes); |
||||||
|
extern void _bt_spooldestroy(void *spool); |
||||||
|
extern void _bt_spool(Relation index, BTItem btitem, void *spool); |
||||||
|
extern void _bt_upperbuild(Relation index, BlockNumber blk, int level); |
||||||
|
extern void _bt_leafbuild(Relation index, void *spool); |
||||||
|
|
||||||
|
#endif /* NBTREE_H */ |
@ -0,0 +1,26 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* printtup.h-- |
||||||
|
*
|
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: printtup.h,v 1.1 1996/08/27 21:50:19 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef PRINTTUP_H |
||||||
|
#define PRINTTUP_H |
||||||
|
|
||||||
|
#include "access/htup.h" |
||||||
|
#include "access/tupdesc.h" |
||||||
|
|
||||||
|
extern Oid typtoout(Oid type); |
||||||
|
extern void printtup(HeapTuple tuple, TupleDesc typeinfo); |
||||||
|
extern void showatts(char *name, TupleDesc attinfo); |
||||||
|
extern void debugtup(HeapTuple tuple, TupleDesc typeinfo); |
||||||
|
extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo); |
||||||
|
extern Oid gettypelem(Oid type); |
||||||
|
|
||||||
|
#endif /* PRINTTUP_H */ |
@ -0,0 +1,87 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* relscan.h-- |
||||||
|
* POSTGRES internal relation scan descriptor definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: relscan.h,v 1.1 1996/08/27 21:50:20 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef RELSCAN_H |
||||||
|
#define RELSCAN_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
|
||||||
|
#include "access/skey.h" |
||||||
|
#include "storage/buf.h" |
||||||
|
#include "access/htup.h" |
||||||
|
#include "storage/itemptr.h" |
||||||
|
|
||||||
|
#include "utils/tqual.h" |
||||||
|
#include "utils/rel.h" |
||||||
|
|
||||||
|
|
||||||
|
typedef ItemPointerData MarkData; |
||||||
|
|
||||||
|
typedef struct HeapScanDescData { |
||||||
|
Relation rs_rd; /* pointer to relation descriptor */ |
||||||
|
HeapTuple rs_ptup; /* previous tuple in scan */ |
||||||
|
HeapTuple rs_ctup; /* current tuple in scan */ |
||||||
|
HeapTuple rs_ntup; /* next tuple in scan */ |
||||||
|
Buffer rs_pbuf; /* previous buffer in scan */ |
||||||
|
Buffer rs_cbuf; /* current buffer in scan */ |
||||||
|
Buffer rs_nbuf; /* next buffer in scan */ |
||||||
|
ItemPointerData rs_mptid; /* marked previous tid */ |
||||||
|
ItemPointerData rs_mctid; /* marked current tid */ |
||||||
|
ItemPointerData rs_mntid; /* marked next tid */ |
||||||
|
ItemPointerData rs_mcd; /* marked current delta XXX ??? */ |
||||||
|
bool rs_atend; /* restart scan at end? */ |
||||||
|
TimeQual rs_tr; /* time qualification */ |
||||||
|
uint16 rs_cdelta; /* current delta in chain */ |
||||||
|
uint16 rs_nkeys; /* number of attributes in keys */ |
||||||
|
ScanKey rs_key; /* key descriptors */ |
||||||
|
} HeapScanDescData; |
||||||
|
|
||||||
|
typedef HeapScanDescData *HeapScanDesc; |
||||||
|
|
||||||
|
typedef struct IndexScanDescData { |
||||||
|
Relation relation; /* relation descriptor */ |
||||||
|
void *opaque; /* am-specific slot */ |
||||||
|
ItemPointerData previousItemData; /* previous index pointer */ |
||||||
|
ItemPointerData currentItemData; /* current index pointer */ |
||||||
|
ItemPointerData nextItemData; /* next index pointer */ |
||||||
|
MarkData previousMarkData; /* marked previous pointer */ |
||||||
|
MarkData currentMarkData; /* marked current pointer */ |
||||||
|
MarkData nextMarkData; /* marked next pointer */ |
||||||
|
uint8 flags; /* scan position flags */ |
||||||
|
bool scanFromEnd; /* restart scan at end? */ |
||||||
|
uint16 numberOfKeys; /* number of key attributes */ |
||||||
|
ScanKey keyData; /* key descriptor */ |
||||||
|
} IndexScanDescData; |
||||||
|
|
||||||
|
typedef IndexScanDescData *IndexScanDesc; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* IndexScanDescPtr is used in the executor where we have to |
||||||
|
* keep track of several index scans when using several indices |
||||||
|
* - cim 9/10/89 |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
typedef IndexScanDesc *IndexScanDescPtr; |
||||||
|
|
||||||
|
/*
|
||||||
|
* HeapScanIsValid -- |
||||||
|
* True iff the heap scan is valid. |
||||||
|
*/ |
||||||
|
#define HeapScanIsValid(scan) PointerIsValid(scan) |
||||||
|
|
||||||
|
/*
|
||||||
|
* IndexScanIsValid -- |
||||||
|
* True iff the index scan is valid. |
||||||
|
*/ |
||||||
|
#define IndexScanIsValid(scan) PointerIsValid(scan) |
||||||
|
|
||||||
|
#endif /* RELSCAN_H */ |
@ -0,0 +1,98 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* rtree.h-- |
||||||
|
* common declarations for the rtree access method code. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: rtree.h,v 1.1 1996/08/27 21:50:21 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef RTREE_H |
||||||
|
#define RTREE_H |
||||||
|
|
||||||
|
/* see rtstrat.c for what all this is about */ |
||||||
|
#define RTNStrategies 8 |
||||||
|
#define RTLeftStrategyNumber 1 |
||||||
|
#define RTOverLeftStrategyNumber 2 |
||||||
|
#define RTOverlapStrategyNumber 3 |
||||||
|
#define RTOverRightStrategyNumber 4 |
||||||
|
#define RTRightStrategyNumber 5 |
||||||
|
#define RTSameStrategyNumber 6 |
||||||
|
#define RTContainsStrategyNumber 7 |
||||||
|
#define RTContainedByStrategyNumber 8 |
||||||
|
|
||||||
|
#define RTNProcs 3 |
||||||
|
#define RT_UNION_PROC 1 |
||||||
|
#define RT_INTER_PROC 2 |
||||||
|
#define RT_SIZE_PROC 3 |
||||||
|
|
||||||
|
#define F_LEAF (1 << 0) |
||||||
|
|
||||||
|
typedef struct RTreePageOpaqueData { |
||||||
|
uint32 flags; |
||||||
|
} RTreePageOpaqueData; |
||||||
|
|
||||||
|
typedef RTreePageOpaqueData *RTreePageOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* When we descend a tree, we keep a stack of parent pointers. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct RTSTACK { |
||||||
|
struct RTSTACK *rts_parent; |
||||||
|
OffsetNumber rts_child; |
||||||
|
BlockNumber rts_blk; |
||||||
|
} RTSTACK; |
||||||
|
|
||||||
|
/*
|
||||||
|
* When we're doing a scan, we need to keep track of the parent stack |
||||||
|
* for the marked and current items. Also, rtrees have the following |
||||||
|
* property: if you're looking for the box (1,1,2,2), on the internal |
||||||
|
* nodes you have to search for all boxes that *contain* (1,1,2,2), and |
||||||
|
* not the ones that match it. We have a private scan key for internal |
||||||
|
* nodes in the opaque structure for rtrees for this reason. See |
||||||
|
* access/index-rtree/rtscan.c and rtstrat.c for how it gets initialized. |
||||||
|
*/ |
||||||
|
|
||||||
|
typedef struct RTreeScanOpaqueData { |
||||||
|
struct RTSTACK *s_stack; |
||||||
|
struct RTSTACK *s_markstk; |
||||||
|
uint16 s_flags; |
||||||
|
uint16 s_internalNKey; |
||||||
|
ScanKey s_internalKey; |
||||||
|
} RTreeScanOpaqueData; |
||||||
|
|
||||||
|
typedef RTreeScanOpaqueData *RTreeScanOpaque; |
||||||
|
|
||||||
|
/*
|
||||||
|
* When we're doing a scan and updating a tree at the same time, the |
||||||
|
* updates may affect the scan. We use the flags entry of the scan's |
||||||
|
* opaque space to record our actual position in response to updates |
||||||
|
* that we can't handle simply by adjusting pointers. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define RTS_CURBEFORE ((uint16) (1 << 0)) |
||||||
|
#define RTS_MRKBEFORE ((uint16) (1 << 1)) |
||||||
|
|
||||||
|
/* root page of an rtree */ |
||||||
|
#define P_ROOT 0 |
||||||
|
|
||||||
|
/*
|
||||||
|
* When we update a relation on which we're doing a scan, we need to |
||||||
|
* check the scan and fix it if the update affected any of the pages it |
||||||
|
* touches. Otherwise, we can miss records that we should see. The only |
||||||
|
* times we need to do this are for deletions and splits. See the code in |
||||||
|
* rtscan.c for how the scan is fixed. These two contants tell us what sort |
||||||
|
* of operation changed the index. |
||||||
|
*/ |
||||||
|
|
||||||
|
#define RTOP_DEL 0 |
||||||
|
#define RTOP_SPLIT 1 |
||||||
|
|
||||||
|
/* defined in rtree.c */ |
||||||
|
extern void freestack(RTSTACK *s); |
||||||
|
|
||||||
|
#endif /* RTREE_H */ |
@ -0,0 +1,17 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* rtscan.h-- |
||||||
|
* routines defined in access/rtree/rtscan.c |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: rtscan.h,v 1.1 1996/08/27 21:50:22 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef RTSCAN_H |
||||||
|
|
||||||
|
void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); |
||||||
|
|
||||||
|
#endif /* RTSCAN_H */ |
@ -0,0 +1,18 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* rtstrat.h-- |
||||||
|
* routines defined in access/rtree/rtstrat.c |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: rtstrat.h,v 1.1 1996/08/27 21:50:23 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef RTSTRAT_H |
||||||
|
|
||||||
|
extern RegProcedure RTMapOperator(Relation r, AttrNumber attnum, |
||||||
|
RegProcedure proc); |
||||||
|
|
||||||
|
#endif /* RTSTRAT_H */ |
@ -0,0 +1,57 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* sdir.h-- |
||||||
|
* POSTGRES scan direction definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: sdir.h,v 1.1 1996/08/27 21:50:23 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef SDIR_H |
||||||
|
#define SDIR_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* ScanDirection was an int8 for no apparent reason. I kept the original |
||||||
|
* values because I'm not sure if I'll break anything otherwise. -ay 2/95 |
||||||
|
*/ |
||||||
|
typedef enum ScanDirection { |
||||||
|
BackwardScanDirection = -1, |
||||||
|
NoMovementScanDirection = 0, |
||||||
|
ForwardScanDirection = 1 |
||||||
|
} ScanDirection; |
||||||
|
|
||||||
|
/*
|
||||||
|
* ScanDirectionIsValid -- |
||||||
|
* True iff scan direction is valid. |
||||||
|
*/ |
||||||
|
#define ScanDirectionIsValid(direction) \ |
||||||
|
((bool) (BackwardScanDirection <= direction && \
|
||||||
|
direction <= ForwardScanDirection)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* ScanDirectionIsBackward -- |
||||||
|
* True iff scan direction is backward. |
||||||
|
*/ |
||||||
|
#define ScanDirectionIsBackward(direction) \ |
||||||
|
((bool) (direction == BackwardScanDirection)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* ScanDirectionIsNoMovement -- |
||||||
|
* True iff scan direction indicates no movement. |
||||||
|
*/ |
||||||
|
#define ScanDirectionIsNoMovement(direction) \ |
||||||
|
((bool) (direction == NoMovementScanDirection)) |
||||||
|
|
||||||
|
/*
|
||||||
|
* ScanDirectionIsForward -- |
||||||
|
* True iff scan direction is forward. |
||||||
|
*/ |
||||||
|
#define ScanDirectionIsForward(direction) \ |
||||||
|
((bool) (direction == ForwardScanDirection)) |
||||||
|
|
||||||
|
#endif /* SDIR_H */ |
@ -0,0 +1,52 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* skey.h-- |
||||||
|
* POSTGRES scan key definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: skey.h,v 1.1 1996/08/27 21:50:24 scrappy Exp $ |
||||||
|
* |
||||||
|
* |
||||||
|
* Note: |
||||||
|
* Needs more accessor/assignment routines. |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef SKEY_H |
||||||
|
#define SKEY_H |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
#include "access/attnum.h" |
||||||
|
|
||||||
|
|
||||||
|
typedef struct ScanKeyData { |
||||||
|
bits16 sk_flags; /* flags */ |
||||||
|
AttrNumber sk_attno; /* domain number */ |
||||||
|
RegProcedure sk_procedure; /* procedure OID */ |
||||||
|
func_ptr sk_func; |
||||||
|
int32 sk_nargs; |
||||||
|
Datum sk_argument; /* data to compare */ |
||||||
|
} ScanKeyData; |
||||||
|
|
||||||
|
typedef ScanKeyData *ScanKey; |
||||||
|
|
||||||
|
|
||||||
|
#define SK_ISNULL 0x1 |
||||||
|
#define SK_UNARY 0x2 |
||||||
|
#define SK_NEGATE 0x4 |
||||||
|
#define SK_COMMUTE 0x8 |
||||||
|
|
||||||
|
#define ScanUnmarked 0x01 |
||||||
|
#define ScanUncheckedPrevious 0x02 |
||||||
|
#define ScanUncheckedNext 0x04 |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in access/common/scankey.c |
||||||
|
*/ |
||||||
|
extern void ScanKeyEntrySetIllegal(ScanKey entry); |
||||||
|
extern void ScanKeyEntryInitialize(ScanKey entry, bits16 flags, |
||||||
|
AttrNumber attributeNumber, RegProcedure procedure, Datum argument); |
||||||
|
|
||||||
|
#endif /* SKEY_H */ |
@ -0,0 +1,86 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* strat.h-- |
||||||
|
* index strategy type definitions |
||||||
|
* (separated out from original istrat.h to avoid circular refs) |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: strat.h,v 1.1 1996/08/27 21:50:25 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef STRAT_H |
||||||
|
#define STRAT_H |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
#include "access/attnum.h" |
||||||
|
#include "access/skey.h" |
||||||
|
|
||||||
|
typedef uint16 StrategyNumber; |
||||||
|
|
||||||
|
#define InvalidStrategy 0 |
||||||
|
|
||||||
|
typedef struct StrategyTransformMapData { |
||||||
|
StrategyNumber strategy[1]; /* VARIABLE LENGTH ARRAY */ |
||||||
|
} StrategyTransformMapData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef StrategyTransformMapData *StrategyTransformMap; |
||||||
|
|
||||||
|
typedef struct StrategyOperatorData { |
||||||
|
StrategyNumber strategy; |
||||||
|
bits16 flags; /* scan qualification flags h/skey.h */ |
||||||
|
} StrategyOperatorData; |
||||||
|
|
||||||
|
typedef StrategyOperatorData *StrategyOperator; |
||||||
|
|
||||||
|
typedef struct StrategyTermData { /* conjunctive term */ |
||||||
|
uint16 degree; |
||||||
|
StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH */ |
||||||
|
} StrategyTermData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef StrategyTermData *StrategyTerm; |
||||||
|
|
||||||
|
typedef struct StrategyExpressionData { /* disjunctive normal form */ |
||||||
|
StrategyTerm term[1]; /* VARIABLE LENGTH ARRAY */ |
||||||
|
} StrategyExpressionData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef StrategyExpressionData *StrategyExpression; |
||||||
|
|
||||||
|
typedef struct StrategyEvaluationData { |
||||||
|
StrategyNumber maxStrategy; |
||||||
|
StrategyTransformMap negateTransform; |
||||||
|
StrategyTransformMap commuteTransform; |
||||||
|
StrategyTransformMap negateCommuteTransform; |
||||||
|
StrategyExpression expression[12]; /* XXX VARIABLE LENGTH */ |
||||||
|
} StrategyEvaluationData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef StrategyEvaluationData *StrategyEvaluation; |
||||||
|
|
||||||
|
/*
|
||||||
|
* StrategyTransformMapIsValid -- |
||||||
|
* Returns true iff strategy transformation map is valid. |
||||||
|
*/ |
||||||
|
#define StrategyTransformMapIsValid(transform) PointerIsValid(transform) |
||||||
|
|
||||||
|
|
||||||
|
#ifndef CorrectStrategies /* XXX this should be removable */ |
||||||
|
#define AMStrategies(foo) 12 |
||||||
|
#else /* !defined(CorrectStrategies) */ |
||||||
|
#define AMStrategies(foo) (foo) |
||||||
|
#endif /* !defined(CorrectStrategies) */ |
||||||
|
|
||||||
|
typedef struct StrategyMapData { |
||||||
|
ScanKeyData entry[1]; /* VARIABLE LENGTH ARRAY */ |
||||||
|
} StrategyMapData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef StrategyMapData *StrategyMap; |
||||||
|
|
||||||
|
typedef struct IndexStrategyData { |
||||||
|
StrategyMapData strategyMapData[1]; /* VARIABLE LENGTH ARRAY */ |
||||||
|
} IndexStrategyData; /* VARIABLE LENGTH STRUCTURE */ |
||||||
|
|
||||||
|
typedef IndexStrategyData *IndexStrategy; |
||||||
|
|
||||||
|
#endif /*STRAT_H */ |
@ -0,0 +1,222 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* transam.h-- |
||||||
|
* postgres transaction access method support code header |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: transam.h,v 1.1 1996/08/27 21:50:26 scrappy Exp $ |
||||||
|
* |
||||||
|
* NOTES |
||||||
|
* Transaction System Version 101 now support proper oid |
||||||
|
* generation and recording in the variable relation. |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef TRANSAM_H |
||||||
|
#define TRANSAM_H |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction system version id |
||||||
|
* |
||||||
|
* this is stored on the first page of the log, time and variable |
||||||
|
* relations on the first 4 bytes. This is so that if we improve |
||||||
|
* the format of the transaction log after postgres version 2, then |
||||||
|
* people won't have to rebuild their databases. |
||||||
|
* |
||||||
|
* TRANS_SYSTEM_VERSION 100 means major version 1 minor version 0. |
||||||
|
* Two databases with the same major version should be compatible, |
||||||
|
* even if their minor versions differ. |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define TRANS_SYSTEM_VERSION 101 |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction id status values |
||||||
|
* |
||||||
|
* someday we will use "11" = 3 = XID_INVALID to mean the |
||||||
|
* starting of run-length encoded log data. |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define XID_COMMIT 2 /* transaction commited */ |
||||||
|
#define XID_ABORT 1 /* transaction aborted */ |
||||||
|
#define XID_INPROGRESS 0 /* transaction in progress */ |
||||||
|
#define XID_INVALID 3 /* other */ |
||||||
|
|
||||||
|
typedef unsigned char XidStatus; /* (2 bits) */ |
||||||
|
|
||||||
|
/* ----------
|
||||||
|
* note: we reserve the first 16384 object ids for internal use. |
||||||
|
* oid's less than this appear in the .bki files. the choice of |
||||||
|
* 16384 is completely arbitrary. |
||||||
|
* ---------- |
||||||
|
*/ |
||||||
|
#define BootstrapObjectIdData 16384 |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* BitIndexOf computes the index of the Nth xid on a given block |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define BitIndexOf(N) ((N) * 2) |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction page definitions |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define TP_DataSize BLCKSZ |
||||||
|
#define TP_NumXidStatusPerBlock (TP_DataSize * 4) |
||||||
|
#define TP_NumTimePerBlock (TP_DataSize / 4) |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* LogRelationContents structure |
||||||
|
* |
||||||
|
* This structure describes the storage of the data in the |
||||||
|
* first 128 bytes of the log relation. This storage is never |
||||||
|
* used for transaction status because transaction id's begin |
||||||
|
* their numbering at 512. |
||||||
|
* |
||||||
|
* The first 4 bytes of this relation store the version |
||||||
|
* number of the transction system. |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
typedef struct LogRelationContentsData { |
||||||
|
int TransSystemVersion; |
||||||
|
} LogRelationContentsData; |
||||||
|
|
||||||
|
typedef LogRelationContentsData *LogRelationContents; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* TimeRelationContents structure |
||||||
|
* |
||||||
|
* This structure describes the storage of the data in the |
||||||
|
* first 2048 bytes of the time relation. This storage is never |
||||||
|
* used for transaction commit times because transaction id's begin |
||||||
|
* their numbering at 512. |
||||||
|
* |
||||||
|
* The first 4 bytes of this relation store the version |
||||||
|
* number of the transction system. |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
typedef struct TimeRelationContentsData { |
||||||
|
int TransSystemVersion; |
||||||
|
} TimeRelationContentsData; |
||||||
|
|
||||||
|
typedef TimeRelationContentsData *TimeRelationContents; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* VariableRelationContents structure |
||||||
|
* |
||||||
|
* The variable relation is a special "relation" which |
||||||
|
* is used to store various system "variables" persistantly. |
||||||
|
* Unlike other relations in the system, this relation |
||||||
|
* is updated in place whenever the variables change. |
||||||
|
* |
||||||
|
* The first 4 bytes of this relation store the version |
||||||
|
* number of the transction system. |
||||||
|
* |
||||||
|
* Currently, the relation has only one page and the next |
||||||
|
* available xid, the last committed xid and the next |
||||||
|
* available oid are stored there. |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
typedef struct VariableRelationContentsData { |
||||||
|
int TransSystemVersion; |
||||||
|
TransactionId nextXidData; |
||||||
|
TransactionId lastXidData; |
||||||
|
Oid nextOid; |
||||||
|
} VariableRelationContentsData; |
||||||
|
|
||||||
|
typedef VariableRelationContentsData *VariableRelationContents; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* extern declarations |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes for functions in transam/transam.c |
||||||
|
*/ |
||||||
|
extern int RecoveryCheckingEnabled(); |
||||||
|
extern void SetRecoveryCheckingEnabled(bool state); |
||||||
|
extern bool TransactionLogTest(TransactionId transactionId, XidStatus status); |
||||||
|
extern void TransactionLogUpdate(TransactionId transactionId, |
||||||
|
XidStatus status); |
||||||
|
extern AbsoluteTime TransactionIdGetCommitTime(TransactionId transactionId); |
||||||
|
extern void TransRecover(Relation logRelation); |
||||||
|
extern void InitializeTransactionLog(); |
||||||
|
extern bool TransactionIdDidCommit(TransactionId transactionId); |
||||||
|
extern bool TransactionIdDidAbort(TransactionId transactionId); |
||||||
|
extern bool TransactionIdIsInProgress(TransactionId transactionId); |
||||||
|
extern void TransactionIdCommit(TransactionId transactionId); |
||||||
|
extern void TransactionIdAbort(TransactionId transactionId); |
||||||
|
extern void TransactionIdSetInProgress(TransactionId transactionId); |
||||||
|
|
||||||
|
/* in transam/transsup.c */ |
||||||
|
extern void AmiTransactionOverride(bool flag); |
||||||
|
extern void TransComputeBlockNumber(Relation relation, |
||||||
|
TransactionId transactionId, BlockNumber *blockNumberOutP); |
||||||
|
extern XidStatus TransBlockGetLastTransactionIdStatus(Block tblock, |
||||||
|
TransactionId baseXid, TransactionId *returnXidP); |
||||||
|
extern XidStatus TransBlockGetXidStatus(Block tblock, |
||||||
|
TransactionId transactionId); |
||||||
|
extern void TransBlockSetXidStatus(Block tblock, |
||||||
|
TransactionId transactionId, XidStatus xstatus); |
||||||
|
extern AbsoluteTime TransBlockGetCommitTime(Block tblock, |
||||||
|
TransactionId transactionId); |
||||||
|
extern void TransBlockSetCommitTime(Block tblock, |
||||||
|
TransactionId transactionId, AbsoluteTime commitTime); |
||||||
|
extern XidStatus TransBlockNumberGetXidStatus(Relation relation, |
||||||
|
BlockNumber blockNumber, TransactionId xid, bool *failP); |
||||||
|
extern void TransBlockNumberSetXidStatus(Relation relation, |
||||||
|
BlockNumber blockNumber, TransactionId xid, XidStatus xstatus, |
||||||
|
bool *failP); |
||||||
|
extern AbsoluteTime TransBlockNumberGetCommitTime(Relation relation, |
||||||
|
BlockNumber blockNumber, TransactionId xid, bool *failP); |
||||||
|
extern void TransBlockNumberSetCommitTime(Relation relation, |
||||||
|
BlockNumber blockNumber, TransactionId xid, AbsoluteTime xtime, |
||||||
|
bool *failP); |
||||||
|
extern void TransGetLastRecordedTransaction(Relation relation, |
||||||
|
TransactionId xid, bool *failP); |
||||||
|
|
||||||
|
/* in transam/varsup.c */ |
||||||
|
extern void VariableRelationGetNextXid(TransactionId *xidP); |
||||||
|
extern void VariableRelationGetLastXid(TransactionId *xidP); |
||||||
|
extern void VariableRelationPutNextXid(TransactionId xid); |
||||||
|
extern void VariableRelationPutLastXid(TransactionId xid); |
||||||
|
extern void VariableRelationGetNextOid(Oid *oid_return); |
||||||
|
extern void VariableRelationPutNextOid(Oid *oidP); |
||||||
|
extern void GetNewTransactionId(TransactionId *xid); |
||||||
|
extern void UpdateLastCommittedXid(TransactionId xid); |
||||||
|
extern void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size); |
||||||
|
extern void GetNewObjectId(Oid *oid_return); |
||||||
|
extern void CheckMaxObjectId(Oid assigned_oid); |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* global variable extern declarations |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
/* in transam.c */ |
||||||
|
extern Relation LogRelation; |
||||||
|
extern Relation TimeRelation; |
||||||
|
extern Relation VariableRelation; |
||||||
|
|
||||||
|
extern TransactionId cachedGetCommitTimeXid; |
||||||
|
extern AbsoluteTime cachedGetCommitTime; |
||||||
|
extern TransactionId cachedTestXid; |
||||||
|
extern XidStatus cachedTestXidStatus; |
||||||
|
|
||||||
|
extern TransactionId NullTransactionId; |
||||||
|
extern TransactionId AmiTransactionId; |
||||||
|
extern TransactionId FirstTransactionId; |
||||||
|
|
||||||
|
extern int RecoveryCheckingEnableState; |
||||||
|
|
||||||
|
/* in transsup.c */ |
||||||
|
extern bool AMI_OVERRIDE;
|
||||||
|
|
||||||
|
/* in varsup.c */ |
||||||
|
extern int OidGenLockId; |
||||||
|
|
||||||
|
#endif /* TRAMSAM_H */ |
@ -0,0 +1,53 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* tupdesc.h-- |
||||||
|
* POSTGRES tuple descriptor definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: tupdesc.h,v 1.1 1996/08/27 21:50:26 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef TUPDESC_H |
||||||
|
#define TUPDESC_H |
||||||
|
|
||||||
|
#include "postgres.h" |
||||||
|
#include "access/attnum.h" |
||||||
|
#include "nodes/pg_list.h" /* for List */ |
||||||
|
#include "catalog/pg_attribute.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* a TupleDesc is an array of AttributeTupleForms, each of which is a |
||||||
|
* pointer to a AttributeTupleForm |
||||||
|
*/ |
||||||
|
/* typedef AttributeTupleForm *TupleDesc; */ |
||||||
|
|
||||||
|
/* a TupleDesc is a pointer to a structure which includes an array of */ |
||||||
|
/* AttributeTupleForms, i.e. pg_attribute information, and the size of */ |
||||||
|
/* the array, i.e. the number of attributes */ |
||||||
|
/* in short, a TupleDesc completely captures the attribute information */ |
||||||
|
/* for a tuple */ |
||||||
|
|
||||||
|
typedef struct tupleDesc { |
||||||
|
int natts; |
||||||
|
AttributeTupleForm *attrs; |
||||||
|
} *TupleDesc; |
||||||
|
|
||||||
|
extern TupleDesc CreateTemplateTupleDesc(int natts); |
||||||
|
|
||||||
|
extern TupleDesc CreateTupleDesc(int natts, AttributeTupleForm *attrs); |
||||||
|
|
||||||
|
extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc); |
||||||
|
|
||||||
|
extern bool TupleDescInitEntry(TupleDesc desc, |
||||||
|
AttrNumber attributeNumber, |
||||||
|
char *attributeName,
|
||||||
|
char *typeName,
|
||||||
|
int attdim,
|
||||||
|
bool attisset); |
||||||
|
|
||||||
|
extern TupleDesc BuildDescForRelation(List *schema, char *relname); |
||||||
|
|
||||||
|
#endif /* TUPDESC_H */ |
@ -0,0 +1,55 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* tupmacs.h-- |
||||||
|
* Tuple macros used by both index tuples and heap tuples. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: tupmacs.h,v 1.1 1996/08/27 21:50:27 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef TUPMACS_H |
||||||
|
#define TUPMACS_H |
||||||
|
|
||||||
|
/*
|
||||||
|
* check to see if the ATT'th bit of an array of 8-bit bytes is set. |
||||||
|
*/ |
||||||
|
#define att_isnull(ATT, BITS) (!((BITS)[(ATT) >> 3] & (1 << ((ATT) & 0x07)))) |
||||||
|
|
||||||
|
/*
|
||||||
|
* given a AttributeTupleForm and a pointer into a tuple's data |
||||||
|
* area, return the correct value or pointer. |
||||||
|
* |
||||||
|
* We return a 4 byte (char *) value in all cases. If the attribute has |
||||||
|
* "byval" false or has variable length, we return the same pointer |
||||||
|
* into the tuple data area that we're passed. Otherwise, we return |
||||||
|
* the 1, 2, or 4 bytes pointed to by it, properly extended to 4 |
||||||
|
* bytes, depending on the length of the attribute. |
||||||
|
* |
||||||
|
* note that T must already be properly LONGALIGN/SHORTALIGN'd for |
||||||
|
* this to work correctly. |
||||||
|
* |
||||||
|
* the double-cast is to stop gcc from (correctly) complaining about
|
||||||
|
* casting integer types with size < sizeof(char *) to (char *). |
||||||
|
* sign-extension may get weird if you use an integer type that |
||||||
|
* isn't the same size as (char *) for the first cast. (on the other |
||||||
|
* hand, it's safe to use another type for the (foo *)(T).) |
||||||
|
* |
||||||
|
* attbyval seems to be fairly redundant. We have to return a pointer if |
||||||
|
* the value is longer than 4 bytes or has variable length; returning the |
||||||
|
* value would be useless. In fact, for at least the variable length case, |
||||||
|
* the caller assumes we return a pointer regardless of attbyval. |
||||||
|
* I would eliminate attbyval altogether, but I don't know how. -BRYANH. |
||||||
|
*/ |
||||||
|
#define fetchatt(A, T) \ |
||||||
|
((*(A))->attbyval && (*(A))->attlen != -1 \
|
||||||
|
? ((*(A))->attlen > sizeof(int16) \
|
||||||
|
? (char *) (long) *((int32 *)(T)) \
|
||||||
|
: ((*(A))->attlen < sizeof(int16) \
|
||||||
|
? (char *) (long) *((char *)(T)) \
|
||||||
|
: (char *) (long) *((int16 *)(T)))) \
|
||||||
|
: (char *) (T)) |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,37 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* valid.h-- |
||||||
|
* POSTGRES tuple qualification validity definitions. |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: valid.h,v 1.1 1996/08/27 21:50:28 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef VALID_H |
||||||
|
#define VALID_H |
||||||
|
|
||||||
|
#include "c.h" |
||||||
|
#include "access/skey.h" |
||||||
|
#include "storage/buf.h" |
||||||
|
#include "utils/tqual.h" |
||||||
|
#include "access/tupdesc.h" |
||||||
|
#include "utils/rel.h" |
||||||
|
#include "storage/bufpage.h" |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* extern decl's |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
|
||||||
|
extern bool heap_keytest(HeapTuple t, TupleDesc tupdesc, |
||||||
|
int nkeys, ScanKey keys); |
||||||
|
|
||||||
|
extern HeapTuple heap_tuple_satisfies(ItemId itemId, Relation relation, |
||||||
|
PageHeader disk_page, TimeQual qual, int nKeys, ScanKey key); |
||||||
|
|
||||||
|
extern bool TupleUpdatedByCurXactAndCmd(HeapTuple t); |
||||||
|
|
||||||
|
#endif /* VALID_H */ |
@ -0,0 +1,115 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* xact.h-- |
||||||
|
* postgres transaction system header |
||||||
|
* |
||||||
|
* |
||||||
|
* Copyright (c) 1994, Regents of the University of California |
||||||
|
* |
||||||
|
* $Id: xact.h,v 1.1 1996/08/27 21:50:29 scrappy Exp $ |
||||||
|
* |
||||||
|
*------------------------------------------------------------------------- |
||||||
|
*/ |
||||||
|
#ifndef XACT_H |
||||||
|
#define XACT_H |
||||||
|
|
||||||
|
#include <signal.h> |
||||||
|
|
||||||
|
#include "storage/ipc.h" |
||||||
|
#include "miscadmin.h" |
||||||
|
#include "utils/portal.h" |
||||||
|
#include "utils/elog.h" |
||||||
|
#include "utils/mcxt.h" |
||||||
|
#include "utils/nabstime.h" |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction state structure |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
typedef struct TransactionStateData { |
||||||
|
TransactionId transactionIdData; |
||||||
|
CommandId commandId; |
||||||
|
AbsoluteTime startTime; |
||||||
|
int state; |
||||||
|
int blockState; |
||||||
|
} TransactionStateData; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction states |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define TRANS_DEFAULT 0 |
||||||
|
#define TRANS_START 1 |
||||||
|
#define TRANS_INPROGRESS 2 |
||||||
|
#define TRANS_COMMIT 3 |
||||||
|
#define TRANS_ABORT 4 |
||||||
|
#define TRANS_DISABLED 5 |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* transaction block states |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
#define TBLOCK_DEFAULT 0 |
||||||
|
#define TBLOCK_BEGIN 1 |
||||||
|
#define TBLOCK_INPROGRESS 2 |
||||||
|
#define TBLOCK_END 3 |
||||||
|
#define TBLOCK_ABORT 4 |
||||||
|
#define TBLOCK_ENDABORT 5 |
||||||
|
|
||||||
|
typedef TransactionStateData *TransactionState; |
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* extern definitions |
||||||
|
* ---------------- |
||||||
|
*/ |
||||||
|
extern int TransactionFlushEnabled(); |
||||||
|
extern void SetTransactionFlushEnabled(bool state); |
||||||
|
|
||||||
|
extern bool IsTransactionState(void); |
||||||
|
extern bool IsAbortedTransactionBlockState(void); |
||||||
|
extern void OverrideTransactionSystem(bool flag); |
||||||
|
extern TransactionId GetCurrentTransactionId(void); |
||||||
|
extern CommandId GetCurrentCommandId(void); |
||||||
|
extern AbsoluteTime GetCurrentTransactionStartTime(void); |
||||||
|
extern bool TransactionIdIsCurrentTransactionId(TransactionId xid); |
||||||
|
extern bool CommandIdIsCurrentCommandId(CommandId cid); |
||||||
|
extern void ClearCommandIdCounterOverflowFlag(void); |
||||||
|
extern void CommandCounterIncrement(void); |
||||||
|
extern void InitializeTransactionSystem(void); |
||||||
|
extern void AtStart_Cache(void); |
||||||
|
extern void AtStart_Locks(void); |
||||||
|
extern void AtStart_Memory(void); |
||||||
|
extern void RecordTransactionCommit(void); |
||||||
|
extern void AtCommit_Cache(void); |
||||||
|
extern void AtCommit_Locks(void); |
||||||
|
extern void AtCommit_Memory(void); |
||||||
|
extern void RecordTransactionAbort(void); |
||||||
|
extern void AtAbort_Cache(void); |
||||||
|
extern void AtAbort_Locks(void); |
||||||
|
extern void AtAbort_Memory(void); |
||||||
|
extern void StartTransaction(void); |
||||||
|
extern bool CurrentXactInProgress(void); |
||||||
|
extern void CommitTransaction(void); |
||||||
|
extern void AbortTransaction(void); |
||||||
|
extern void StartTransactionCommand(void); |
||||||
|
extern void CommitTransactionCommand(void); |
||||||
|
extern void AbortCurrentTransaction(void); |
||||||
|
extern void BeginTransactionBlock(void); |
||||||
|
extern void EndTransactionBlock(void); |
||||||
|
extern void AbortTransactionBlock(void); |
||||||
|
extern bool IsTransactionBlock(); |
||||||
|
extern void UserAbortTransactionBlock(); |
||||||
|
|
||||||
|
extern TransactionId DisabledTransactionId; |
||||||
|
|
||||||
|
/* defined in xid.c */ |
||||||
|
extern bool TransactionIdIsValid(TransactionId transactionId); |
||||||
|
extern void StoreInvalidTransactionId(TransactionId *destination); |
||||||
|
extern void TransactionIdStore(TransactionId transactionId, |
||||||
|
TransactionId *destination); |
||||||
|
extern bool TransactionIdEquals(TransactionId id1, TransactionId id2); |
||||||
|
extern bool TransactionIdIsLessThan(TransactionId id1, TransactionId id2); |
||||||
|
extern void TransactionIdIncrement(TransactionId *transactionId); |
||||||
|
extern void TransactionIdAdd(TransactionId *xid, int value); |
||||||
|
|
||||||
|
#endif /* XACT_H */ |
Loading…
Reference in new issue