Re: Where's the doc for "array()" — as in "select array(values (17), (42))"

From: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Date: 2022-09-19 04:20:01
Message-ID: C167E3BD-B650-4A8E-80A3-3307E70883C0@yugabyte.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> adrian(dot)klaver(at)aklaver(dot)com wrote:
>
>> bryn(at)yugabyte(dot)com 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-dot-com. But it doesn't x-ref to the PG doc.
>
> www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS
>
>> 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%');

Thanks. I can't, even now, formulate a search that finds this—unless I know that it's a kind of array constructor. (I'll concede, with the benefit of hindsight, that I should have thought of that.) I hope that I'll be able to learn to navigate the PG docs better over time.

Why is the "array()" constructor not found in "pg_proc"? After all, section 4.2.12 refers to "array_agg()" as a constructor. And that *is* found in "pg_proc".

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-09-19 04:24:41 Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Previous Message David G. Johnston 2022-09-19 00:00:07 Re: Where's the doc for "array()" — as in "select array(values (17), (42))"