1: # include   "../ingres.h"
   2: # include   "../access.h"
   3: # include   "../aux.h"
   4: # include   "../lock.h"
   5: 
   6: /*
   7: **	ADD_OVFLO -- Allocates an overflow page which will be
   8: **		attached to current page.  TID must be for current page.
   9: **		TID will be updated to id of new overflow page.
  10: */
  11: 
  12: add_ovflo(dx, tid)
  13: struct descriptor   *dx;
  14: struct tup_id       *tid;
  15: {
  16:     register struct descriptor  *d;
  17:     register struct accbuf      *b;
  18:     register int            lk;
  19:     int             i;
  20:     long                mpage, newpage;
  21:     struct tup_id           tidx;
  22:     struct accbuf           *choose_buf();
  23: 
  24:     d = dx;
  25: 
  26: /*
  27: **	save main page pointer so that it may be used when
  28: **	setting up new overflow page.
  29: */
  30:     mpage = Acc_head->mainpg;
  31: 
  32:     if (lk = (Acclock && (d->relstat & S_CONCUR) && (d->relopn < 0 )))
  33:     {
  34:         setcsl(Acc_head->rel_tupid);
  35:         Acclock = FALSE;
  36:     }
  37: 
  38: /*
  39: **	Determine last page of the relation
  40: */
  41:     last_page(d, &tidx, Acc_head);
  42:     pluck_page(&tidx, &newpage);
  43:     newpage++;
  44: 
  45: /*
  46: **	choose an available buffer as victim for setting up
  47: **	overflow page.
  48: */
  49:     if ((b = choose_buf(d, newpage)) == NULL)
  50:     {
  51:         if (lk)
  52:         {
  53:             Acclock = TRUE;
  54:             unlcs(Acc_head->rel_tupid);
  55:         }
  56:         return(-1);
  57:     }
  58: 
  59: /*
  60: **	setup overflow page
  61: */
  62:     b->mainpg = mpage;
  63:     b->ovflopg = 0;
  64:     b->thispage = newpage;
  65:     b->linetab[0] = b->firstup - b;
  66:     b->nxtlino = 0;
  67:     b->bufstatus |= BUF_DIRTY;
  68:     if (pageflush(b))
  69:         return (-2);
  70: 
  71: /*
  72: **	now that overflow page has successfully been written,
  73: **	get the old current page back and link the new overflow page
  74: **	to it.
  75: **	If the relation is a heap then don't leave the old main
  76: **	page around in the buffers. This is done on the belief
  77: **	that it will never be accessed again.
  78: */
  79: 
  80:     if (get_page(d, tid))
  81:         return (-3);
  82:     Acc_head->ovflopg = newpage;
  83:     Acc_head->bufstatus |= BUF_DIRTY;
  84:     i = pageflush(Acc_head);
  85:     if (lk)
  86:     {
  87:         Acclock = TRUE;
  88:         unlcs(Acc_head->rel_tupid);
  89:     }
  90:     if (i)
  91:         return (-4);
  92:     if (abs(d->relspec) == M_HEAP)
  93:         resetacc(Acc_head); /* no error is possible */
  94: 
  95: /*
  96: **	now bring the overflow page back and make it current.
  97: **	if the overflow page is still in AM cache, then this will not
  98: **	cause any disk activity.
  99: */
 100: 
 101:     stuff_page(tid, &newpage);
 102:     if (get_page(d, tid))
 103:         return (-5);
 104:     return (0);
 105: }

Defined functions

add_ovflo defined in line 12; used 1 times
Last modified: 1995-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 637
Valid CSS Valid XHTML 1.0 Strict