# 2.11BSD#431 - /usr/ingres/source/decomp/rnum.c

##### Functions

    rnum_alloc        X
    rnum_assign       X
    rnum_convert      X
    rnum_init         X
    rnum_last         X
    rnum_remove       X
    rnum_temp         X

##### Variables

    Name_table        X
    Num_used          X

##### Macros

    FIRSTNUM          X
    LASTNUM           X

       1: # include   "../ingres.h"
       2: # include   "decomp.h"
       3:
       4: # define    FIRSTNUM    MAXRANGE + 3
       5: # define    LASTNUM     100
       6:
       7: /*
       8: **	Internal numbers are used in decomp to
       9: **	represent relation names. The numbers
      10: **	from 0 to FIRSTNUM-1 refer to the names
      11: **	stored in Name_table[].
      12: **
      13: **	The number from FIRSTNUM to LASTNUM have
      14: **	names which are computed from aa, ab, etc.
      15: */
      16: char    Name_table[FIRSTNUM-1][MAXNAME];
      17:
      18: char    Num_used[LASTNUM+1];
      19:
      20:
      21: rnum_assign(name)
      22: char    *name;
      23:
      24: /*
      25: **	Assign an internal number rnum to name.
      26: */
      27:
      28: {
      29:     register int    i;
      30:
      31:     for (i = 0; i < FIRSTNUM; i++)
      32:         if (Num_used[i] == 0)
      33:         {
      34:             bmove(name, Name_table[i], MAXNAME);
      35:             Num_used[i]++;
      36:             return (i);
      37:         }
      38:     syserr("rnum_assign:no room");
      39: }
      40:
      41: rnum_alloc()
      42:
      43: /*
      44: **	Allocate the next available name
      45: */
      46:
      47: {
      48:     register int    i;
      49:     register char   *cp;
      50:
      51:     cp = &Num_used[FIRSTNUM];
      52:     for (i = FIRSTNUM; i < LASTNUM; i++)
      53:         if (*cp++ == 0)
      54:         {
      55:             --cp;
      56:             (*cp)++;
      57:             return (i);
      58:         }
      59:     syserr("no free names");
      60: }
      61:
      62:
      63: char *rnum_convert(num)
      64: int num;
      65:
      66: /*
      67: **	Convert internal relation number
      68: **	to its real name. Guarantee '\0' at end.
      69: */
      70:
      71: {
      72:     register int    i;
      73:     register char   *ret, *cp;
      74:     static char temp[MAXNAME+1];
      75:     extern char *Fileset;
      76:     extern char *concat();
      77:
      78:     i = num;
      79:     if (i > LASTNUM || Num_used[i] == 0)
      80:         syserr("no name for %d", i);
      81:
      82:     ret = temp;
      83:
      84:     if (i < FIRSTNUM)
      85:     {
      86:         bmove(Name_table[i], ret, MAXNAME);
      87:     }
      88:     else
      89:     {
      90:         /* compute temp name */
      91:         cp = concat("_SYS", Fileset, ret);
      92:         pad(ret, MAXNAME);
      93:         i -= FIRSTNUM;
      94:         *cp++ = i/26 + 'a';
      95:         *cp = i%26 + 'a';
      96:     }
      97:     return (ret);
      98: }
      99:
     100: rnum_remove(num)
     101: int num;
     102:
     103: /*
     104: **	Remove a num from the used list
     105: */
     106:
     107: {
     108:     register int    i;
     109:     register char   *cp;
     110:
     111:     cp = &Num_used[num];
     112:
     113:     if (*cp == 0)
     114:         syserr("cant remove %d", num);
     115:     *cp = 0;
     116: }
     117:
     118:
     119: rnum_last()
     120:
     121: /*
     122: **	returns number of largest assigned temp number.
     123: **	zero if none
     124: */
     125:
     126: {
     127:     register int    i;
     128:     register char   *cp;
     129:
     130:     for (i = LASTNUM; i >= FIRSTNUM; i--)
     131:         if (Num_used[i])
     132:             return (i);
     133:
     134:     return (0);
     135: }
     136:
     137:
     138: rnum_temp(rnum)
     139: int rnum;
     140:
     141: /*
     142: **	Predicate to check whether rnum is a temporary relation or not
     143: */
     144:
     145: {
     146:     register int    i;
     147:
     148:     i = rnum;
     149:
     150:     return (i >= FIRSTNUM || bequal("_SYS", rnum_convert(i), 4));
     151: }
     152:
     153: rnum_init()
     154:
     155: /*
     156: **	Clear tag fields from previous query
     157: */
     158:
     159: {
     160:     register char   *cp;
     161:     register int    i;
     162:
     163:     cp = Num_used;
     164:     i = FIRSTNUM;
     165:     while (--i)
     166:         *cp++ = 0;
     167: }

#### Defined functions

rnum_alloc defined in line 41; used 3 times

- in /usr/ingres/source/decomp/byeval.c line 83
- in /usr/ingres/source/decomp/reformat.c line 429
- in /usr/ingres/source/decomp/usubr.c line 212

rnum_assign defined in line 21; used 2 times

- in /usr/ingres/source/decomp/call_ovqp70.c line 384
- in /usr/ingres/source/decomp/readq.c line 69

rnum_convert defined in line 63; used 20 times

- in line 150
- in /usr/ingres/source/decomp/byeval.c line 84, 102, 222
- in /usr/ingres/source/decomp/call_ovqp.c line 76, 112
- in /usr/ingres/source/decomp/call_ovqp70.c line 91
- in /usr/ingres/source/decomp/exec_sq.c line 197
- in /usr/ingres/source/decomp/openrs.c line 173, 180-181(2), 218, 348, 383
- in /usr/ingres/source/decomp/rangetable.c line 149-151(2)
- in /usr/ingres/source/decomp/reformat.c line 430
- in /usr/ingres/source/decomp/usubr.c line 163-167(2), 213

rnum_init defined in line 153; used 2 times

- in /usr/ingres/source/decomp/call_ovqp.c line 380
- in /usr/ingres/source/decomp/call_ovqp70.c line 410

rnum_last defined in line 119; used 1 times

- in /usr/ingres/source/decomp/openrs.c line 145

rnum_remove defined in line 100; used 1 times

- in /usr/ingres/source/decomp/usubr.c line 174

rnum_temp defined in line 138; used 2 times

- in /usr/ingres/source/decomp/reformat.c line 237
- in /usr/ingres/source/decomp/usubr.c line 165

#### Defined variables

Name_table defined in line 16; used 2 times

- in line 34, 86

Num_used defined in line 18; used 7 times

- in line 32-35(2), 51, 79, 111, 131, 163

#### Defined macros

FIRSTNUM defined in line 4; used 9 times

- in line 16, 31, 51-52(2), 84, 93, 130, 150, 164

LASTNUM defined in line 5; used 4 times

- in line 18, 52, 79, 130

Last modified: 1995-04-14 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1151 |