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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Дата
Msg-id 456815.1663607116@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Where's the doc for "array()" — as in "select array(values (17), (42))"  (Bryn Llewellyn <bryn@yugabyte.com>)
Список pgsql-general
Bryn Llewellyn <bryn@yugabyte.com> writes:
> This works fine:
>   select length( (select 'dog') )
> But without the doubled parentheses, it causes a syntax error.

The parens are required for it to be a valid scalar subquery, as per
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-SCALAR-SUBQUERIES

The reason ARRAY() is different is exactly that its argument is
directly a subquery, not an expression that chances to be a
scalar subquery.

> On the other hand, an extra pair of surrounding parentheses here
>   select array( (values (17), (42)) )
> while not necessary, *is* tolerated.

You can pretty much always add *extra* parens in any expression
context.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Where's the doc for "array()" — as in "select array(values (17), (42))"
Следующее
От: Bryn Llewellyn
Дата:
Сообщение: I slipped up so that no existing role allows connection. Is rescue possible?