From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Ken Johanson <pg-user(at)kensystem(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Example of RETURNING clause to get auto-generated keys |
Date: | 2007-01-25 05:53:51 |
Message-ID: | 14826.1169704431@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alvaro Herrera <alvherre(at)commandprompt(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2007-01-25 06:26:26 | Re: indexing primary and foreign keys w/lookup table |
Previous Message | bala | 2007-01-25 04:57:35 | Postgresql Backup |