*** src/backend/commands/sequence.c.orig Sun Mar 1 23:35:30 1998 --- src/backend/commands/sequence.c Mon Mar 2 00:45:30 1998 *************** *** 304,309 **** --- 304,312 ---- { char *seqname = textout(seqin); SeqTable elm; + Buffer buf; + SequenceTupleForm seq; + ItemPointerData iptr; int4 result; /* open and WIntentLock sequence */ *************** *** 312,321 **** if (elm->increment == 0) /* nextval/read_info were not called */ { ! elog(ERROR, "%s.currval is not yet defined in this session", elm->name); } ! ! result = elm->last; return (result); --- 315,327 ---- if (elm->increment == 0) /* nextval/read_info were not called */ { ! /* Prime the pump (so to speak) by reading the sequence tuple */ ! result = (read_info("currval", elm, &buf))->last_value; ! ItemPointerSet(&iptr, 0, FirstOffsetNumber); ! RelationUnsetSingleWLockPage(elm->rel, &iptr); } ! else ! result = elm->last; return (result);