1: # include "../ingres.h" 2: # include "../access.h" 3: 4: /* 5: inpcloser - close an input relation 6: 7: The relation must have been opened by openr with 8: mode 0 (read only) 9: 10: return values: 11: <0 fatal error 12: 0 success 13: 1 relation was not open 14: 2 relation was opened in write mode 15: */ 16: 17: inpcloser(dx) 18: struct descriptor *dx; 19: 20: { 21: register struct descriptor *d; 22: register int i; 23: 24: d = dx; 25: # ifdef xATR1 26: tTfp(90, 9, "inpcloser: %.14s\n", d->relid); 27: # endif 28: if (abs(d->relopn) != (d->relfp + 1) * 5) 29: /* relation not open */ 30: return (1); 31: 32: if (d->relopn < 0) 33: return (2); /* relation open in write mode */ 34: 35: i = flush_rel(d, TRUE); /* flush and reset all pages */ 36: 37: if (close(d->relfp)) 38: i = acc_err(AMCLOSE_ERR); 39: d->relopn = 0; 40: return (i); 41: }