1: # include   <ingres.h>
   2: # include   <access.h>
   3: # include   <catalog.h>
   4: # include   <btree.h>
   5: # include   <sccs.h>
   6: 
   7: SCCSID(@(#)insert_mbtree.c	8.1	12/31/84)
   8: 
   9: insert_mbtree(d, btree, lid, tid, tidpos)
  10: 
  11: register DESC *d;
  12: char *btree;
  13: long lid[];
  14: long *tid;
  15: TID *tidpos;
  16: {
  17:     register int    i, j;
  18:     long        page;
  19:     long        l;
  20:     long        last_lid();
  21:     struct locator  tidloc;
  22:     long        ntid;
  23:     long        t;
  24:     struct BTreeNode    junk;
  25: 
  26:     page = RT;
  27:     for (i = 0; i < d->reldum.reldim - 1; ++i)
  28:     {
  29:         if (lid[i] && lid[i+1])
  30:         {
  31:             if ((t = get_tid(page, lid[i], &tidloc)) < -1)
  32:                 return(-1);
  33:             if (t != -1)
  34:                 page = t;
  35:         }
  36:         if (!lid[i] || t == -1 || !lid[i+1])
  37:         {
  38:             for (j = i; j < d->reldum.reldim - 1; ++j)
  39:             {
  40:                 if (j != i)
  41:                     lid[j] = 1;
  42:                 else if (t == -1 || !lid[i])
  43:                     lid[j] = last_lid(page);
  44:                 insert_btree(btree, page, lid[j], &ntid, tidpos, j + 2);
  45:                 page = ntid;
  46:             }
  47:             lid[d->reldum.reldim - 1] = 1;
  48:             break;
  49:         }
  50:     }
  51:     l = last_lid(page);
  52:     if (lid[d->reldum.reldim - 1] < 0 || lid[d->reldum.reldim - 1] >  l)
  53:         return(-1);
  54:     if (!lid[d->reldum.reldim - 1])
  55:         lid[d->reldum.reldim - 1] = l;
  56:     insert_btree(btree, page, lid[d->reldum.reldim - 1], tid, tidpos, 0);
  57: 
  58:     return (0);
  59: }

Defined functions

Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 749
Valid CSS Valid XHTML 1.0 Strict