Re: Example of RETURNING clause to get auto-generated keys

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Example of RETURNING clause to get auto-generated keys
Дата
Msg-id 14826.1169704431@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Example of RETURNING clause to get auto-generated keys  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Ken Johanson wrote:
>> Just to be sure, will the RETURNING clause work with custom sequences
>> (say, non numeric or increment by two) or other types of key
>> generators?... And how will triggers interfere with it (if at all)?

> As far as I know, RETURNING will give you exactly the values that are
> put into the table.

RETURNING evaluates the given expression-list over the values that were
actually stored.  There's no way for a datatype or BEFORE trigger to
"fool" it.  The only possibly interesting case is if you had an AFTER
trigger that proceeded to modify the stored row by issuing an UPDATE
... but that would be a pretty silly/inefficient way to do things,
and even then I think that RETURNING is telling the truth as of the time
that the tuple insert/update happened.  It can't be supposed to be
prescient about subsequent changes.

            regards, tom lane

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

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: indexing primary and foreign keys w/lookup table
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: indexing primary and foreign keys w/lookup table