Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF) - Mailing list pgsql-hackers

From Itagaki Takahiro
Subject Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)
Date
Msg-id AANLkTi=9bqCLMzXDy-KYSsPK9gB_-dE=f3kTvzvbPT6i@mail.gmail.com
Whole thread Raw
In response to UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)  (David Fetter <david@fetter.org>)
Responses Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)
List pgsql-hackers
On Fri, Nov 19, 2010 at 08:33, David Fetter <david@fetter.org> wrote:
> In order to get WITH ORDINALITY, would it be better to change gram.y
> to account for both WITH ORDINALITY and without, or just for the WITH
> ORDINALITY case?

We probably need to change gram.y and make UNNEST to be COL_NAME_KEYWORD.
UNNEST (without ORDINALITY) will call the existing unnest() function,
and UNNEST() WITH ORDINALITY will call unnest_with_ordinality().

BTW, what will we return for arrays with 2 or more dimensions?
There are no confusion in your two arguments version:
> UNNEST(anyarray, number_of_dimensions_to_unnest)
but we will also support one argument version. Array indexes will
be composite numbers in the cases. The possible design would be just
return sequential serial numbers of the values -- the following two
queries return the same results:

- SELECT i, v FROM UNNEST($1) WITH ORDINALITY AS t(v, i)
- SELECT row_number() OVER () AS i, v FROM UNNEST($1) AS t(v)

-- 
Itagaki Takahiro


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Latches with weak memory ordering (Re: max_wal_senders must die)
Next
From: Greg Smith
Date:
Subject: Changes to Linux OOM killer in 2.6.36