Re: remark regarding 4.2.13. Row Constructors

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: jochen(dot)bandhauer(at)gmx(dot)net, PostgreSQL-documentation <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: remark regarding 4.2.13. Row Constructors
Date: 2026-06-09 16:46:38
Message-ID: 891848.1781023598@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Daniel Gustafsson <daniel(at)yesql(dot)se> writes:
>> On 8 Jun 2026, at 09:42, PG Doc comments form <noreply(at)postgresql(dot)org> wrote:
>> in
>> https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS
>> there is:
>> "The key word ROW is optional when there is more than one expression in the
>> list."
>> I think it should be:
>> "The key word ROW is optional when there are more than zero expressions in
>> the list."

> "more than zero" sounds a bit odd, my suggestion would be "The key word ROW is
> optional when there is one, or more, expressions in the list."

More to the point, the statement is correct as written and either of
these changes would make it wrong. For example, both of these things
produce a two-column composite value:

postgres=# select row(1,2), (1,2);
row | row
-------+-------
(1,2) | (1,2)
(1 row)

postgres=# select pg_typeof(row(1,2)), pg_typeof((1,2));
pg_typeof | pg_typeof
-----------+-----------
record | record
(1 row)

But adding more parentheses around a scalar value does not make
it a composite value:

postgres=# select row(1), (1), ((((1))));
row | ?column? | ?column?
-----+----------+----------
(1) | 1 | 1
(1 row)

postgres=# select pg_typeof(row(1)), pg_typeof((1)), pg_typeof(((((1)))));
pg_typeof | pg_typeof | pg_typeof
-----------+-----------+-----------
record | integer | integer
(1 row)

Maybe there is something we can do to make this clearer, but
the above isn't it.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Peter Eisentraut 2026-06-10 13:16:28 Re: Patch for bind message to clarify signedness of parameters and result column format codes
Previous Message Dave Cramer 2026-06-09 11:51:54 Patch for bind message to clarify signedness of parameters and result column format codes