Re: SELECT List with/without parentheses

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "jason(at)starnull(dot)net" <jason(at)starnull(dot)net>, "pgsql-docs(at)lists(dot)postgresql(dot)org" <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: SELECT List with/without parentheses
Date: 2025-09-05 21:11:32
Message-ID: CAKFQuwZ5v-+HcoSy3TKOBPk1+TDMcM7iHq-VCh+d-ZvdC3QnMw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thursday, September 4, 2025, PG Doc comments form <noreply(at)postgresql(dot)org>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/17/sql-select.html
> Description:
>
> Here: https://www.postgresql.org/docs/current/sql-select.html
>
> There is no mention of the difference in PostgreSql behavior if the select
> list of columns is surrounded by parentheses or not. The difference is
> quite
> dramatic and non-obvious, especially when working with a database driver
> (like pq or pqxx) where the result is packed up in a fairly opaque object.
> Just some mention of how using parentheses causes a query to return a "row"
> object that represents the tuple as a single string vs not using
> parentheses
> where each column is represented individually.
>

That kind of material usually goes in the syntax chapter since it isn’t
special to a select command or really any command in particular.

The documentation does explain that to create a row-like composite from
individual columns you use [row](…).

https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS

The select command itself states what it does: each column - and the column
list is not parenthesized - becomes a column in the result.

I admit it’s definitely not easy to try making up some new syntax, finding
that it works, then looking for the feature in the documentation from the
syntax alone. But that is also not usually how one learns. In short, I’m
against updating “select” but would entertain some other concrete
suggestion since I don’t find this scenario rare enough to just ignore and
deal with via Q&A.

David J.

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2025-09-05 21:17:02 Re: SELECT List with/without parentheses
Previous Message Pierrick 2025-09-05 13:53:09 Adding clarification on extension_control_path when extension is present in multiple folders