Re: Review: UNNEST (and other functions) WITH ORDINALITY - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Review: UNNEST (and other functions) WITH ORDINALITY
Date
Msg-id CAM-w4HOnJ2t2SpaN1eE6oDa9YdiVDmuUT7eqbUNe92FC4YfCxw@mail.gmail.com
Whole thread Raw
In response to Re: Review: UNNEST (and other functions) WITH ORDINALITY  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Review: UNNEST (and other functions) WITH ORDINALITY
Re: Review: UNNEST (and other functions) WITH ORDINALITY
List pgsql-hackers
On Wed, Jun 26, 2013 at 2:47 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Some of the rest of us would like to hear those reasons, because my
> immediate reaction is that the patch must be broken by design.  WITH
> ORDINALITY should not be needing to mess with the fundamental evaluation
> semantics of SRFs, but it sure sounds like it is doing so if that case
> doesn't work as expected.

As Dan pointed out later the patch is not affecting whether this case
works as expected. Only that since you can only use WITH ORDINALITY on
SRFs in the FROM list and not in the target list if you want to use it
you have to rewrite this query to put the SRFs in the FROM list.

I think we're ok with that since SRFs in the target list are something
that already work kind of strangely and probably we would rather get
rid of rather than work to extend. It would be hard to work ordinality
into the grammar in the middle of the target list let alone figure out
how to implement it.


My only reservation with this patch is whether the WITH_ORDINALITY
parser hack is the way we want to go. The precedent was already set
with WITH TIME ZONE though and I think this was the best option. The
worst failure I can come up with is this which doesn't seem like a
huge problem:

postgres=# with o as (select 1 ) select * from o;?column?
----------       1
(1 row)

postgres=# with ordinality as (select 1 ) select * from ordinality;
ERROR:  syntax error at or near "ordinality"
LINE 1: with ordinality as (select 1 ) select * from ordinality;            ^



-- 
greg



pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: Foreign Tables as Partitions
Next
From: Robert Haas
Date:
Subject: Re: FKey not enforced resulting in broken Dump/Reload