[PATCH] doc: clarify AS requirement when VALUES used in a FROM clause
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
This thread has been committed, so CI has stopped here. Anything below is the last result it produced.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t253185psql -h localhost -U postgresBuilt from patchset v8 (message #8), September 01, 2026 at 07:01 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t253185_8 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t253185_8 && git checkout t253185_8Patchset v8 (message #8) is on t253185_8
Hi
Per comment here:
/messages/by-id/178484951486.1225.14869692065642101159@wrigleys.postgresql.org
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.
Regards
Ian Barwick
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.
Yours,
Laurenz Albe
2026年7月24日(金) 18:51 Laurenz Albe <laurenz.albe@cybertec.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
On Fri, Aug 21, 2026 at 2:48 PM Ian Lawrence Barwick <barwick@gmail.com> 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.
Regards,
--
Fujii Masao
2026年8月21日(金) 16:01 Fujii Masao <masao.fujii@gmail.com>:
On Fri, Aug 21, 2026 at 2:48 PM Ian Lawrence Barwick <barwick@gmail.com> 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 forEven 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!
Regards
Ian Barwick
2026年8月21日(金) 16:15 Ian Lawrence Barwick <barwick@gmail.com>:
2026年8月21日(金) 16:01 Fujii Masao <masao.fujii@gmail.com>:
On Fri, Aug 21, 2026 at 2:48 PM Ian Lawrence Barwick <barwick@gmail.com> 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 forEven 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
On Fri, Aug 21, 2026 at 7:06 PM Ian Lawrence Barwick <barwick@gmail.com> wrote:
Revised patch attached.
Thanks for updating the patch!
I was initially thinking this patch should be backpatched to v16, where
commit bcedd8f appeared. However, since an AS clause is optional even
in v14 and v15, while the table alias itself is required there, should
"an AS clause" in the original description be changed to "a table alias"
for v14 and v15 as well?
+ clause, a table alias is optional. Assigning alias names to the columns
+ of the <command>VALUES</command> list is optional, but is good practice.
In queries.sgml, writing a table alias is also described as good
practice according to the SQL standard. So we could mention here that
writing a table alias is good practice as well. But, since this is
already covered in queries.sgml and it seems a bit overkill to repeat
it here, I'm fine with mentioning only assigning alias names to the
columns as good practice.
Thoughts?
Regards,
--
Fujii Masao
2026年8月21日(金) 23:27 Fujii Masao <masao.fujii@gmail.com>:
On Fri, Aug 21, 2026 at 7:06 PM Ian Lawrence Barwick <barwick@gmail.com> wrote:
Revised patch attached.
Thanks for updating the patch!
I was initially thinking this patch should be backpatched to v16, where
commit bcedd8f appeared. However, since an AS clause is optional even
in v14 and v15, while the table alias itself is required there, should
"an AS clause" in the original description be changed to "a table alias"
for v14 and v15 as well?
Good point! Patch attached for v14/v15.
+ clause, a table alias is optional. Assigning alias names to the columns + of the <command>VALUES</command> list is optional, but is good practice.In queries.sgml, writing a table alias is also described as good
practice according to the SQL standard. So we could mention here that
writing a table alias is good practice as well. But, since this is
already covered in queries.sgml and it seems a bit overkill to repeat
it here, I'm fine with mentioning only assigning alias names to the
columns as good practice.
Yes, I think we can keep it simple here, the main objective is to correct
the inaccuracy, not write an SQL style guide ;).
Regards
Ian Barwick
On Fri, Aug 28, 2026 at 3:08 PM Ian Lawrence Barwick <barwick@gmail.com> wrote:
Yes, I think we can keep it simple here, the main objective is to correct
the inaccuracy, not write an SQL style guide ;).
Agreed. I've pushed the patch. Thanks!
Regards,
--
Fujii Masao
2026年9月1日(火) 22:56 Fujii Masao <masao.fujii@gmail.com>:
On Fri, Aug 28, 2026 at 3:08 PM Ian Lawrence Barwick <barwick@gmail.com> wrote:
Yes, I think we can keep it simple here, the main objective is to correct
the inaccuracy, not write an SQL style guide ;).Agreed. I've pushed the patch. Thanks!
Many thanks!
Regards
Ian Barwick