Subject: 7.2.1. The FROM Clause

From: PG Doc comments form <[email-masked]>
Date: Fri, 12 Jun 2026 09:58:36 +0000

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/queries-table-expressions.html
Description:

I have a question regarding:
https://www.postgresql.org/docs/current/queries-table-expressions.html#QUERIES-FROM
Is the following sentence from the docu correct?
"Instead of writing ONLY before the table name, you can write * after the
table name to explicitly specify that descendant tables are included."

I read it like you can use "* after the table name" instead of "ONLY before
the table name" which seems wrong.

Thanks
Jochen

---

From: Laurenz Albe <[email-masked]>
Date: Sun, 14 Jun 2026 22:09:34 +0200

> the table name" which seems wrong.

The "instead" does not mean that "tab *" is a substitute for "ONLY tab",
but is meant to mean that you cannot use both at the same time, like "ONLY tab *".

But I understand your confusion.  To be honest, I only learned about the syntax
"tab *" a few days ago.  Digging through the history, this syntax has been
obsolete since 2000.  I think we could remove both the paragraph that confuses
you and the asterisk from the syntax diagram.  We can leave the obsolete
syntax to accomodate SQL code that hasn't changed for over 25 years, but I don't
see a reason to keep it in the documentation.

Yours,
Laurenz Albe

---

From: Tom Lane <[email-masked]>
Date: Sun, 14 Jun 2026 16:40:34 -0400

> see a reason to keep it in the documentation.

I think we've discussed that before, and concluded that removing the
docs would be a disservice to users who are trying to read old code
that does this and don't know what it means.  Maybe that argument
is too weak now to justify keeping the docs, but I'm unsure.
I'd be inclined to just rephrase this sentence in hopes of making
it less ambiguous.

			regards, tom lane

---

From: Laurenz Albe <[email-masked]>
Date: Mon, 15 Jun 2026 08:39:05 +0200

On Sun, 2026-06-14 at 16:40 -0400, Tom Lane wrote:
> > To be honest, I only learned about the syntax
> > you and the asterisk from the syntax diagram.
> 

Fine by me; here is a patch.

I could not resist the temptation to remove the "now always" in
"searching descendant tables is now always the default".  That sounds
too much like this was a recent change.

Yours,
Laurenz Albe
From 2a3cfb32c7f3fd626617d075ba4f0f3e2818b4e4 Mon Sep 17 00:00:00 2001
From: Laurenz Albe <[email-masked]>
Date: Mon, 15 Jun 2026 08:34:27 +0200
Subject: [PATCH v1] Reword doc for asterisk after table names

The syntax "tablename *" has been obsolete since 7.1, but we want
to retain it and its documentation for backward compatibility
reasons.  However, the wording was confusing and could be understood
to mean that "tablename *" is the same as "ONLY tablename".

Reported-by: Jochen Bandhauer <[email-masked]>
Author: Laurenz Albe <[email-masked]>
Discussion: https://postgr.es/m/178125831604.1285960.8250607197280951685%40wrigleys.postgresql.org
---
 doc/src/sgml/queries.sgml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml
index ec4ca01cd16..3096b986a09 100644
--- a/doc/src/sgml/queries.sgml
+++ b/doc/src/sgml/queries.sgml
@@ -143,10 +143,10 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
    </para>
 
    <para>
-    Instead of writing <literal>ONLY</literal> before the table name, you can write
-    <literal>*</literal> after the table name to explicitly specify that descendant
-    tables are included.  There is no real reason to use this syntax any more,
-    because searching descendant tables is now always the default behavior.
+    You can write <literal>*</literal> after the table name to explicitly
+    specify that descendant tables are included, which is the opposite of
+    <literal>ONLY</literal>.  There is no real reason to use this syntax
+    any more, because searching descendant tables is the default behavior.
     However, it is supported for compatibility with older releases.
    </para>
 
-- 
2.54.0

---

From: Tom Lane <[email-masked]>
Date: Mon, 15 Jun 2026 11:05:52 -0400

> too much like this was a recent change.

Hmm, phrasing that part that way sounds like it's always been so,
which is not only false but is contradicted by the surrounding text.
What do you think of saying

    There is no real reason to use this syntax
    any more, because searching descendant tables has been the default
    behavior since PostgreSQL whatever-version-it-was.

I can look up the version where it changed, if this seems like the way
to go.

I'm also tempted to replace "to use this syntax" with "to write *",
just to be totally clear which syntax we are referring to.  After
your rewrite of the prior sentence, someone might think the closest
antecedent for "this" is "ONLY".

			regards, tom lane

---

From: Laurenz Albe <[email-masked]>
Date: Mon, 15 Jun 2026 17:24:49 +0200

> I can look up the version where it changed, if this seems like the way

I did, and * became obsolete with 7.1.  It's even in the release notes.

> antecedent for "this" is "ONLY".

I am fine with both your suggestions.

Yours,
Laurenz Albe

---

From: Tom Lane <[email-masked]>
Date: Mon, 15 Jun 2026 13:14:28 -0400

> I did, and * became obsolete with 7.1.  It's even in the release notes.

Well, not really.  7.1 changed this behavior to depend on the
sql_inheritance GUC.  It wasn't till v10 when we removed that GUC
(see e13486eba) that you could really safely assume that an
undecorated table name includes child tables.  So I think we should
say it's obsolete since v10 not 7.1.

Pushed with those changes.

			regards, tom lane

---

From: Laurenz Albe <[email-masked]>
Date: Mon, 15 Jun 2026 19:35:45 +0200

> Pushed with those changes.

Thanks for improving PostgreSQL!

Laurenz Albe

---

From: Christoph Berg <[email-masked]>
Date: Mon, 15 Jun 2026 22:35:37 +0200

Re: Tom Lane
> is too weak now to justify keeping the docs, but I'm unsure.

Fwiw, I saw that syntax somewhere some days back and then went looking
what it meant. I did find it in psql's "\h select" and in turn the
full SELECT documentation. I guess if the docs had not mentioned it, I
would have had to read the grammar, and looking for a non-string in
there sounds painful.

So it should definitely be kept. Thanks. :)

Christoph