1: # include   "../ingres.h"
   2: # include   "decomp.h"
   3: 
   4: /*
   5: ** Allocation of range table.
   6: ** The size of the range table for decomp is
   7: ** MAXRANGE plus 2; 1 for a free aggregate slot and 1 for
   8: ** a free secondary index slot.
   9: */
  10: struct rang_tab Rangev[MAXRANGE+2]; /* global range table with extra slot for FREEVAR and SECINDXVAR */
  11: 
  12: 
  13: 
  14: initrange()
  15: {
  16:     register struct rang_tab    *rt;
  17: 
  18:     for (rt = Rangev; rt <= &Rangev[MAXRANGE+1]; rt++)
  19:         rt->relnum = -1;
  20: }
  21: 
  22: 
  23: savrang(locrang, var)
  24: int     locrang[];
  25: int     var;
  26: 
  27: /*
  28: **	Save the entry for var in the range table.
  29: */
  30: 
  31: {
  32:     register int    i;
  33: 
  34:     i = var;
  35:     locrang[i] = Rangev[i].relnum;
  36: }
  37: 
  38: rstrang(locrang, var)
  39: int     locrang[];
  40: int     var;
  41: 
  42: /*
  43: **	Restore the entry for var from the local range
  44: **	table locrang.
  45: */
  46: 
  47: {
  48:     register int    i;
  49: 
  50:     i = var;
  51:     Rangev[i].relnum = locrang[i];
  52: }
  53: 
  54: 
  55: 
  56: new_range(var, relnum)
  57: int var;
  58: int relnum;
  59: 
  60: /*
  61: **	Update the range name. It is up to
  62: **	the calling routine to openr the new rel.
  63: */
  64: 
  65: {
  66:     register int    i, old;
  67: 
  68:     i = var;
  69: 
  70:     old = Rangev[i].relnum;
  71:     Rangev[i].relnum = relnum;
  72: 
  73:     return (old);
  74: }
  75: 
  76: 
  77: newquery(locrang)
  78: int locrang[];
  79: 
  80: /*
  81: **	Make a copy of the current range table.
  82: */
  83: 
  84: {
  85:     register struct rang_tab    *rp;
  86:     register int            *ip, i;
  87: 
  88:     ip = locrang;
  89:     rp = Rangev;
  90: 
  91:     for (i = 0; i < MAXRANGE; i++)
  92:         *ip++ = (rp++)->relnum;
  93: }
  94: 
  95: 
  96: endquery(locrang, reopen)
  97: int locrang[];
  98: int reopen;
  99: 
 100: /*
 101: **	Check the range table to see if any
 102: **	relations changed since the last call
 103: **	to newquery. If so, they were caused
 104: **	by reformat. Restore back the orig relation
 105: **	Reopen it if reopen == TRUE.
 106: */
 107: 
 108: {
 109:     register struct rang_tab    *rp;
 110:     register int            *ip, i;
 111:     int             old;
 112: 
 113:     rp = Rangev;
 114:     ip = locrang;
 115: 
 116:     initp();
 117:     for (i = 0; i < MAXRANGE; i++)
 118:     {
 119:         if (rp->relnum != *ip)
 120:         {
 121: #			ifdef xDTR1
 122:             if (tTf(15, -1))
 123:             printf("reformat or reduct changed var %d (%d,%d)\n", i, *ip, rp->relnum);
 124: #			endif
 125: 
 126:             old = new_range(i, *ip);
 127:             dstr_mark(old);
 128:             if (reopen)
 129:                 openr1(i);
 130:         }
 131: 
 132:         ip++;
 133:         rp++;
 134:     }
 135: 
 136:     dstr_flush(0);
 137: }
 138: 
 139: 
 140: char *rangename(var)
 141: int var;
 142: 
 143: /*
 144: **	Return the name of the variable "var"
 145: **	in the range table
 146: */
 147: 
 148: {
 149:     char    *rnum_convert();
 150: 
 151:     return (rnum_convert(Rangev[var].relnum));
 152: }

Defined functions

rstrang defined in line 38; used 1 times

Defined variables

Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1356
Valid CSS Valid XHTML 1.0 Strict