Re: [NOVICE] Last ID Problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [NOVICE] Last ID Problem
Дата
Msg-id 28692.1107358480@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [NOVICE] Last ID Problem  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
Ответы Re: [NOVICE] Last ID Problem  (Greg Stark <gsstark@mit.edu>)
Re: [NOVICE] Last ID Problem  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
Список pgsql-hackers
"Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk> writes:
> Just off the top of my head, would it not be feasible to add a column to
> pg_class called lastinsert that points to the OID of the pg_attribute column
> to return after an insert?

No.  The thing everyone is ignoring here is that the INSERT command tag
format is not something we can just go and change.  You certainly could
not put anything in it that wasn't an integer, and I'm not sure it would
even be safe to put a bigint.  So most of the cases you might actually
want (timestamp, bigserial, etc) would be ruled out.  Hardly worth
inventing such a feature.

> I see that INSERT...RETURNING is a solution to the problem, but it seems
> somewhat strange to have to use an unportable command just to be able to
> return an identifier for the last inserted record...

How is what you're suggesting more portable?
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: a_ogawa
Дата:
Сообщение: Re: FunctionCallN improvement.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Problems with initdb 8.0.1