# 2.11BSD#431 - /usr/ingres/source/access/scan_dups.c

##### Functions

    dup_check         X
    scan_dups         X

       1: # include   "../ingres.h"
       2: # include   "../symbol.h"
       3: # include   "../access.h"
       4: # include   "../lock.h"
       5:
       6: scan_dups(d, tidx, tuple)
       7: struct descriptor   *d;
       8: struct tup_id       *tidx;
       9: char            *tuple;
      10:
      11: /*
      12: **	Scan for duplicates. Start with the page
      13: **	specified by tid and
      14: **	continue until there are no more pages
      15: **
      16: **	Scan_dups guarantees that the same page will
      17: **	be in the buffer on entry and exit
      18: **
      19: **	returns:
      20: **		<0 if fatal error
      21: **		0  if not duplicate
      22: **		1  if duplicate
      23: */
      24:
      25: {
      26:     register int        dup, pagerr;
      27:     register struct tup_id  *tid;
      28:     struct tup_id       savetid;
      29:
      30:     tid = tidx;
      31:
      32:     stuff_page(&savetid, &Acc_head->thispage);
      33:
      34:     Acclock = FALSE;    /* turn concurrency off */
      35:     dup = 0;    /* assume success */
      36:
      37:     do
      38:     {
      39:         if (pagerr = get_page(d, tid))
      40:             break;  /* fatal error */
      41:
      42:         if (dup = dup_check(d, tid, tuple))
      43:             break;  /* found duplicate */
      44:
      45:         stuff_page(tid, &Acc_head->ovflopg);
      46:     } while (Acc_head->ovflopg);
      47:
      48:     if (pagerr || (pagerr = get_page(d, &savetid)))
      49:         dup = pagerr;   /* return fatal page error */
      50:
      51:     Acclock = TRUE;     /* turn concurency on */
      52:     return (dup);
      53: }
      54:
      55:
      56: dup_check(dx, tid, tuple1)
      57: struct descriptor   *dx;
      58: struct tup_id       *tid;
      59: char            *tuple1;
      60:
      61: /*
      62: **	Check current page for a duplicate of tuple;
      63: **
      64: **	returns:
      65: **		0 if not duplicate
      66: **		1 if duplicate
      67: */
      68:
      69: {
      70:     register struct descriptor  *d;
      71:     register int            i, dom;
      72:     int             *lp, len, lastline, tups_equal;
      73:     char                *tup1, *tup2;
      74:     char                tuple2[MAXTUP];
      75:     char                *getint_tuple();
      76:
      77:     d = dx;
      78:
      79:
      80:     /* determine starting and ending points */
      81:     lastline = Acc_head->nxtlino;
      82:     lp = &Acc_head->linetab[0];
      83:
      84:     /* check each tuple for duplication */
      85:     for (i = 0; i < lastline; i++)
      86:     {
      87:
      88:         /* is this line used? */
      89:         if (*lp--)
      90:         {
      91:             /* yes. get tuple and check it */
      92:             tid->line_id = i;
      93:             tup2 = getint_tuple(d, tid, tuple2);
      94:             tup1 = tuple1;
      95:             tups_equal = TRUE;  /* assume equal */
      96:
      97:             /* now check each domain for duplication */
      98:             for (dom = 1; dom <= d->relatts; dom++)
      99:             {
     100:                 len = d->relfrml[dom] & I1MASK;
     101:                 if (d->relfrmt[dom] == CHAR)
     102:                     tups_equal = scompare(tup1, len, tup2, len) == 0;
     103:                 else
     104:                     tups_equal = bequal(tup1, tup2, len);
     105:                 if (!tups_equal)
     106:                 {
     107:                     /* not duplicates */
     108:                     break;
     109:                 }
     110:                 tup1 += len;
     111:                 tup2 += len;
     112:             }
     113:             if (tups_equal)
     114:                 return (1); /* duplicate */
     115:         }
     116:     }
     117:     return (0); /* no duplicate */
     118: }

#### Defined functions

dup_check defined in line 56; used 2 times

- in line 42
- in /usr/ingres/source/access/findbest.c line 80

scan_dups defined in line 6; used 2 times

- in /usr/ingres/source/access/findbest.c line 107
- in /usr/ingres/source/access/replace.c line 150

Last modified: 1995-02-04 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 582 |