Re: lastval() - Mailing list pgsql-patches

From Neil Conway
Subject Re: lastval()
Date
Msg-id 42A3D79E.4030001@samurai.com
Whole thread Raw
In response to Re: lastval()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: lastval()
List pgsql-patches
Tom Lane wrote:
> This definition is OK with me ... so long as it still includes the
> phrase "an error occurs if no nextval or setval has occurred in the
> current session".  However it seemed that a number of people asking
> for the feature wanted some-random-default to be returned instead.

Right -- I think it definitely needs to return an error in that
situation. Per my earlier mail, the other debatable behavior is whether
lastval() should be defined if the sequence it would be returning the
currval() for has been subsequently dropped. I'm inclined to not return
an error here to simplify the implementation, but I'm open to objections.

> Another question is why should setval affect the result?  I don't
> see the use-case for that offhand.

I'm not militant about it, but having setval() affect the result means
lastval() is more consistent with currval().

-Neil

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: lastval()
Next
From: Tom Lane
Date:
Subject: Re: lastval()