|
|
1.1 root 1: #
2: /*
3: ** ACCESS.H -- definitions relating to the access methods.
4: **
5: ** Version:
6: ** @(#)access.h 7.1 2/5/81
7: */
8:
9: # ifndef PGSIZE
10:
11:
12: /*
13: ** PGSIZE is the physical size of a page.
14: ** MAXTUP is the maximum size of a tuple, assuming only one
15: ** tuple on the page. This is PGSIZE-hdrsize, where
16: ** hdrsize is the size of the page header (12 bytes).
17: ** MAXLINENO is the maximum number of tuples on a page
18: ** assuming minimum size tuples (1 byte). This is
19: ** constrained by the size of the lineid field of
20: ** the tid.
21: */
22:
23: # define PGSIZE 1024 /* size of page */
24: # define MAXTUP 1010 /* max size of a tuple */
25: # define MAXLINENO 254 /* max tuples per page */
26: # define PGPTRSIZ 4 /* size of a tid */
27: # define MAXTUPS 100 /* maximum number of tups */
28:
29: /* storage structure flags; < 0 means compressed */
30: # define M_HEAP 5 /* paged heap */
31: # define M_ISAM 11 /* indexed sequential */
32: # define M_HASH 21 /* random hash */
33: # define M_BTREE 31 /* BTREES */
34: # define M_TRUNC 99 /* internal pseudo-mode: truncated */
35:
36: # define NACCBUFS 3 /* number of access method buffers */
37:
38: /* error flags */
39: # define AMREAD_ERR -1
40: # define AMWRITE_ERR -2
41: # define AMNOFILE_ERR -3 /* can't open file for a relation */
42: # define AMREL_ERR -4 /* can't open relation relation */
43: # define AMATTR_ERR -5 /* can't open attribute relation */
44: # define AMNOATTS_ERR -6 /* attribute missing or xtra in att-rel */
45: # define AMCLOSE_ERR -7 /* can't close relation */
46: # define AMFIND_ERR -8 /* unidentifiable stora Petructure in find */
47: # define AMINVL_ERR -9 /* invalid TID */
48: # define AMOPNVIEW_ERR -10 /* attempt to open a view for rd or wr */
49:
50: /* the following is the access methods buffer */
51: struct accbuf
52: {
53: /* this stuff is actually stored in the relation */
54: long mainpg; /* next main page (0 - eof) */
55: long ovflopg; /* next ovflo page (0 - none) */
56: short nxtlino; /* next avail line no for this page */
57: char firstup[PGSIZE - 12]; /* tuple space */
58: short linetab[1]; /* line table at end of buffer - grows down */
59: /* linetab[lineno] is offset into
60: ** the buffer for that line; linetab[nxtlino]
61: ** is free space pointer */
62:
63: /* this stuff is not stored in the relation */
64: long rel_tupid; /* unique relation id */
65: long thispage; /* page number of the current page */
66: int filedesc; /* file descriptor for this reln */
67: struct accbuf *modf; /* use time link list forward pointer */
68: struct accbuf *modb; /* back pointer */
69: int bufstatus; /* various bits defined below */
70: };
71:
72: /* The following assignments are status bits for accbuf.bufstatus */
73: # define BUF_DIRTY 001 /* page has been changed */
74: # define BUF_LOCKED 002 /* page has a page lock on it */
75: # define BUF_DIRECT 004 /* this is a page from isam direct */
76:
77: /* access method buffer typed differently for various internal operations */
78: struct
79: {
80: char acc_buf[NACCBUFS];
81: };
82:
83: /* pointers to maintain the buffer */
84: extern struct accbuf *Acc_head; /* head of the LRU list */
85: extern struct accbuf *Acc_tail; /* tail of the LRU list */
86: extern struct accbuf Acc_buf[NACCBUFS]; /* the buffers themselves */
87:
88:
89: /*
90: ** ADMIN file struct
91: **
92: ** The ADMIN struct describes the initial part of the ADMIN file
93: ** which exists in each database. This file is used to initially
94: ** create the database, to maintain some information about the
95: ** database, and to access the RELATION and ATTRIBUTE relations
96: ** on OPENR calls.
97: */
98:
99: struct adminhdr
100: {
101: char adowner[2]; /* user code of data base owner */
102: short adflags; /* database flags */
103: short adlength; /* length of adminhdr */
104: short adversion; /* database format stamp */
105: short adreldsz; /* length of relation descriptor */
106: short adattdsz; /* length of attribute descriptor */
107: };
108:
109: struct admin
110: {
111: struct adminhdr adhdr;
112: struct descriptor adreld;
113: struct descriptor adattd;
114: };
115:
116: /*
117: ** Admin status bits
118: **
119: ** These bits define the status of the database. They are
120: ** contained in the adflags field of the admin struct.
121: */
122:
123: # define A_DBCONCUR 0000001 /* set database concurrency */
124: # define A_QRYMOD 0000002 /* database uses query modification */
125: # define A_NEWFMT 0000004 /* database is post-6.2 */
126:
127:
128: /* following is buffer space for data from admin file */
129: extern struct admin Admin;
130:
131: /*
132: ** PGTUPLE -- btree index key (a tid and an index key)
133: */
134:
135: struct pgtuple
136: {
137: struct tup_id childtid; /* the pointer comes before */
138: char childtup[MAXTUP];
139: };
140:
141: /*
142: ** global counters for the number of UNIX read and write
143: ** requests issued by the access methods.
144: */
145:
146: extern long Accuread, Accuwrite;
147:
148: /*
149: ** Global values used by everything
150: */
151:
152: extern char *Acctuple; /* pointer to canonical tuple */
153: extern Accerror; /* error no for fatal errors */
154: extern char Accanon[MAXTUP]; /* canonical tuple buffer */
155:
156: # endif PGSIZE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.