Re: Re: postgres TODO
Ed Loehr <eloehr@austin.rr.com>
From: Ed Loehr <eloehr@austin.rr.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alessio Bragadini <alessio@albourne.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2000-07-10T15:35:50Z
Lists: 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 provide it; Regards, Ed Loehr