Re: NEXT VALUE FOR - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: NEXT VALUE FOR
Date
Msg-id 542D36AF.8070000@vmware.com
Whole thread Raw
In response to NEXT VALUE FOR  (Thomas Munro <munro@ip9.org>)
Responses Re: NEXT VALUE FOR
List pgsql-hackers
On 10/01/2014 07:28 PM, Thomas Munro wrote:
> Hi
>
> SQL:2003 introduced the function NEXT VALUE FOR <sequence>. Google
> tells me that at least DB2, SQL Server and a few niche databases
> understand it so far.  As far as I can tell there is no standardised
> equivalent of currval and setval (but I only have access to second
> hand information about the standard, like articles and the manuals of
> other products).
>
> Here is a starter patch to add it.  To avoid a shift/reduce conflict,
> I had to reclassify the keyword NEXT.  I admit that I don't fully
> understand the consequences of that change!  Please let me know if you
> think this could fly.

Looks correct. Of course, it's annoying to have to reserve the NEXT 
keyword (as a type_func_name_keyword, not fully reserved).

One way to avoid that is to collapse NEXT VALUE FOR into a single token 
in parser.c. We do that for a few other word pairs: NULLS FIRST, NULLS 
LAST, WITH TIME and WITH ORDINALITY. In this case you'd need to 
look-ahead three tokens, not two, but I guess that'd be doable.

- Heikki




pgsql-hackers by date:

Previous
From: Ilya Kosmodemiansky
Date:
Subject: Re: Dynamic LWLock tracing via pg_stat_lwlock (proof of concept)
Next
From: Heikki Linnakangas
Date:
Subject: Re: pgcrypto: PGP signatures