1: # include   <ingres.h>
   2: # include   <aux.h>
   3: # include   <tree.h>
   4: # include   <symbol.h>
   5: # include   <access.h>
   6: # include   <pv.h>
   7: # include   "globs.h"
   8: # include   <sccs.h>
   9: 
  10: SCCSID(@(#)usubr.c	8.1	12/31/84)
  11: 
  12: 
  13: /*
  14: **	usubr.c
  15: **
  16: **	utility routines to handle setting up params, etc for DBU calls
  17: */
  18: 
  19: 
  20: 
  21: /*
  22:  *	generate domain names, formats
  23:  */
  24: domnam(lnp, pre)
  25: QTREE   **lnp;
  26: char    *pre;
  27: {
  28: 
  29:     register char   suf, *n;
  30:     char        name[MAXNAME];
  31:     char        *getformat();
  32:     register QTREE  **p;
  33: 
  34:     suf = '1';
  35:     for (n=name; *n++= *pre++;);
  36:     *n = '\0';
  37:     n--;
  38:     for (p = lnp; *p != NULL; p++)
  39:     {
  40:         *n = suf++;
  41:         setp(PV_STR, name);
  42:         setp(PV_STR, getformat(*p));
  43:     }
  44: }
  45: /*
  46: **	gets format in ascii from RESDOM or AOP node
  47: */
  48: static char *
  49: getformat(p)
  50: QTREE   *p;
  51: {
  52: 
  53:     static char buf[10];
  54:     register char   *b;
  55: 
  56:     b = buf;
  57: 
  58:     *b++ = p->sym.value.sym_op.opfrmt;
  59:     itoa(p->sym.value.sym_op.opfrml & I1MASK, b);
  60:     return(buf);
  61: }
  62: /*
  63: **	makes list of nodes (depth first)
  64: */
  65: 
  66: lnode(nod, lnodv, count)
  67: QTREE   *nod, *lnodv[];
  68: int count;
  69: {
  70:     register QTREE  *q;
  71:     register int    i;
  72: 
  73:     i = count;
  74:     q = nod;
  75: 
  76:     if (q && q->sym.type != TREE)
  77:     {
  78:         i = lnode(q->left, lnodv, i);
  79:         lnodv[i++] = q;
  80:     }
  81:     return(i);
  82: }
  83: /*
  84: **	Immediately destroys the relation if it is an _SYS
  85: */
  86: 
  87: dstr_rel(relnum)
  88: int relnum;
  89: {
  90:     initp();
  91:     if (dstr_mark(relnum))
  92:         call_dbu(mdDESTROY, FALSE);
  93:     else
  94:         resetp();
  95: }
  96: /*
  97: **	Put relation on list of relations to be
  98: **	destroyed. A call to initp() must be
  99: **	made before any calls to dstr_mark().
 100: **
 101: **	A call to call_dbu will actually have
 102: **	the relations exterminated
 103: **
 104: **	Trace Flags:
 105: **		65
 106: */
 107: 
 108: dstr_mark(relnum)
 109: int relnum;
 110: {
 111:     register char   *p;
 112:     char        *rnum_convert();
 113:     bool        dstr_flag;
 114: 
 115:     dstr_flag = FALSE;
 116:     if (rnum_temp(relnum))
 117:     {
 118:         p = rnum_convert(relnum);
 119: #		ifdef xDTR1
 120:         if (tTf(65, 4))
 121:             printf("destroying %s\n", p);
 122: #		endif
 123:         setp(PV_STR, p);
 124:         specclose(relnum);  /* guarantee that relation is closed and descriptor destroyed */
 125:         rnum_remove(relnum);
 126:         dstr_flag = TRUE;   /* indicate that there are relations to be destroyed */
 127:     }
 128:     return(dstr_flag);
 129: }
 130: /*
 131: **	Make a temporary relation to match
 132: **	the target list of tree.
 133: **
 134: **	If rnum is positive, use it as the relation number,
 135: **	Otherwise allocate a new one.
 136: */
 137: 
 138: mak_t_rel(tree, prefix, rnum)
 139: QTREE   *tree;
 140: char    *prefix;
 141: int rnum;
 142: {
 143:     QTREE       *lnodv[MAXDOM + 1];
 144:     register int    relnum;
 145: 
 146:     initp();
 147:     setp(PV_STR, "0");  /* initial relstat field */
 148:     relnum = rnum < 0 ? rnum_alloc() : rnum;
 149:     setp(PV_STR, rnum_convert(relnum));
 150:     lnodv[lnode(tree->left, lnodv, 0)] = NULL;
 151:     domnam(lnodv, prefix);
 152: 
 153:     call_dbu(mdCREATE, FALSE);
 154:     return (relnum);
 155: }
 156: 
 157: 
 158: QTREE **
 159: mksqlist(tree, var)
 160: QTREE   *tree;
 161: int var;
 162: {
 163:     register QTREE  **sq;
 164:     register int    i;
 165:     static QTREE    *sqlist[MAXRANGE];
 166: 
 167:     sq = sqlist;
 168:     for (i = 0; i < MAXRANGE; i++)
 169:         *sq++ = 0;
 170: 
 171:     sqlist[var] = tree;
 172:     return (sqlist);
 173: }
 174: 
 175: 
 176: 
 177: 
 178: long
 179: rel_pages(tupcnt, width)
 180: long    tupcnt;
 181: int width;
 182: {
 183:     register int    tups_p_page;
 184: 
 185:     tups_p_page = (PGSIZE - 12) / (width + 2);
 186:     return ((tupcnt + tups_p_page - 1) / tups_p_page);
 187: }
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1158
Valid CSS Valid XHTML 1.0 Strict