Re: Re: postgres TODO - Mailing list pgsql-hackers

From Ed Loehr
Subject Re: Re: postgres TODO
Date
Msg-id 3969ED56.8CD45D14@austin.rr.com
Whole thread Raw
In response to Re: Re: postgres TODO  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Tom Lane wrote:
> 
> Alessio Bragadini <alessio@albourne.com> writes:
> > Peter Eisentraut wrote:
> >>>> * Add function to return primary key value on INSERT
> >>
> >> I don't get the point of this. Don't you know what you inserted? For
> >> sequences there's curval()
> 
> To get back to Peter's original question, you don't necessarily "know
> what you inserted" if you allow columns to be filled with default values
> that are calculated by complicated functions.  A serial column is just
> the simplest example of that.  Whether this situation is common enough
> to justify a special hack in INSERT is another question.  I kinda doubt
> it.  We already return the OID which is sufficient info to select the
> row again if you need it.  Returning the primary key would be
> considerably more work for no visible gain in functionality...

It's definitely not a crucial functionality gain, IMO, but it is
nonetheless a gain when you consider that *every* pgsql developer on 
the planet could then do something in one query that currently takes 
two (plus the requisite error-handling code).  A few other counter-
arguments for returning the autoincrement/serial/pkey:
1) it earns bad press w/r/t usability;2) it is an FAQ on the lists;3) it is an extremely common operation;4) other DBs
provideit;
 

Regards,
Ed Loehr


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: memory: bug or feature
Next
From: Thomas Lockhart
Date:
Subject: Re: Re: [GENERAL] PostgreSQL vs. MySQL