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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Undocumented array_val[generate_series(...)] functionality?
Date: 2021-07-11 23:52:14
Message-ID: CAKFQuwaMq8xwBoJzW_gGVrDj0hvCf2V7Z2bJEZkkNodZnayOVQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,

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)];
===
1
2
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?

I get this is basically a variant of the slice syntax [n:m], and it is
working as expected, but nothing indicates I can put an SRF inside the
brackets.

David J.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2021-07-12 00:31:42 Re: Undocumented array_val[generate_series(...)] functionality?
Previous Message Jakub Jedelsky 2021-07-11 21:52:56 libicu global support