1: # include   "../ingres.h"
   2: # include   "../symbol.h"
   3: # include   "../access.h"
   4: 
   5: 
   6: /* tTf flag 87	TTF	put_tuple() */
   7: 
   8: put_tuple(tid, tuple, length)
   9: struct tup_id   *tid;
  10: char        *tuple;
  11: int     length;
  12: 
  13: /*
  14: **	Put the canonical tuple in the position
  15: **	on the current page specified by tid
  16: */
  17: 
  18: {
  19:     register char   *tp;
  20:     char        *get_addr();
  21: 
  22: #	ifdef xATR2
  23:     if (tTf(87, 0))
  24:     {
  25:         printf("put_tuple:len=%d,", length);
  26:         dumptid(tid);
  27:     }
  28: #	endif
  29: 
  30:     /* get address in buffer */
  31:     tp = get_addr(tid);
  32: 
  33:     /* move the tuple */
  34:     bmove(tuple, tp, length);
  35: 
  36:     /* mark page as dirty */
  37:     Acc_head->bufstatus |= BUF_DIRTY;
  38: }
  39: 
  40: 
  41: canonical(dx, tuplex)
  42: struct descriptor   *dx;
  43: char            *tuplex;
  44: 
  45: /*
  46: **	Make the tuple canonical and return the length
  47: **	of the tuple.
  48: **
  49: **	If the relation is compressed then the tuple in
  50: **	compressed into the global area Accanon.
  51: **
  52: **	As a side effect, the address of the tuple to be
  53: **	inserted is placed in Acctuple.
  54: **
  55: **	returns: length of canonical tuple
  56: */
  57: 
  58: {
  59:     register struct descriptor  *d;
  60:     register char           *tuple;
  61:     register int            i;
  62: 
  63:     d = dx;
  64:     tuple = tuplex;
  65: 
  66:     if (d->relspec < 0)
  67:     {
  68:         /* compress tuple */
  69:         i = comp_tup(d, tuple);
  70:         Acctuple = Accanon;
  71:     }
  72:     else
  73:     {
  74:         Acctuple = tuple;
  75:         i = d->relwid;
  76:     }
  77:     return (i);
  78: }
  79: 
  80: 
  81: comp_tup(dx, tuple)
  82: struct descriptor   *dx;
  83: char            *tuple;
  84: 
  85: /*
  86: **	Compress the tuple into Accanon. Compression is
  87: **	done by copying INT and FLOAT as is.
  88: **	For CHAR fields, the tuple is copied until a null
  89: **	byte or until the end of the field. Then trailing
  90: **	blanks are removed and a null byte is inserted at
  91: **	the end if any trailing blanks were present.
  92: */
  93: 
  94: {
  95:     register struct descriptor  *d;
  96:     register char           *src, *dst;
  97:     char                *save;
  98:     char                *domlen, *domtype;
  99:     int             i, j, len;
 100: 
 101:     src = tuple;
 102:     d = dx;
 103:     dst = Accanon;
 104: 
 105:     domlen = &d->relfrml[1];
 106:     domtype = &d->relfrmt[1];
 107: 
 108:     for (i = 1; i <= d->relatts; i++)
 109:     {
 110:         len = *domlen++ & I1MASK;
 111:         if (*domtype++ == CHAR)
 112:         {
 113:             save = src;
 114:             for (j = 1; j <= len; j++)
 115:             {
 116:                 if ((*dst++ = *src++) == NULL)
 117:                 {
 118:                     dst--;
 119:                     break;
 120:                 }
 121:             }
 122: 
 123:             while (j--)
 124:                 if (*--dst != ' ')
 125:                     break;
 126: 
 127:             if (j != len)
 128:                 *++dst = NULL;
 129: 
 130:             dst++;
 131:             src = save + len;
 132:         }
 133:         else
 134:         {
 135:             while (len--)
 136:                 *dst++ = *src++;
 137: 
 138:         }
 139:     }
 140:     return (dst - Accanon);
 141: }
 142: 
 143: 
 144: space_left(bp)
 145: struct accbuf   *bp;
 146: 
 147: /*
 148: **	Determine how much space remains on the page in
 149: **	the current buffer. Included in computation
 150: **	is the room for an additional line number
 151: */
 152: 
 153: {
 154:     register int        nextoff;
 155:     register struct accbuf  *buf;
 156: 
 157:     buf = bp;
 158: 
 159:     nextoff = buf->nxtlino;
 160: 
 161:     return (PGSIZE - buf->linetab[-nextoff] - (nextoff + 2) * 2);
 162: }
Last modified: 1995-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 652
Valid CSS Valid XHTML 1.0 Strict