1: # include "../ingres.h" 2: # include "../access.h" 3: # include "../symbol.h" 4: 5: /* 6: ** Routine associated with getting a tuple out of 7: ** the current buffer. 8: */ 9: 10: get_tuple(dx, tid, tuple) 11: struct descriptor *dx; 12: struct tup_id *tid; 13: char *tuple; 14: 15: /* 16: ** Get_tuple - take the tuple specified 17: ** by tid and move it to "tuple" 18: */ 19: 20: { 21: register struct descriptor *d; 22: register char *cp; 23: char *get_addr(); 24: 25: d = dx; 26: 27: cp = get_addr(tid); 28: 29: if (d->relspec < 0) 30: uncomp_tup(d, cp, tuple); /* compressed tuple */ 31: else 32: bmove(cp, tuple, d->relwid); /* uncompressed tuple */ 33: } 34: 35: 36: char *getint_tuple(dx, tid, tuple) 37: struct descriptor *dx; 38: struct tup_id *tid; 39: char *tuple; 40: 41: /* 42: ** Getint_tuple - get the tuple specified by 43: ** tid. If possible avoid moving the tuple. 44: ** Return value is address of tuple. 45: */ 46: 47: { 48: register struct descriptor *d; 49: register char *cp, *ret; 50: char *get_addr(); 51: 52: d = dx; 53: 54: cp = get_addr(tid); 55: 56: if (d->relspec < 0) 57: { 58: ret = tuple; 59: uncomp_tup(d, cp, ret); /* compressed tuple */ 60: } 61: else 62: ret = cp; /* uncompressed tuple */ 63: return (ret); 64: } 65: 66: 67: char *get_addr(tidx) 68: struct tup_id *tidx; 69: 70: /* 71: ** Routine to compute the address of a tuple 72: ** within the current buffer. 73: ** Syserr if specified tuple deleted. 74: */ 75: 76: { 77: register struct tup_id *tid; 78: register int offset; 79: 80: tid = tidx; 81: 82: offset = Acc_head->linetab[-(tid->line_id & I1MASK)]; 83: if (offset == 0) 84: { 85: syserr("get_addr %s", locv(Acc_head->rel_tupid)); 86: } 87: return (&((struct raw_accbuf *)Acc_head)->acc_buf[offset]); 88: } 89: 90: 91: 92: uncomp_tup(dx, cp, tuple) 93: struct descriptor *dx; 94: char *cp; 95: char *tuple; 96: 97: /* 98: ** Uncompress - decompress the tuple at address cp 99: ** according to descriptor. 100: */ 101: 102: { 103: register struct descriptor *d; 104: register char *src, *dst; 105: int i, j; 106: 107: d = dx; 108: dst = tuple; 109: src = cp; 110: 111: /* for each domain, copy and blank pad if char */ 112: for (i = 1; i <= d->relatts; i++) 113: { 114: j = d->relfrml[i] & I1MASK; 115: if (d->relfrmt[i] == CHAR) 116: { 117: while (j--) 118: { 119: if ((*dst++ = *src++) == NULL) 120: { 121: /* back up one */ 122: dst--; 123: j++; 124: break; 125: } 126: } 127: 128: /* blank pad if necessary */ 129: while (j-- > 0) 130: *dst++ = ' '; 131: } 132: else 133: { 134: while (j--) 135: *dst++ = *src++; 136: } 137: } 138: } 139: 140: 141: invalid(tidx) 142: struct tup_id *tidx; 143: 144: /* 145: ** Check if a line number is valid. 146: ** If linenumber is illegal return AMINVL_ERR 147: ** if Line has been deleted return 2 148: ** else return 0 149: */ 150: 151: { 152: register struct tup_id *tid; 153: register int i; 154: 155: tid = tidx; 156: 157: i = tid->line_id & I1MASK; 158: 159: if (i >= Acc_head->nxtlino) 160: return (acc_err(AMINVL_ERR)); 161: 162: if (Acc_head->linetab[-i] == 0) 163: return (2); 164: 165: return (0); 166: }