1: # include   "../ingres.h"
   2: # include   "../access.h"
   3: 
   4: /*
   5: **	INSERT - add a new tuple to a relation
   6: **
   7: **	Insert puts a given tuple into a relation in
   8: **	the "correct" position.
   9: **
  10: **	If insert is called with checkdups == TRUE then
  11: **	the tuple will not be inserted if it is a duplicate
  12: **	of some already existing tuple. If the relation is a
  13: **	heap then checkdups is made false.
  14: **
  15: **	Tid will be set to the tuple id where the
  16: **	tuple is placed.
  17: **
  18: **	returns:
  19: **		<0  fatal eror
  20: **		0   success
  21: **		1   tuple was a duplicate
  22: */
  23: 
  24: insert(desc, tid1, tuple, checkdups)
  25: struct descriptor   *desc;
  26: struct tup_id       *tid1;
  27: char            *tuple;
  28: int         checkdups;
  29: {
  30:     register struct descriptor  *d;
  31:     register struct tup_id      *tid;
  32:     register int            i;
  33:     int             need;
  34: 
  35:     d = desc;
  36:     tid = tid1;
  37: 
  38: #	ifdef xATR1
  39:     if (tTf(94, 0))
  40:     {
  41:         printf("insert:%.14s,", d->relid);
  42:         dumptid(tid);
  43:         printup(d, tuple);
  44:     }
  45: #	endif
  46:     /* determine how much space is needed for tuple */
  47:     need = canonical(d, tuple);
  48: 
  49:     /* find the "best" page to place tuple */
  50:     if (i = findbest(d, tid, tuple, need, checkdups))
  51:         return (i);
  52: 
  53:     /* put tuple in position "tid" */
  54:     put_tuple(tid, Acctuple, need);
  55: 
  56:     d->reladds++;
  57: 
  58:     return (0);
  59: }
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1975
Valid CSS Valid XHTML 1.0 Strict