Re: NEXT VALUE FOR <sequence>

From: Thomas Munro <munro(at)ip9(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NEXT VALUE FOR <sequence>
Date: 2014-10-04 21:45:21
Message-ID: CADLWmXXPuwhrLNVw0J-CRdPJtSz7sd-0j8tsD1PLod9bp21=Aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3 October 2014 00:18, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Thomas Munro <munro(at)ip9(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-10-04 21:55:32 Re: Aussie timezone database changes incoming
Previous Message Bruce Momjian 2014-10-04 21:25:45 Re: Aussie timezone database changes incoming