Re: NEXT VALUE FOR sequence - Mailing list pgsql-hackers

From Daniel Verite
Subject Re: NEXT VALUE FOR sequence
Date
Msg-id 759ae1b7-543c-4f38-9bc9-cbe773cbe5ef@manitou-mail.org
Whole thread Raw
In response to NEXT VALUE FOR sequence  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-hackers
    Laurenz Albe wrote:

> The SQL standard has the expression "NEXT VALUE FOR asequence" to do
> what we traditionally do with "nextval('asequence')".

The behavior mandated by the standard is that several invocations
of NEXT VALUE on the same sequence on the same output row
must produce the same value. That is:

CREATE SEQUENCE s;
SELECT NEXT VALUE FOR s, NEXT VALUE FOR s
 UNION
SELECT NEXT VALUE FOR s, NEXT VALUE FOR s

should produce
(1,1)
(2,2)

It makes sense that the value does not depend on
the position of the expression as a column.

The trouble of course is that the equivalent with
nextval() would produce instead
(1,2)
(3,4)


There have been previous discussions on the standard syntax
that said that when it will get into postgres, it should go with
the standard conforming semantics.
I guess it would be a much more difficult patch.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


pgsql-hackers by date:

Previous
From: Alexander Levsha
Date:
Subject: Tracking object modification time using event triggers
Next
From: David Rowley
Date:
Subject: Re: [HACKERS] path toward faster partition pruning