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