From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
To: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Date: Sun, 18 Sep 2022 13:29:31 -0700
Message-ID: <e6ac86e5-39f4-9704-7260-3f6c40c63b2d@aklaver.com> (raw)
In-Reply-To: <F2DA0774-0B4D-4E72-8944-116154A57D98@yugabyte.com>
References: <F2DA0774-0B4D-4E72-8944-116154A57D98@yugabyte.com>
On 9/18/22 13:25, Bryn Llewellyn wrote:
> I noticed that "array()" is used in the query that implements the "\du"
> psql meta-command. It has some similarity with "array_agg()" thus:
>
> create temporary view x(v) as (values (17), (42));
> select array_agg(v) from x;
> select array(select v from x);
>
> Anyway, I can't find where "array()" is documented. Google does find me
> a hit on stackexchange.com <http://stackexchange.com;. But it doesn't
> x-ref to the PG doc.
https://www.postgresql.org/docs/current/sql-expressions.html
4.2.12. Array Constructors
"It is also possible to construct an array from the results of a
subquery. In this form, the array constructor is written with the key
word ARRAY followed by a parenthesized (not bracketed) subquery. For
example:
SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
..."
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, bryn@yugabyte.com
Subject: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
In-Reply-To: <e6ac86e5-39f4-9704-7260-3f6c40c63b2d@aklaver.com>
References: <F2DA0774-0B4D-4E72-8944-116154A57D98@yugabyte.com> <e6ac86e5-39f4-9704-7260-3f6c40c63b2d@aklaver.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