From: Rob Sargent <robjsargent@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Undocumented array_val[generate_series(...)] functionality?
Date: Sun, 11 Jul 2021 18:31:42 -0600
Message-ID: <5DE6FCCC-B89D-4556-885E-D2E4F0C5A64B@gmail.com> (raw)
In-Reply-To: <CAKFQuwaMq8xwBoJzW_gGVrDj0hvCf2V7Z2bJEZkkNodZnayOVQ@mail.gmail.com>
References: <CAKFQuwaMq8xwBoJzW_gGVrDj0hvCf2V7Z2bJEZkkNodZnayOVQ@mail.gmail.com>
> On Jul 11, 2021, at 5:52 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
>
> 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.
Is that expression saying something like select the first second third element from array 1,2,3,4?
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, david.g.johnston@gmail.com
Subject: Re: Undocumented array_val[generate_series(...)] functionality?
In-Reply-To: <5DE6FCCC-B89D-4556-885E-D2E4F0C5A64B@gmail.com>
References: <CAKFQuwaMq8xwBoJzW_gGVrDj0hvCf2V7Z2bJEZkkNodZnayOVQ@mail.gmail.com> <5DE6FCCC-B89D-4556-885E-D2E4F0C5A64B@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox