Re: NEXT VALUE FOR - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: NEXT VALUE FOR
Date
Msg-id CADLWmXXPuwhrLNVw0J-CRdPJtSz7sd-0j8tsD1PLod9bp21=Aw@mail.gmail.com
Whole thread Raw
In response to Re: NEXT VALUE FOR  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: NEXT VALUE FOR
List pgsql-hackers
On 3 October 2014 00:18, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <munro@ip9.org> writes:
>> I suppose one approach would be to use command
>> IDs as the scope.
>
> The spec clearly says one value per row, not one per statement; so
> command ID is very definitely not the right thing.

I think (command ID, estate->es_processed) would work.  Tracking those
two values in SeqTableData would allow you to detect the level change
meaning the next tuple has been returned by a SELECT, updated by an
UPDATE or inserted by an INSERT.  This could be activated by a new
2-argument nextval with a boolean argument to request the standard
behaviour.  Then NEXT VALUE FOR could be translated to nextval(...,
true).

But I just can't figure out how to get my hands on the current EState
or QueryDesc from inside a fmgr function, so I can't reach
estate->es_processed from nextval...

Best regards,
Thomas Munro



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Aussie timezone database changes incoming
Next
From: Tom Lane
Date:
Subject: Re: Aussie timezone database changes incoming