1: # include   "../ingres.h"
   2: # include   "../tree.h"
   3: # include   "../symbol.h"
   4: # include   "decomp.h"
   5: # include   "../lock.h"
   6: 
   7: int Qry_mode;   /* mode of original query (not nec same as Qmode) */
   8: 
   9: 
  10: qryproc()
  11: {
  12:     register struct querytree   *root, *q;
  13:     register int            i;
  14:     int             mode, result_num, retr_uniq;
  15:     struct querytree        *trbuild();
  16:     extern long         Accuread, Accuwrite, Accusread;
  17:     extern int          derror();
  18:     extern struct querytree     *readqry();
  19: 
  20: #	ifdef xDTM
  21:     if (tTf(76, 1))
  22:         timtrace(23, 0);
  23: #	endif
  24: #	ifdef xDTR1
  25:     if (tTf(50, 0))
  26:     {
  27:         Accuread = 0;
  28:         Accusread = 0;
  29:         Accuwrite = 0;
  30:     }
  31: #	endif
  32: 
  33:     /* initialize query buffer */
  34:     initbuf(Qbuf, QBUFSIZ, QBUFFULL, &derror);
  35: 
  36:     /* init various variables in decomp for start of this query */
  37:     startdecomp();
  38: 
  39:     /* Read in query, range table and mode */
  40:     root = readqry();
  41:     mode = Qmode;
  42: 
  43:     /* Initialize relation descriptors */
  44:     initdesc(mode);
  45: 
  46:     /* re-build the tree */
  47:     root = trbuild(root);
  48:     if (root == NULL)
  49:         derror(STACKFULL);
  50: 
  51: 
  52:     /* locate pointers to QLEND and TREE nodes */
  53:     for (q = root->right; q->sym.type != QLEND; q = q->right);
  54:     Qle = q;
  55: 
  56:     for (q = root->left; q->sym.type != TREE; q = q->left);
  57:     Tr = q;
  58: 
  59: 
  60:     /* map the complete tree */
  61:     mapvar(root, 0);
  62: 
  63:     /* set logical locks */
  64:     if (Lockrel)
  65:         lockit(root, Resultvar);
  66: 
  67:     /* If there is no result variable then this must be a retrieve to the terminal */
  68:     Qry_mode = Resultvar < 0 ? mdRETTERM : mode;
  69: 
  70:     /* if the mode is retrieve_unique, then make a result rel */
  71:     retr_uniq = mode == mdRET_UNI;
  72:     if (retr_uniq)
  73:     {
  74:         mk_unique(root);
  75:         mode = mdRETR;
  76:     }
  77: 
  78:     /* get id of result relation */
  79:     if (Resultvar < 0)
  80:         result_num = NORESULT;
  81:     else
  82:         result_num = Rangev[Resultvar].relnum;
  83: 
  84:     /* evaluate aggregates in query */
  85:     aggregate(root);
  86: 
  87:     /* decompose and process aggregate free query */
  88:     decomp(root, mode, result_num);
  89: 
  90:     /* If this is a retrieve unique, then retrieve results */
  91:     if (retr_uniq)
  92:         pr_unique(root, Resultvar);
  93: 
  94:     if (mode != mdRETR)
  95:         i = ACK;
  96:     else
  97:         i = NOACK;
  98:     i = endovqp(i);
  99: 
 100:     /* call update processor if batch mode */
 101:     if (i == UPDATE)
 102:     {
 103:         initp();
 104:         call_dbu(mdUPDATE, -1);
 105:     }
 106: 
 107: 
 108:     /*
 109: 	** send eop back to parser to indicate completion
 110: 	** if UPDATE then return block comes from dbu else
 111: 	** return block comes from decomp
 112: 	*/
 113:     writeback(i == UPDATE ? -1 : 1);
 114: 
 115: #	ifdef xDTM
 116:     if(tTf(76, 1))
 117:         timtrace(24,0);
 118: #	endif
 119: #	ifdef xDTR1
 120:     if (tTf(50, 1))
 121:     {
 122:         printf("DECOMP read %s pages,", locv(Accuread));
 123:         printf("%s catalog pages,", locv(Accusread));
 124:         printf("wrote %s pages\n", locv(Accuwrite));
 125:     }
 126: #	endif
 127: 
 128:     /* clean decomp */
 129:     reinit();
 130: 
 131:     /* return */
 132: }

Defined functions

qryproc defined in line 10; used 1 times

Defined variables

Qry_mode defined in line 7; used 1 times
  • in line 68
Last modified: 1995-04-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1168
Valid CSS Valid XHTML 1.0 Strict