Skip site navigation (1) Skip section navigation (2)

Re: BUG #4684: lastval in function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4684: lastval in function
Date: 2009-03-02 17:21:43
Message-ID: 7406.1236014503@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Chris Browne <cbbrowne(at)acm(dot)org> writes:
> I'm not sure I'd *want* to have a more-sophisticated scoping mechanism
> for this.

We already have an appropriate language-level solution for this: it's
called INSERT RETURNING.

The fact is that lastval was invented to aid in porting brain-dead
mysql applications that weren't going to do anything as complicated
as execute commands that might involve more than one nextval call.
If there is any remote possibility that your app might have to deal
with such a thing, you shouldn't be using lastval.

Before considering complicating the definition of lastval, I'd vote
for removing it entirely.  It's a foot-gun and will never be anything
but.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2009-03-02 19:19:38
Subject: Re: [BUGS] BUG #4680: Server crashed if using wrong (mismatch) conversion functions
Previous:From: Tihamer Toth-FejelDate: 2009-03-02 17:01:54
Subject: BUG #4687: PostgreSQL website won't let me register

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group