1: # include <ingres.h>
2: # include <access.h>
3: # include <symbol.h>
4: # include <catalog.h>
5: # include <btree.h>
6: # include <sccs.h>
7:
8: SCCSID(@(#)get_tuple.c 8.2 2/8/85)
9:
10: /*
11: ** Routine associated with getting a tuple out of
12: ** the current buffer.
13: */
14:
15:
16: /*
17: ** Get_tuple - take the tuple specified
18: ** by tid and move it to "tuple"
19: */
20:
21: get_tuple(d, tid, tuple)
22: register DESC *d;
23: TID *tid;
24: char *tuple;
25: {
26: register char *cp;
27: char *get_addr();
28: TID tidloc;
29: char lid[MAXLID * LIDSIZE];
30: extern DESC Btreesec;
31: extern int Btree_fd;
32:
33: cp = get_addr(tid);
34:
35: if (d->reldum.relspec < 0)
36: uncomp_tup(d, cp, tuple); /* compressed tuple */
37: else
38: {
39: if (d->reldum.reldim == 0)
40: bmove(cp, tuple, d->reldum.relwid); /* uncompressed tuple */
41: else
42: /* ignore lid field for now */
43: bmove(cp, tuple, d->reldum.relwid - d->reldum.reldim * LIDSIZE);
44: }
45:
46: if (d->reldum.reldim > 0)
47: /* find corresponding lid value given main relation tid */
48: {
49: bmove(d->relbtree, &Btreesec, sizeof(Btreesec));
50: Btree_fd = d->btree_fd;
51: search_btree(*tid, &tidloc);
52: get_lid(&tidloc, lid);
53: /* attach lid value to end of tuple */
54: cp = tuple + d->reldum.relwid - d->reldum.reldim * LIDSIZE;
55: bmove(lid, cp, d->reldum.reldim * LIDSIZE);
56: }
57: }
58: /*
59: ** Getint_tuple - get the tuple specified by
60: ** tid. If possible avoid moving the tuple.
61: ** Return value is address of tuple.
62: */
63:
64: char *
65: getint_tuple(d, tid, tuple)
66: register DESC *d;
67: TID *tid;
68: char *tuple;
69: {
70: register char *cp, *ret;
71: extern char *get_addr();
72: TID tidloc;
73: char lid[MAXLID * LIDSIZE];
74: extern DESC Btreesec;
75: extern int Btree_fd;
76:
77: cp = get_addr(tid);
78:
79: if (d->reldum.relspec < 0)
80: {
81: ret = tuple;
82: uncomp_tup(d, cp, ret); /* compressed tuple */
83: }
84: else if (d->reldum.reldim == 0)
85: ret = cp; /* uncompressed tuple */
86: else
87: {
88: /* ignore lid field for now */
89: ret = tuple;
90: bmove(cp, tuple, d->reldum.relwid - d->reldum.reldim * LIDSIZE);
91: }
92: if (d->reldum.reldim > 0)
93: {
94: bmove(d->relbtree, &Btreesec, sizeof(Btreesec));
95: Btree_fd = d->btree_fd;
96: /* find corresponding lid value */
97: search_btree(*tid, &tidloc);
98: get_lid(&tidloc, lid);
99: /* attach lid value to end of tuple */
100: cp = ret + d->reldum.relwid - d->reldum.reldim * LIDSIZE;
101: bmove(lid, cp, d->reldum.reldim * LIDSIZE);
102: }
103: return (ret);
104: }
105: /*
106: ** Routine to compute the address of a tuple
107: ** within the current buffer.
108: ** Syserr if specified tuple deleted.
109: */
110:
111: char *
112: get_addr(tid)
113: register TID *tid;
114: {
115: register int offset;
116:
117: offset = Acc_head->linetab[-(tid->line_id & I1MASK)];
118: if (offset == 0)
119: {
120: syserr("get_addr rel=%ld tid=%ld", Acc_head->rel_tupid, *(long *)tid);
121: }
122: # ifdef xATR3
123: if (offset < 0 || offset > PGSIZE)
124: syserr("get_addr: offset=%d\n");
125: # endif
126: return (((char *) Acc_head) + offset);
127: }
128: /*
129: ** Uncompress - decompress the tuple at address cp
130: ** according to descriptor.
131: */
132:
133: uncomp_tup(d, cp, tuple)
134: register DESC *d;
135: char *cp;
136: char *tuple;
137: {
138: register char *src, *dst;
139: int i, j, numatts;
140:
141: dst = tuple;
142: src = cp;
143:
144: /* for each domain, copy and blank pad if char */
145: /* ignore lid field */
146: numatts = d->reldum.relatts - d->reldum.reldim;
147: for (i = 1; i <= numatts; i++)
148: {
149: j = d->relfrml[i] & I1MASK;
150: if (d->relfrmt[i] == CHAR)
151: {
152: while (j--)
153: {
154: if ((*dst++ = *src++) == NULL)
155: {
156: /* back up one */
157: dst--;
158: j++;
159: break;
160: }
161: }
162:
163: /* blank pad if necessary */
164: while (j-- > 0)
165: *dst++ = ' ';
166: }
167: else
168: {
169: while (j--)
170: *dst++ = *src++;
171: }
172: }
173: }
174: /*
175: ** Check if a line number is valid.
176: ** If linenumber is illegal return AMINVL_ERR
177: ** if Line has been deleted return DELTUP
178: ** else return 0
179: */
180:
181: invalid(tid)
182: register TID *tid;
183: {
184: register int i;
185:
186: i = tid->line_id & I1MASK;
187:
188: if (i >= Acc_head->nxtlino)
189: return (acc_err(AMINVL_ERR));
190:
191: if (Acc_head->linetab[-i] == 0)
192: return (DELTUP);
193:
194: return (0);
195: }
Defined functions
get_addr
defined in line
111; used 15 times
- in line 27,
33,
71,
77
- in /usr/ingres/source/iutil/bndxsearch.c line
67,
117,
151,
185
- in /usr/ingres/source/iutil/del_tuple.c line
22,
31
- in /usr/ingres/source/iutil/ndxsearch.c line
55,
98,
123
- in /usr/ingres/source/iutil/put_tuple.c line
31,
42