1: # include   <ingres.h>
   2: # include   <aux.h>
   3: # include   <tree.h>
   4: # include   <symbol.h>
   5: # include   "globs.h"
   6: # include   <pv.h>
   7: # include   <lock.h>
   8: # include   <resp.h>
   9: # include   <sccs.h>
  10: # include   <errors.h>
  11: 
  12: SCCSID(@(#)qryproc.c	8.4	12/18/85)
  13: 
  14: /* Control Module configuration information structure */
  15: 
  16: extern  int de_init();
  17: extern  int de_rubproc();
  18: extern  int qryproc();
  19: 
  20: struct fn_def   DeOvqpFn =
  21: {
  22:     "DECOMP/OVQP",
  23:     qryproc,
  24:     de_init,
  25:     de_rubproc,
  26:     (char *) &De,
  27:     sizeof De,
  28:     tTdecomp,
  29:     100,
  30:     'D',
  31:     0,
  32: };
  33: 
  34: /*ARGSUSED*/
  35: qryproc(pc, pv)
  36: int pc;
  37: PARM    *pv;
  38: {
  39:     register QTREE  *root, *q;
  40:     register int    i;
  41:     int     mode, result_num, retr_uniq;
  42:     extern long Accuread, Accuwrite, Accusread;
  43:     extern int  derror();
  44:     int     loc_qbuf[1+QBUFSIZ/sizeof(int)];
  45: 
  46: #	ifdef xDTR1
  47:     if (tTf(50, 0))
  48:     {
  49:         Accuread = 0;
  50:         Accusread = 0;
  51:         Accuwrite = 0;
  52:     }
  53: #	endif
  54: 
  55:     De.de_qbuf = (char *)loc_qbuf;
  56:     initbuf((char *)loc_qbuf, QBUFSIZ, QBUFFULL, derror);
  57: 
  58:     /* init various variables in decomp for start of this query */
  59:     startdecomp();
  60: 
  61:     /* Read in query, range table and mode */
  62:     if (pv[0].pv_type != PV_QTREE)
  63:         syserr("qryproc: bad parameter");
  64:     root = pv[0].pv_val.pv_qtree;
  65:     /* a john fix (below)
  66: 	root->sym.value.sym_root.rootuser = TRUE; */
  67: #	ifdef xDTR1
  68:     if (tTf(50, 4))
  69:     {
  70:         printf("qryproc\n");
  71:         treepr(root);
  72:     }
  73: # 	endif
  74: 
  75:     /* initialize qt parameters */
  76:     mode = De.de_qmode = Qt.qt_qmode;
  77:     De.de_resultvar = Qt.qt_resvar;
  78: 
  79:     /*
  80: 	** Initialize range table. This code should eventually
  81: 	** be changed to take advantage of the fact that all
  82: 	** the openrs are already done by the control module.
  83: 	*/
  84: 
  85:     for (i = 0; i < MAXRANGE; i++)
  86:     {
  87:         if (Qt.qt_rangev[i].rngvdesc != NULL)
  88:         {
  89:             De.de_rangev[i].relnum = rnum_assign(Qt.qt_rangev[i].rngvdesc->reldum.relid);
  90: 
  91:         }
  92:     }
  93:     /* Initialize relation descriptors */
  94:     initdesc(mode);
  95: 
  96:     /* locate pointers to QLEND and TREE nodes */
  97:     for (q = root->right; q->sym.type != QLEND; q = q->right)
  98:         continue;
  99:     De.de_qle = q;
 100: 
 101:     for (q = root->left; q->sym.type != TREE; q = q->left)
 102:         continue;
 103:     De.de_tr = q;
 104: 
 105: 
 106:     /* map the complete tree */
 107:     mapvar(root, 0);
 108: 
 109:     /* set logical locks */
 110:     if (Lockrel)
 111:         lockit(root, De.de_resultvar);
 112: 
 113:     /* If there is no result variable then this must be a retrieve to the terminal */
 114:     De.de_qry_mode = De.de_resultvar < 0 ? mdRETTERM : mode;
 115: 
 116:     /* if the mode is retrieve_unique, then make a result rel */
 117:     retr_uniq = mode == mdRET_UNI;
 118:     if (retr_uniq)
 119:     {
 120:         mk_unique(root);
 121:         mode = mdRETR;
 122:     }
 123: 
 124:     /* get id of result relation */
 125:     if (De.de_resultvar < 0)
 126:         result_num = NORESULT;
 127:     else
 128:         result_num = De.de_rangev[De.de_resultvar].relnum;
 129: 
 130:     /* evaluate aggregates in query */
 131:     aggregate(root);
 132: 
 133:     /* decompose and process aggregate free query */
 134:     decomp(root, mode, result_num);
 135: 
 136:     /* If this is a retrieve unique, then retrieve results */
 137:     if (retr_uniq)
 138:         pr_unique(root, De.de_resultvar);
 139: 
 140:     if (mode != mdRETR)
 141:         i = ACK;
 142:     else
 143:         i = NOACK;
 144:     i = endovqp(i);
 145: 
 146: #	ifdef xDTR1
 147:     if (tTf(50, 1))
 148:     {
 149:         printf("DECOMP read %ld pages,", Accuread);
 150:         printf("%ld catalog pages,", Accusread);
 151:         printf("wrote %ld pages\n", Accuwrite);
 152:     }
 153: #	endif
 154: 
 155:     /* call update processor if batch mode */
 156:     if (i == UPDATE)
 157:     {
 158:         initp();
 159:         call_dbu(mdUPDATE, -1);
 160:     }
 161: 
 162: 
 163:     /* clean decomp */
 164:     reinit();
 165: 
 166:     if (i != UPDATE)
 167:         Resp.resp_tups = De.ov_tupsfound;
 168: 
 169:     return (0);
 170: }

Defined functions

qryproc defined in line 35; used 2 times

Defined variables

DeOvqpFn defined in line 20; never used
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1034
Valid CSS Valid XHTML 1.0 Strict