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