Re: VALUES() evaluation order

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: VALUES() evaluation order
Date: 2013-01-14 15:23:36
Message-ID: 2d29c570-bc21-41ed-9914-2a456fc3ea6c@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:

> Consider sticking the nextval() into a WITH.

This is also a reminder that PG's nextval() differs on this from
the SQL standard, which says:

"If there are multiple instances of <next value expression>s
specifying the same sequence generator within a single
SQL-statement, all those instances return the same value for
a given row processed by that SQL-statement"

According to that sentence, we would write
INSERT INTO table(c1,c2) VALUES(nextval('s'), nextval('s'))
and get the same value in c1 and c2.
But we know that's not how nextval works in PG.
However that's how it work in Oracle, for instance.

To avoid depending on the evaluation order, or for
the sake of porting SQL queries from other DBs, it
would be nice to have in PG an alternate nextval operator
that would comply with this "one-value per-row" rule.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Asia 2013-01-14 15:57:01 Re: Libpq and multithreading
Previous Message Merlin Moncure 2013-01-14 15:05:53 Re: Libpq and multithreading