1: # include   "../ingres.h"
   2: # include   "../symbol.h"
   3: # include   "../tree.h"
   4: # include   "decomp.h"
   5: 
   6: /*
   7: ** PULL_CONST - Detach and execute all constant clauses in the qualification.
   8: **
   9: **	Pull_const examines the root tree for any constant clauses.
  10: **	If none are present then it returns TRUE. If there are any
  11: **	constant clauses, then they are removed, executed and if
  12: **	TRUE then pull_const returns TRUE and other wise it returns
  13: **	FALSE.
  14: **
  15: **	This routine is not necessary to decomposition but rather
  16: **	can be called as an optimization when constant clauses are
  17: **	expected. Note that without this routine, constant clauses
  18: **	would only be examined at the bottom level of decomposition.
  19: **	Thus a multivar query which was true except for a constant clause
  20: **	would look at the required cross-product space before returning.
  21: */
  22: 
  23: pull_const(root, buf)
  24: struct querytree    *root;
  25: char            *buf;
  26: {
  27:     register struct querytree   *r, *q, *s;
  28:     struct querytree        *makroot();
  29: 
  30:     s = 0;
  31: 
  32:     for (r = root; r->right->sym.type != QLEND; )
  33:     {
  34:         q = r;
  35:         r = r->right;   /* r is now the AND node */
  36: 
  37:         if (((struct qt_root *)r)->lvarc == 0)
  38:         {
  39:             /* we have a constant clause */
  40:             if (s == 0)
  41:                 s = makroot(buf);
  42: 
  43:             /* remove AND from root tree */
  44:             q->right = r->right;
  45: 
  46:             /* put node into constant tree */
  47:             r->right = s->right;
  48:             s->right = r;
  49: 
  50:             /* fix up var counts (just for good form!) */
  51:             ((struct qt_root *)r)->rvarm = ((struct qt_root *)r)->tvarc = 0;
  52: 
  53:             r = q;
  54:         }
  55:     }
  56: 
  57:     if (s)
  58:     {
  59:         /* run the constant query */
  60:         return (execsq1(s, -1, NORESULT));
  61:     }
  62: 
  63:     return (TRUE);
  64: }

Defined functions

pull_const defined in line 23; used 1 times
Last modified: 1995-04-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 932
Valid CSS Valid XHTML 1.0 Strict