1: # 2: /* 3: ** COPYRIGHT 4: ** 5: ** The Regents of the University of California 6: ** 7: ** 1977 8: ** 9: ** This program material is the property of the 10: ** Regents of the University of California and 11: ** may not be reproduced or disclosed without 12: ** the prior written permission of the owner. 13: */ 14: 15: 16: 17: # 18: /* 19: ** conditional compilation flags 20: ** 21: ** Some of these may be commented out to set them to "off". 22: ** The comment should be removed to set them to "on". 23: */ 24: 25: /* access methods compilation flags */ 26: 27: /* disable timing information 28: # define xATM /* timing information */ 29: # define xATR1 /* trace info, level 1 */ 30: # define xATR2 /* trace info, level 2, implies xTR1 */ 31: # define xATR3 /* trace info, level 3, implies xTR1 & xTR2 */ 32: 33: /* decomposition compilation flags */ 34: 35: /* disable timing information 36: # define xDTM /* timing information */ 37: # define xDTR1 /* trace info, level 1 */ 38: # define xDTR2 /* trace info, level 2, implies xTR1 */ 39: # define xDTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 40: 41: /* EQUEL compilation flags */ 42: 43: /* disable timing information 44: # define xETM /* timing information */ 45: # define xETR1 /* trace info, level 1 */ 46: # define xETR2 /* trace info, level 2, implies xTR1 */ 47: # define xETR3 /* trace info, level 3, implies xTR1 & xTR2 */ 48: 49: /* monitor compilation flags */ 50: 51: /* disable timing information 52: # define xMTM /* timing information */ 53: # define xMTR1 /* trace info, level 1 */ 54: # define xMTR2 /* trace info, level 2, implies xTR1 */ 55: # define xMTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 56: 57: /* OVQP compilatiion flags */ 58: 59: /* disable timing information 60: # define xOTM /* timing information */ 61: # define xOTR1 /* trace info, level 1 */ 62: # define xOTR2 /* trace info, level 2, implies xTR1 */ 63: # define xOTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 64: 65: /* parser compilation flags */ 66: 67: /* disable timing information 68: # define xPTM /* timing information */ 69: # define xPTR1 /* trace info, level 1 */ 70: # define xPTR2 /* trace info, level 2, implies xTR1 */ 71: # define xPTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 72: 73: /* qrymod compilation flags */ 74: 75: /* disable timing information 76: # define xQTM /* timing information */ 77: # define xQTR1 /* trace info, level 1 */ 78: # define xQTR2 /* trace info, level 2, implies xTR1 */ 79: # define xQTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 80: 81: /* scanner compilation flags */ 82: 83: /* disable timing information 84: # define xSTM /* timing information */ 85: # define xSTR1 /* trace info, level 1 */ 86: # define xSTR2 /* trace info, level 2, implies xTR1 */ 87: # define xSTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 88: 89: /* DBU compilation flags */ 90: 91: /* disable timing information 92: # define xZTM /* timing information */ 93: # define xZTR1 /* trace info, level 1 */ 94: # define xZTR2 /* trace info, level 2, implies xTR1 */ 95: # define xZTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 96: 97: /* support compilation flags */ 98: 99: /* disable timing information 100: # define xTTM /* timing information */ 101: # define xTTR1 /* trace info, level 1 */ 102: # define xTTR2 /* trace info, level 2, implies xTR1 */ 103: # define xTTR3 /* trace info, level 3, implies xTR1 & xTR2 */ 104: 105: /* 106: ** INGRES manifest constants 107: ** 108: ** These constants are manifest to the operation of the entire 109: ** system. If anything 110: ** is changed part or all of the system will stop working. 111: ** The values have been carefully chosen and are not intended 112: ** to be modifiable by users. 113: */ 114: 115: # define MAXDOM 50 /* maximum number+1 of domains in a relation */ 116: # define MAXTUP 498 /* max size (in bytes) of a tuple */ 117: # define MAXNAME 12 /* max size of a name (in bytes) */ 118: # define MAXVAR 10 /* max # of variables */ 119: # define MAXKEYS 6 /* max # of keys in secondary index */ 120: # define MAXAGG 50 /* max number of aggs in a qry */ 121: # define MAXPARMS MAXDOM * 2 + 20 /* max number of parameters 122: ** to the DBU controller 123: ** (allows for 2 per domain for 124: ** create which is the worst case 125: */ 126: # define STACKSIZ 20 /* max depth for arith. expr. stacks */ 127: # define I1MASK 0377 /* mask out sign extension that occurs 128: ** when a c1 or i1 field is converted 129: ** to an i2 field. 130: */ 131: 132: # define TRUE 1 /* logical one, true, yes, ok, etc.*/ 133: # define FALSE 0 /* logical zero, false, no, nop, etc. */ 134: # ifndef NULL 135: # define NULL 0 136: # endif 137: 138: # define i_1 char 139: # define i_2 int 140: # define i_4 long 141: # define c_1 char 142: # define c_2 char 143: # define c_12 char 144: 145: /* 146: ** RELATION relation struct 147: ** 148: ** The RELATION relation contains one tuple for each relation 149: ** in the database. This relation contains information which 150: ** describes how each relation is actually stored in the 151: ** database, who the owner is, information about its size, 152: ** assorted operation information, etc. 153: */ 154: 155: # define RELID 1 /* domain for setkey */ 156: # define RELOWNER 2 157: 158: /* 159: ** Note carefully! 160: ** 161: ** Do not change this struct without changing the exact copy 162: ** of it occuring at the beginning of the descriptor struct! 163: */ 164: 165: struct relation 166: { 167: c_12 relid[MAXNAME]; /* relation name */ 168: c_2 relowner[2]; /* code of relation owner */ 169: i_1 relspec; /* storage mode of relation */ 170: /* M_HEAP unsorted paged heap */ 171: /* -M_HEAP compressed heap */ 172: /* M_ISAM isam */ 173: /* -M_ISAM compressed isam */ 174: /* M_HASH hashed */ 175: /* -M_HASH compressed hash */ 176: i_1 relindxd; /* -1 rel is an index, 0 not indexed, 1 indexed */ 177: i_2 relstat; /* relation status bits */ 178: i_4 relsave; /*unix time until which relation is saved*/ 179: i_4 reltups; /*number of tuples in relation */ 180: i_2 relatts; /*number of attributes in relation */ 181: i_2 relwid; /*width (in bytes) of relation */ 182: i_4 relprim; /*no. of primary pages in relation*/ 183: i_4 relspare; /*not used yet*/ 184: }; 185: 186: 187: /* 188: ** ATTRIBUTE relation struct 189: ** 190: ** The ATTRIBUTE relation contains one tuple for each domain 191: ** of each relation in the database. This relation describes 192: ** the position of each domain in the tuple, its format, 193: ** its length, and whether or not it is used in part of the key. 194: */ 195: 196: # define ATTRELID 1 197: # define ATTOWNER 2 198: # define ATTNAME 3 199: # define ATTID 4 200: 201: 202: struct attribute 203: { 204: c_12 attrelid[MAXNAME]; /*relation name of which this is an attr */ 205: c_2 attowner[2]; /* code of relation owner */ 206: c_12 attname[MAXNAME]; /*alias for this domain*/ 207: i_2 attid; /*domain number (from 1 to relatts) */ 208: i_2 attoff; /*offset in tuple (no. of bytes*/ 209: i_1 attfrmt; /* INT, FLOAT, CHAR (in symbol.h) */ 210: i_1 attfrml; /* unsigned integer no of bytes */ 211: i_1 attxtra; /* flag indicating whether this dom is part of a key */ 212: }; 213: 214: /* 215: ** DESCRIPTOR struct 216: ** 217: ** The DESCRIPTOR struct is initialized by OPENR to describe any 218: ** open relation. The first part of the descriptor is the tuple 219: ** from the RELATION relation. The remainder contains some magic 220: ** numbers and a template initialized from the ATTRIBUTE relation. 221: */ 222: 223: struct descriptor 224: { 225: c_12 relid[MAXNAME]; /* relation name */ 226: c_2 relowner[2]; /* code of relation owner */ 227: i_1 relspec; /* storage mode of relation */ 228: /* M_HEAP unsorted paged heap */ 229: /* -M_HEAP compressed heap */ 230: /* M_ISAM isam */ 231: /* -M_ISAM compressed isam */ 232: /* M_HASH hashed */ 233: /* -M_HASH compressed hash */ 234: i_1 relindxd; /* -1 rel is an index, 0 not indexed, 1 indexed */ 235: i_2 relstat; /* relation status bits */ 236: i_4 relsave; /*unix time until which relation is saved*/ 237: i_4 reltups; /*number of tuples in relation */ 238: i_2 relatts; /*number of attributes in relation */ 239: i_2 relwid; /*width (in bytes) of relation */ 240: i_4 relprim; /*no. of primary pages in relation*/ 241: i_4 relspare; /*not used yet*/ 242: /*the above part of the descriptor struct is identical 243: to the relation struct and the information in this 244: part of the struct is read directly from the 245: relation tuple by openr. the rest of the descriptor 246: struct is calculated by openr. 247: */ 248: i_2 relfp; /*filep for relation , if open */ 249: i_2 relopn; /*indicates if relation is really open*/ 250: i_4 reltid; /*when relation is open, this indicates 251: the tid in the relation relation for 252: this relation */ 253: i_4 reladds; /*no. of additions of tuples during this open*/ 254: i_2 reloff[MAXDOM]; /*reloff[i] is offset to domain i */ 255: c_1 relfrmt[MAXDOM]; /* format of domain i 256: ** INT, FLOAT, or CHAR */ 257: c_1 relfrml[MAXDOM]; /* relfrml[i] is an unsigned integer 258: which indicates length 259: in bytes of domain 260: */ 261: c_1 relxtra[MAXDOM]; /*relxtra[i] is none zero if domain i is 262: ** a key domain for the relation */ 263: c_1 relgiven[MAXDOM]; /*cleared by openr and set before 264: call to find to indicate value of this 265: domain has been supplied in the key*/ 266: }; 267: 268: # define NOKEY 1 /* scan entire relation */ 269: # define EXACTKEY 2 270: # define LRANGEKEY 3 /* low range key */ 271: # define FULLKEY 4 /* forces full key comparison */ 272: # define HRANGEKEY 5 /* high range key */ 273: 274: /* 275: ** tuple id struct 276: */ 277: 278: struct tup_id 279: { 280: char pg1, pg0; 281: char line_id, pg2; 282: };