1: # include   <ingres.h>
   2: # include   <symbol.h>
   3: # include   <tree.h>
   4: # include   "../decomp/globs.h"
   5: # include   "strategy.h"
   6: # include   <sccs.h>
   7: 
   8: SCCSID(@(#)tidtest.c	8.1	12/31/84)
   9: 
  10: /*
  11: ** tid_only_test
  12: ** Check the qualification list to see if it
  13: ** contains exactly one simple clause, that
  14: ** clause refers to a tid as the VAR, and that
  15: ** the binary operation is opEQ.
  16: **
  17: ** Side Effects:
  18: **	If the condition holds true, De.ov_hitid and De.ov_lotid
  19: **	are set to refer to the constant value.
  20: **
  21: ** Returns:
  22: **	1 if qualification holds,
  23: **	0 on failure.
  24: **
  25: ** Trace Flags:
  26: **	89
  27: **
  28: ** Called From:
  29: **	strategy
  30: */
  31: tid_only_test()
  32: {
  33:     register struct symbol  *c;
  34:     register int        t;
  35:     register struct symbol  **q;
  36:     int         found;
  37:     int         i;
  38: 
  39: #	ifdef xOTR1
  40:     if (tTf(89, 0))
  41:         printf("TID_ONLY_TEST\n");
  42: #	endif
  43:     found = FALSE;
  44: 
  45:     q = De.ov_qlist;    /* q holds pointer to qualification */
  46: 
  47:     if (!q)
  48:         return (0);
  49: 
  50: 
  51:     /*
  52: 	** iterate through the tree
  53: 	*/
  54:     for (t = (*q)->type; t != QLEND; t = (*++q)->type)
  55:     {
  56:         /*
  57: 		** The only thing we allow is a single simple
  58: 		** expression with tids.
  59: 		*/
  60:         if ( found == TRUE )
  61:             return ( 0 );
  62: 
  63:         switch (t)
  64:         {
  65:           case VAR:
  66:             /*
  67: 			** Only allow tids to be vars.
  68: 			*/
  69:             if ( (*q)->value.sym_var.attno != 0 )
  70:                 return (0);
  71:             t = (*++q)->type;
  72:             if ( t != INT )
  73:                 return ( 0 );
  74:             else
  75:             {
  76:                 c = *q; /* save pointer to value symbol */
  77:                 t = (*++q)->type;
  78:                 if (relop(*q, FALSE) == opEQ
  79:                    && (t = (*++q)->type) == AND)
  80:                 {
  81:                     /* found a simple clause */
  82:                     found = TRUE;
  83:                 }
  84:             }
  85:             break;
  86: 
  87:           case INT:
  88:             c = *q++;
  89:             if ((t = (*q)->type) != VAR)
  90:                 return ( 0 );
  91:             else
  92:             {
  93:                 if ( (*q)->value.sym_var.attno != 0 )
  94:                     return ( 0 );
  95:                 t = (*++q)->type;
  96:                 if ( relop(*q, TRUE) == opEQ && (t = (*++q)->type) == AND)
  97:                 {
  98:                     /* found a simple clause */
  99:                     found = TRUE;
 100:                 }
 101:                 else
 102:                     return ( 0 );
 103:             }
 104: 
 105:           default:
 106:             return ( 0 );
 107:         }
 108:     }
 109: 
 110: #	ifdef xOTR1
 111:     if (tTf(89, 2))
 112:         printf("tid_only_test returning %d\n", found);
 113: #	endif
 114: 
 115:     /*
 116: 	** We have found a simple clause using only the tid.
 117: 	** Set the low and high search keys.
 118: 	*/
 119:     if ( found == TRUE )
 120:     {
 121:         register    union   symvalue    *p;
 122: 
 123:         p = &c->value;
 124:         De.ov_lotid = De.ov_hitid = p->sym_data.i2type;
 125:         dec_tid(&De.ov_lotid);
 126:         return (1);
 127:     }
 128: 
 129:     return ( 0 );
 130: }/* tid_only_test */
 131: 
 132: /*
 133: ** dec_tid
 134: ** Decrement the line-id of a tid
 135: */
 136: dec_tid(tid)
 137: TID *tid;
 138: {
 139:     tid->line_id--;
 140: }/* dec_tid */

Defined functions

dec_tid defined in line 136; used 1 times
tid_only_test defined in line 8; used 1 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 940
Valid CSS Valid XHTML 1.0 Strict