Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alvaro Herrera <alvherre@xxxxxxxxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux