1: # include   "../ingres.h"
   2: # include   "../access.h"
   3: # include   "../symbol.h"
   4: # include   "../aux.h"
   5: 
   6: icompare(ax, bx, frmt, frml)
   7: char    *ax, *bx, frmt, frml;
   8: {
   9:     register char   *a, *b;
  10:     register int    length;
  11:     int     atemp[4], btemp[4];
  12: 
  13:     length = frml & I1MASK;
  14:     if (frmt == CHAR)
  15:         return (scompare(ax, length, bx, length));
  16:     a = (char *) atemp;
  17:     b = (char *) btemp;
  18:     bmove(ax, a, length);
  19:     bmove(bx, b, length);
  20:     if (bequal(a, b, length))
  21:         return (0);
  22:     switch (frmt)
  23:     {
  24:       case INT:
  25:         switch (length)
  26:         {
  27:           case 1:
  28:             return (i1deref(a) - i1deref(b));
  29:           case 2:
  30:             return (i2deref(a) - i2deref(b));
  31:           case 4:
  32:             return (i4deref(a) > i4deref(b) ? 1 : -1);
  33:         };
  34:       case FLOAT:
  35:         if (frml == 4)
  36:         {
  37:             return (f4deref(a) > f4deref(b) ? 1 : -1);
  38:         }
  39:         else
  40:         {
  41:             return (f8deref(a) > f8deref(b) ? 1 : -1);
  42:         }
  43:     };
  44: }
  45: 
  46: 
  47: kcompare (dx, tuple, key)
  48: struct descriptor   *dx;    /*relation descriptor	*/
  49: char    tuple[MAXTUP];      /*tuple to be compared	*/
  50: char    key[MAXTUP];        /*second tuple or key	*/
  51: /*
  52:  * compares all domains indicated by SETKEY in the tuple to the
  53:  * corressponding domains in the key.
  54:  * the comparison is done according to the format of the domain
  55:  * as specified in the descriptor.
  56:  *
  57:  * function values:
  58:  *	<0 tuple < key
  59:  * 	=0 tuple = key
  60:  *	>0 tuple > key
  61:  *
  62:  */
  63: {
  64:     register int            i, tmp;
  65:     register struct descriptor  *d;
  66: 
  67:     d = dx;
  68:     for (i = 1; i <= d->relatts; i++)
  69:         if (d->relgiven[i])
  70:             if (tmp = icompare(&tuple[d->reloff[i]],
  71:                     &key[d->reloff[i]],
  72:                     d->relfrmt[i],
  73:                 d->relfrml[i]))
  74:             {
  75:                 return (tmp);
  76:             }
  77:     return (0);
  78: }
Last modified: 1995-02-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2401
Valid CSS Valid XHTML 1.0 Strict