Re: [PATCH] doc: clarify AS requirement when VALUES used in a FROM clause

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] doc: clarify AS requirement when VALUES used in a FROM clause
Date: 2026-08-21 05:47:46
Message-ID: CAB8KJ=hEjmXL_ykTOVcgKwLjcqJn_TRahJ27-tz3JKv6p3soDw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2026年7月24日(金) 18:51 Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>:
>
> On Fri, 2026-07-24 at 18:12 +0900, Ian Lawrence Barwick wrote:
> > the VALUES documentation [*] still claims an AS clause is required
> > when VALUES is
> > used in a FROM clause. This has not been the case since PostgreSQL 16
> > (commit bcedd8f).
> >
> > [*] https://www.postgresql.org/docs/current/sql-values.html
> >
> > Attached patch reworks the offending sentence from:
> >
> > > Note that an AS clause is required when VALUES is used in a FROM clause, just
> > > as is true for SELECT. It is not required that the AS clause specify names for
> > > all the columns, but it's good practice to do so.
> >
> > to:
> >
> > > If VALUES is used in a FROM clause, it's not necessary to have an AS clause
> > > specifying names for each column, but it's good practice to do so.
>
> This should be changed, but I think the wording could be better:
>
> Note that if <command>VALUES</command> is used in a <literal>FROM</literal>
> clause, it is not necessary to specify an <literal>AS</literal> clause, but
> it is good practice to do so.
>
> Otherwise people might think that you need to specify an AS clause, but
> you can omit specifying the column names in the AS clause.

True, but that omits the point the original documentation is making,
i.e. that an
AS clause should preferably specify names for all columns, so:

Note that if <command>VALUES</command> is used in a
<literal>FROM</literal> clause,
it is not necessary to provide an <literal>AS</literal> clause, but
it's good practice
to do so and specify names for each column.

I.e. don't do something like SELECT * FROM (values (1,2)) AS f(foo).

Regards

Ian Barwick

Attachment Content-Type Size
v2-0001-doc-clarify-AS-requirement-when-VALUES-used-in-a-.patch text/x-patch 1.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mario González Troncoso 2026-08-21 05:52:14 Re: Credits For v19
Previous Message Ayush Tiwari 2026-08-21 05:36:11 RegisterShmemCallbacks() does nothing in single-user mode