2026年8月21日(金) 16:15 Ian Lawrence Barwick <[email protected]>:
>
> 2026年8月21日(金) 16:01 Fujii Masao <[email protected]>:
> >
> > On Fri, Aug 21, 2026 at 2:48 PM Ian Lawrence Barwick <[email protected]> 
> > wrote:
> > > 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).
> >
> > Thanks for updating the patch!
> >
> > +   <command>VALUES</command> are
> > <literal>column1</literal>,<literal>column2</literal>,
> >
> > A space should be added just after "<literal>column1</literal>,".
> >
> >
> > +   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. (The default column names 
> > for
> >
> > Even when an alias is supplied, the AS keyword itself is optional, e.g.
> > FROM (VALUES (1, 2)) v(a, b). So I think it's better to avoid saying
> > "AS clause" here.  Instead, how about using wording similar to queries.sgml,
> > as follows?
> >
> >     Note that if <command>VALUES</command> is used in a 
> > <literal>FROM</literal>
> >     clause, a table alias is optional.  Assigning alias names to the columns
> >     of the <command>VALUES</command> list is optional, but is good practice.
>
> Oh yes, that sounds much better!

Revised patch attached.


Regards

Ian Barwick
From 8b9d5927be0471c0eb77843d2fed360e614b9325 Mon Sep 17 00:00:00 2001
From: Ian Barwick <[email protected]>
Date: Fri, 21 Aug 2026 19:03:55 +0900
Subject: [PATCH v3] doc: clarify AS requirement when VALUES used in a FROM
 clause

From PostgreSQL 16 (commit bcedd8f), subquery aliases in the FROM clause
are optional, so update the VALUES reference documentation to reflect
this.
---
 doc/src/sgml/ref/values.sgml | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/ref/values.sgml b/doc/src/sgml/ref/values.sgml
index 4bf7bfdffee..8536d065aad 100644
--- a/doc/src/sgml/ref/values.sgml
+++ b/doc/src/sgml/ref/values.sgml
@@ -198,10 +198,9 @@ UPDATE employees SET salary = salary * v.increase
   WHERE employees.depno = v.depno AND employees.sales &gt;= v.target;
 </programlisting>
 
-   Note that an <literal>AS</literal> clause is required when <command>VALUES</command>
-   is used in a <literal>FROM</literal> clause, just as is true for
-   <command>SELECT</command>.  It is not required that the <literal>AS</literal> clause
-   specify names for all the columns, but it's good practice to do so.
+   Note that if <command>VALUES</command> is used in a <literal>FROM</literal>
+   clause, a table alias is optional.  Assigning alias names to the columns
+   of the <command>VALUES</command> list is optional, but is good practice.
    (The default column names for <command>VALUES</command> are <literal>column1</literal>,
    <literal>column2</literal>, etc. in <productname>PostgreSQL</productname>, but
    these names might be different in other database systems.)
-- 
2.43.0

Reply via email to