Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)

From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)
Date: 2010-11-19 02:40:05
Message-ID: AANLkTi=9bqCLMzXDy-KYSsPK9gB_-dE=f3kTvzvbPT6i@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 19, 2010 at 08:33, David Fetter <david(at)fetter(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2010-11-19 02:43:03 Changes to Linux OOM killer in 2.6.36
Previous Message Robert Haas 2010-11-19 02:17:40 Re: Latches with weak memory ordering (Re: max_wal_senders must die)