#include "postgres.h"
#include "fmgr.h"
#include "storage/relfilenode.h"
#include "commands/sequence.h"

static int64 _lastval = 0;

PG_FUNCTION_INFO_V1(nextval_new);
Datum nextval_new(PG_FUNCTION_ARGS) {
    _lastval = DatumGetInt64(nextval(fcinfo));
    PG_RETURN_INT64(_lastval);
}

PG_FUNCTION_INFO_V1(lastval);
Datum lastval(PG_FUNCTION_ARGS) {
    PG_RETURN_INT64(_lastval);
}
