Annotation of 43BSD/ingres/source/iutil/put_tuple.c, revision 1.1.1.1

1.1       root        1: # include      <ingres.h>
                      2: # include      <symbol.h>
                      3: # include      <access.h>
                      4: # include      <catalog.h>
                      5: # include      <sccs.h>
                      6: 
                      7: SCCSID(@(#)put_tuple.c 8.1     12/31/84)
                      8: 
                      9: 
                     10: 
                     11: char   *Acctuple;
                     12: char   Accanon[MAXTUP];
                     13: 
                     14: 
                     15: /*
                     16: **  PUT_TUPLE
                     17: **
                     18: **     Put the canonical tuple in the position
                     19: **     on the current page specified by tid
                     20: **
                     21: **     Trace Flags:
                     22: **             27.3-5
                     23: */
                     24: 
                     25: put_tuple(tid, tuple, length)
                     26: TID    *tid;
                     27: char   *tuple;
                     28: int    length;
                     29: {
                     30:        register char   *tp;
                     31:        char            *get_addr();
                     32: 
                     33: #      ifdef xATR2
                     34:        if (tTf(27, 3))
                     35:        {
                     36:                printf("put_tuple:len=%d,", length);
                     37:                dumptid(tid);
                     38:        }
                     39: #      endif
                     40: 
                     41:        /* get address in buffer */
                     42:        tp = get_addr(tid);
                     43: 
                     44:        /* move the tuple */
                     45:        bmove(tuple, tp, length);
                     46: 
                     47:        /* mark page as dirty */
                     48:        Acc_head->bufstatus |= BUF_DIRTY;
                     49: }
                     50: /*
                     51: **  CANONICAL
                     52: **
                     53: **     Make the tuple canonical and return the length
                     54: **     of the tuple.
                     55: **
                     56: **     If the relation is compressed then the tuple in
                     57: **     compressed into the global area Accanon.
                     58: **
                     59: **     As a side effect, the address of the tuple to be
                     60: **     inserted is placed in Acctuple.
                     61: **
                     62: **     returns: length of canonical tuple
                     63: **
                     64: **     Trace Flags:
                     65: **             27.6, 7
                     66: */
                     67: 
                     68: canonical(d, tuple)
                     69: register DESC  *d;
                     70: register char  *tuple;
                     71: {
                     72:        register int    i;
                     73: 
                     74:        if (d->reldum.relspec < 0)
                     75:        {
                     76:                /* compress tuple */
                     77:                i = comp_tup(d, tuple);
                     78:                Acctuple = Accanon;
                     79:        }
                     80:        else
                     81:        {
                     82:                Acctuple = tuple;
                     83:                /* ignore lid field */
                     84:                i = d->reldum.relwid - 4 * d->reldum.reldim;
                     85:        }
                     86: #      ifdef xATR3
                     87:        if (tTf(27, 6))
                     88:                printf("canonical: %d\n", i);
                     89: #      endif
                     90:        return (i);
                     91: }
                     92: /*
                     93: **  COMP_TUP
                     94: **
                     95: **     Compress the tuple into Accanon. Compression is
                     96: **     done by copying INT and FLOAT as is.
                     97: **     For CHAR fields, the tuple is copied until a null
                     98: **     byte or until the end of the field. Then trailing
                     99: **     blanks are removed and a null byte is inserted at
                    100: **     the end if any trailing blanks were present.
                    101: */
                    102: 
                    103: comp_tup(d, src)
                    104: register DESC  *d;
                    105: register char  *src;
                    106: {
                    107:        register char   *dst;
                    108:        char            *save;
                    109:        char            *domlen, *domtype;
                    110:        int             i, j, len, numatts;
                    111: 
                    112:        dst = Accanon;
                    113: 
                    114:        domlen = &d->relfrml[1];
                    115:        domtype = &d->relfrmt[1];
                    116: 
                    117:        /* ignore lid field */
                    118:        numatts = d->reldum.relatts - d->reldum.reldim;
                    119:        for (i = 1; i <= numatts; i++)
                    120:        {
                    121:                len = *domlen++ & I1MASK;
                    122:                if (*domtype++ == CHAR)
                    123:                {
                    124:                        save = src;
                    125:                        for (j = 1; j <= len; j++)
                    126:                        {
                    127:                                if ((*dst++ = *src++) == NULL)
                    128:                                {
                    129:                                        dst--;
                    130:                                        break;
                    131:                                }
                    132:                        }
                    133: 
                    134:                        while (j--)
                    135:                                if (*--dst != ' ')
                    136:                                        break;
                    137: 
                    138:                        if (j != len)
                    139:                                *++dst = NULL;
                    140: 
                    141:                        dst++;
                    142:                        src = save + len;
                    143:                }
                    144:                else
                    145:                {
                    146:                        while (len--)
                    147:                                *dst++ = *src++;
                    148: 
                    149:                }
                    150:        }
                    151:        return (dst - Accanon);
                    152: }
                    153: /*
                    154: **  SPACE_LEFT
                    155: **
                    156: **     Determine how much space remains on the page in
                    157: **     the current buffer. Included in computation
                    158: **     is the room for an additional line number
                    159: */
                    160: 
                    161: space_left(bp)
                    162: register struct accbuf *bp;
                    163: {
                    164:        register int    nextoff;
                    165:        register int    i;
                    166:        register short  *pp;
                    167: 
                    168:        nextoff = bp->nxtlino;
                    169: #      ifdef xATR3
                    170:        if (nextoff < 0 || nextoff > PGSIZE)
                    171:                syserr("space_left: nextoff=%d", nextoff);
                    172: #      endif
                    173: 
                    174:        /* compute space left on page */
                    175:        pp = &bp->linetab[-nextoff];
                    176:        i = PGSIZE - *pp - (nextoff + 2) * 2;
                    177: 
                    178:        /* see if there is also a free line number */
                    179:        if (nextoff < MAXLINENO)
                    180:                return (i);
                    181:        while (++pp <= &bp->linetab[0])
                    182:                if (*pp == 0)
                    183:                        return (i);
                    184:        return (0);
                    185: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.