Re: Undocumented array_val[generate_series(...)] functionality?

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Undocumented array_val[generate_series(...)] functionality?
Date: 2021-07-12 00:42:47
Message-ID: CAApHDvoRcyDFvvt+5Y3uNeuckaNhpLZg6jsBc2T3xWqL5iPAnQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 12 Jul 2021 at 11:52, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> A post over in Reddit had an expression form I've never seen before:
>
> select (array[1,2,3,4]::integer[])[generate_series(1, 3)];

> Looking at subscripting in the SQL syntax this example doesn't seem to be documented.
>
> https://www.postgresql.org/docs/current/sql-expressions.html#SQL-EXPRESSIONS-SUBSCRIPTS
>
> Is it documented somewhere else, and, regardless, shouldn't it be documented in the linked location?

Isn't this implied by "Each subscript is itself an expression"?
There's nothing special here with the SRF. That just produces 3 rows
and passes the subscript as 1, 2 then 3.

David

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-07-12 00:58:14 Re: Undocumented array_val[generate_series(...)] functionality?
Previous Message Rob Sargent 2021-07-12 00:31:42 Re: Undocumented array_val[generate_series(...)] functionality?