Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a8820e

Browse files
committed
Moved from backend/access to include/access
1 parent 9247b29 commit 5a8820e

28 files changed

+2418
-0
lines changed

src/include/access/attnum.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* attnum.h--
4+
* POSTGRES attribute number definitions.
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* $Id: attnum.h,v 1.1 1996/08/27 21:50:07 scrappy Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef ATTNUM_H
14+
#define ATTNUM_H
15+
16+
#include "c.h"
17+
18+
/*
19+
* user defined attribute numbers start at 1. -ay 2/95
20+
*/
21+
typedef int16 AttrNumber;
22+
23+
#define InvalidAttrNumber 0
24+
25+
/* ----------------
26+
* support macros
27+
* ----------------
28+
*/
29+
/*
30+
* AttributeNumberIsValid --
31+
* True iff the attribute number is valid.
32+
*/
33+
#define AttributeNumberIsValid(attributeNumber) \
34+
((bool) ((attributeNumber) != InvalidAttrNumber))
35+
36+
/*
37+
* AttrNumberIsForUserDefinedAttr --
38+
* True iff the attribute number corresponds to an user defined attribute.
39+
*/
40+
#define AttrNumberIsForUserDefinedAttr(attributeNumber) \
41+
((bool) ((attributeNumber) > 0))
42+
43+
/*
44+
* AttrNumberGetAttrOffset --
45+
* Returns the attribute offset for an attribute number.
46+
*
47+
* Note:
48+
* Assumes the attribute number is for an user defined attribute.
49+
*/
50+
#define AttrNumberGetAttrOffset(attNum) \
51+
(AssertMacro(AttrNumberIsForUserDefinedAttr(attNum)) ? \
52+
((attNum - 1)) : 0)
53+
54+
/*
55+
* AttributeOffsetGetAttributeNumber --
56+
* Returns the attribute number for an attribute offset.
57+
*/
58+
#define AttrOffsetGetAttrNumber(attributeOffset) \
59+
((AttrNumber) (1 + attributeOffset))
60+
61+
#endif /* ATTNUM_H */

src/include/access/funcindex.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* funcindex.h--
4+
*
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* $Id: funcindex.h,v 1.1 1996/08/27 21:50:08 scrappy Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef _FUNC_INDEX_INCLUDED_
14+
#define _FUNC_INDEX_INCLUDED_
15+
16+
#include "postgres.h"
17+
18+
typedef struct {
19+
int nargs;
20+
Oid arglist[8];
21+
Oid procOid;
22+
NameData funcName;
23+
} FuncIndexInfo;
24+
25+
typedef FuncIndexInfo *FuncIndexInfoPtr;
26+
27+
/*
28+
* some marginally useful macro definitions
29+
*/
30+
/* #define FIgetname(FINFO) (&((FINFO)->funcName.data[0]))*/
31+
#define FIgetname(FINFO) (FINFO)->funcName.data
32+
#define FIgetnArgs(FINFO) (FINFO)->nargs
33+
#define FIgetProcOid(FINFO) (FINFO)->procOid
34+
#define FIgetArg(FINFO, argnum) (FINFO)->arglist[argnum]
35+
#define FIgetArglist(FINFO) (FINFO)->arglist
36+
37+
#define FIsetnArgs(FINFO, numargs) ((FINFO)->nargs = numargs)
38+
#define FIsetProcOid(FINFO, id) ((FINFO)->procOid = id)
39+
#define FIsetArg(FINFO, argnum, argtype) ((FINFO)->arglist[argnum] = argtype)
40+
41+
#define FIisFunctionalIndex(FINFO) (FINFO->procOid != InvalidOid)
42+
43+
#endif /* FUNCINDEX_H */

src/include/access/genam.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* genam.h--
4+
* POSTGRES general access method definitions.
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* $Id: genam.h,v 1.1 1996/08/27 21:50:09 scrappy Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef GENAM_H
14+
#define GENAM_H
15+
16+
#include "postgres.h"
17+
18+
#include "access/attnum.h"
19+
#include "access/htup.h"
20+
#include "access/istrat.h"
21+
#include "access/itup.h"
22+
#include "access/relscan.h"
23+
#include "access/skey.h"
24+
#include "access/sdir.h"
25+
#include "access/funcindex.h"
26+
27+
/* ----------------
28+
* generalized index_ interface routines
29+
* ----------------
30+
*/
31+
extern Relation index_open(Oid relationId);
32+
extern Relation index_openr(char *relationName);
33+
extern void index_close(Relation relation);
34+
extern InsertIndexResult index_insert(Relation relation,
35+
Datum *datum, char *nulls,
36+
ItemPointer heap_t_ctid);
37+
extern void index_delete(Relation relation, ItemPointer indexItem);
38+
extern IndexScanDesc index_beginscan(Relation relation, bool scanFromEnd,
39+
uint16 numberOfKeys, ScanKey key);
40+
extern void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key);
41+
extern void index_endscan(IndexScanDesc scan);
42+
extern void index_markpos(IndexScanDesc scan);
43+
extern void index_restrpos(IndexScanDesc scan);
44+
extern RetrieveIndexResult index_getnext(IndexScanDesc scan,
45+
ScanDirection direction);
46+
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
47+
uint16 procnum);
48+
extern Datum GetIndexValue(HeapTuple tuple, TupleDesc hTupDesc,
49+
int attOff, AttrNumber attrNums[], FuncIndexInfo *fInfo,
50+
bool *attNull, Buffer buffer);
51+
52+
/* in genam.c */
53+
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd,
54+
uint16 numberOfKeys, ScanKey key);
55+
extern void IndexScanRestart(IndexScanDesc scan, bool scanFromEnd,
56+
ScanKey key);
57+
extern void IndexScanEnd(IndexScanDesc scan);
58+
extern void IndexScanMarkPosition(IndexScanDesc scan);
59+
extern void IndexScanRestorePosition(IndexScanDesc scan);
60+
61+
#endif /* GENAM_H */

src/include/access/gist.h

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* gist.h--
4+
* common declarations for the GiST access method code.
5+
*
6+
*
7+
*
8+
*
9+
*
10+
*-------------------------------------------------------------------------
11+
*/
12+
#ifndef GIST_H
13+
#define GIST_H
14+
15+
#include "utils/rel.h"
16+
#include "storage/off.h"
17+
#include "storage/block.h"
18+
#include "storage/bufpage.h"
19+
#include "access/skey.h"
20+
21+
/*
22+
** You can have as many strategies as you please in GiSTs, as
23+
** long as your consistent method can handle them
24+
*/
25+
#define GISTNStrategies 100
26+
27+
/*
28+
** Helper routines
29+
*/
30+
#define GISTNProcs 8
31+
#define GIST_CONSISTENT_PROC 1
32+
#define GIST_UNION_PROC 2
33+
#define GIST_COMPRESS_PROC 3
34+
#define GIST_DECOMPRESS_PROC 4
35+
#define GIST_PENALTY_PROC 5
36+
#define GIST_PICKSPLIT_PROC 6
37+
#define GIST_EQUAL_PROC 7
38+
#define GIST_INFO_PROC 8
39+
40+
#define F_LEAF (1 << 0)
41+
42+
typedef struct GISTPageOpaqueData {
43+
uint32 flags;
44+
} GISTPageOpaqueData;
45+
46+
typedef GISTPageOpaqueData *GISTPageOpaque;
47+
48+
#define GIST_LEAF(entry) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
49+
50+
/*
51+
* When we descend a tree, we keep a stack of parent pointers.
52+
*/
53+
54+
typedef struct GISTSTACK {
55+
struct GISTSTACK *gs_parent;
56+
OffsetNumber gs_child;
57+
BlockNumber gs_blk;
58+
} GISTSTACK;
59+
60+
typedef struct GISTSTATE {
61+
func_ptr consistentFn;
62+
func_ptr unionFn;
63+
func_ptr compressFn;
64+
func_ptr decompressFn;
65+
func_ptr penaltyFn;
66+
func_ptr picksplitFn;
67+
func_ptr equalFn;
68+
bool haskeytype;
69+
bool keytypbyval;
70+
} GISTSTATE;
71+
72+
73+
/*
74+
** When we're doing a scan, we need to keep track of the parent stack
75+
** for the marked and current items.
76+
*/
77+
78+
typedef struct GISTScanOpaqueData {
79+
struct GISTSTACK *s_stack;
80+
struct GISTSTACK *s_markstk;
81+
uint16 s_flags;
82+
struct GISTSTATE *giststate;
83+
} GISTScanOpaqueData;
84+
85+
typedef GISTScanOpaqueData *GISTScanOpaque;
86+
87+
/*
88+
** When we're doing a scan and updating a tree at the same time, the
89+
** updates may affect the scan. We use the flags entry of the scan's
90+
** opaque space to record our actual position in response to updates
91+
** that we can't handle simply by adjusting pointers.
92+
*/
93+
94+
#define GS_CURBEFORE ((uint16) (1 << 0))
95+
#define GS_MRKBEFORE ((uint16) (1 << 1))
96+
97+
/* root page of a gist */
98+
#define GISTP_ROOT 0
99+
100+
/*
101+
** When we update a relation on which we're doing a scan, we need to
102+
** check the scan and fix it if the update affected any of the pages it
103+
** touches. Otherwise, we can miss records that we should see. The only
104+
** times we need to do this are for deletions and splits. See the code in
105+
** gistscan.c for how the scan is fixed. These two constants tell us what sort
106+
** of operation changed the index.
107+
*/
108+
109+
#define GISTOP_DEL 0
110+
#define GISTOP_SPLIT 1
111+
112+
/*
113+
** This is the Split Vector to be returned by the PickSplit method.
114+
*/
115+
typedef struct GIST_SPLITVEC {
116+
OffsetNumber *spl_left; /* array of entries that go left */
117+
int spl_nleft; /* size of this array */
118+
char *spl_ldatum; /* Union of keys in spl_left */
119+
OffsetNumber *spl_right; /* array of entries that go right */
120+
int spl_nright; /* size of the array */
121+
char *spl_rdatum; /* Union of keys in spl_right */
122+
} GIST_SPLITVEC;
123+
124+
/*
125+
** An entry on a GiST node. Contains the key (pred), as well as
126+
** its own location (rel,page,offset) which can supply the matching
127+
** pointer. The size of the pred is in bytes, and leafkey is a flag to
128+
** tell us if the entry is in a leaf node.
129+
*/
130+
typedef struct GISTENTRY {
131+
char *pred;
132+
Relation rel;
133+
Page page;
134+
OffsetNumber offset;
135+
int bytes;
136+
bool leafkey;
137+
} GISTENTRY;
138+
139+
/*
140+
** macro to initialize a GISTENTRY
141+
*/
142+
#define gistentryinit(e, pr, r, pg, o, b, l)\
143+
{(e).pred = pr; (e).rel = r; (e).page = pg; (e).offset = o; (e).bytes = b; (e).leafkey = l;}
144+
145+
/* defined in gist.c */
146+
extern void gistfreestack(GISTSTACK *s);
147+
extern void initGISTstate(GISTSTATE *giststate, Relation index);
148+
extern void gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
149+
Relation r, Page pg, OffsetNumber o, int b, bool l) ;
150+
extern void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
151+
Relation r, Page pg, OffsetNumber o, int b, bool l) ;
152+
#endif /* GIST_H */

src/include/access/gistscan.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* gistscan.h--
4+
* routines defined in access/gisr/gistscan.c
5+
*
6+
*
7+
*
8+
* rtscan.h,v 1.2 1995/06/14 00:06:58 jolly Exp
9+
*
10+
*-------------------------------------------------------------------------
11+
*/
12+
#ifndef GISTSCAN_H
13+
14+
void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum);
15+
16+
#endif /* GISTSCAN_H */

src/include/access/giststrat.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* giststrat.h--
4+
* routines defined in access/gist/giststrat.c
5+
*
6+
*
7+
*
8+
* rtstrat.h,v 1.2 1995/02/12 02:54:51 andrew Exp
9+
*
10+
*-------------------------------------------------------------------------
11+
*/
12+
#ifndef GISTSTRAT_H
13+
14+
#endif /* GISTSTRAT_H */

0 commit comments

Comments
 (0)