From: | Mike Mascari <mascarm(at)mascari(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Subject: | Re: Behavior of nextval() and currval() |
Date: | 2001-11-13 18:41:28 |
Message-ID: | 3BF16958.AD35F546@mascari.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Bruce Momjian wrote:
>
> So you are asking if the order of column function evaluations is
> reliable. I tend to think so. I think the only thing that could
> reorder it is rules.
and
Tom Lane wrote:
>
> Mike Mascari <mascarm(at)mascari(dot)com> writes:
> > The following works in 7.1. Is this behavior guaranteed or is it the
> > subject of possible change in the future? Or am I just "getting
> > lucky" that nextval() is evaluated before currval():
>
> > SELECT nextval('s'), currval('s');
>
> Hmm. SELECT target expressions are indeed evaluated left to right at
> present, and I don't see any reason to change that --- but it's not
> guaranteed by the spec AFAIK. I think you're right to be wary of
> depending on it. Why would you need to do this anyway?
It's an odd scenario, where I need to generate primary keys from an
INSERT..SELECT and the secondary field should match the primary key
in this instance. The secondary field represents a "parent" which
refers to itself if the record is not a child (as opposed to say,
0). I've switched to using a CREATE TEMPORARY TABLE AS SELECT..,
INSERT..SELECT to avoid the scenario.
Thanks,
Mike Mascari
mascarm(at)mascari(dot)com
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-11-13 18:53:33 | Re: Behavior of nextval() and currval() |
Previous Message | Tom Lane | 2001-11-13 18:12:47 | Re: Behavior of nextval() and currval() |