public inbox for [email protected]  
help / color / mirror / Atom feed
7.2.1. The FROM Clause
9+ messages / 4 participants
[nested] [flat]

* 7.2.1. The FROM Clause
@ 2026-06-12 09:58 PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: PG Doc comments form @ 2026-06-12 09:58 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

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







^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
@ 2026-06-14 20:09 ` Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Laurenz Albe @ 2026-06-14 20:09 UTC (permalink / raw)
  To: [email protected]; [email protected]

On Fri, 2026-06-12 at 09:58 +0000, PG Doc comments form wrote:
> 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.

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





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
@ 2026-06-14 20:40   ` Tom Lane <[email protected]>
  2026-06-15 06:39     ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-15 20:35     ` Re: 7.2.1. The FROM Clause Christoph Berg <[email protected]>
  0 siblings, 2 replies; 9+ messages in thread

From: Tom Lane @ 2026-06-14 20:40 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]; [email protected]

Laurenz Albe <[email protected]> writes:
> 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.

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






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
@ 2026-06-15 06:39     ` Laurenz Albe <[email protected]>
  2026-06-15 15:05       ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  1 sibling, 1 reply; 9+ messages in thread

From: Laurenz Albe @ 2026-06-15 06:39 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]

On Sun, 2026-06-14 at 16:40 -0400, Tom Lane wrote:
> Laurenz Albe <[email protected]> writes:
> > 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.
> 
> 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.

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


Attachments:

  [text/x-patch] v1-0001-Reword-doc-for-asterisk-after-table-names.patch (1.8K, ../../[email protected]/2-v1-0001-Reword-doc-for-asterisk-after-table-names.patch)
  download | inline diff:
From 2a3cfb32c7f3fd626617d075ba4f0f3e2818b4e4 Mon Sep 17 00:00:00 2001
From: Laurenz Albe <[email protected]>
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 protected]>
Author: Laurenz Albe <[email protected]>
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



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 06:39     ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
@ 2026-06-15 15:05       ` Tom Lane <[email protected]>
  2026-06-15 15:24         ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2026-06-15 15:05 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]; [email protected]

Laurenz Albe <[email protected]> writes:
> 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.

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






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 06:39     ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-15 15:05       ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
@ 2026-06-15 15:24         ` Laurenz Albe <[email protected]>
  2026-06-15 17:14           ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Laurenz Albe @ 2026-06-15 15:24 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]

On Mon, 2026-06-15 at 11:05 -0400, Tom Lane wrote:
> Laurenz Albe <[email protected]> writes:
> > 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.
> 
> 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 did, and * became obsolete with 7.1.  It's even in the release notes.

> 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".

I am fine with both your suggestions.

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 06:39     ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-15 15:05       ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 15:24         ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
@ 2026-06-15 17:14           ` Tom Lane <[email protected]>
  2026-06-15 17:35             ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2026-06-15 17:14 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]; [email protected]

Laurenz Albe <[email protected]> writes:
> On Mon, 2026-06-15 at 11:05 -0400, Tom Lane wrote:
>> I can look up the version where it changed, if this seems like the way
>> to go.

> 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





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 06:39     ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-15 15:05       ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
  2026-06-15 15:24         ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-15 17:14           ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
@ 2026-06-15 17:35             ` Laurenz Albe <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Laurenz Albe @ 2026-06-15 17:35 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]

On Mon, 2026-06-15 at 13:14 -0400, Tom Lane wrote:
> Pushed with those changes.

Thanks for improving PostgreSQL!

Laurenz Albe






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: 7.2.1. The FROM Clause
  2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
  2026-06-14 20:09 ` Re: 7.2.1. The FROM Clause Laurenz Albe <[email protected]>
  2026-06-14 20:40   ` Re: 7.2.1. The FROM Clause Tom Lane <[email protected]>
@ 2026-06-15 20:35     ` Christoph Berg <[email protected]>
  1 sibling, 0 replies; 9+ messages in thread

From: Christoph Berg @ 2026-06-15 20:35 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Laurenz Albe <[email protected]>; [email protected]; [email protected]

Re: Tom Lane
> 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.

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






^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2026-06-15 20:35 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12 09:58 7.2.1. The FROM Clause PG Doc comments form <[email protected]>
2026-06-14 20:09 ` Laurenz Albe <[email protected]>
2026-06-14 20:40   ` Tom Lane <[email protected]>
2026-06-15 06:39     ` Laurenz Albe <[email protected]>
2026-06-15 15:05       ` Tom Lane <[email protected]>
2026-06-15 15:24         ` Laurenz Albe <[email protected]>
2026-06-15 17:14           ` Tom Lane <[email protected]>
2026-06-15 17:35             ` Laurenz Albe <[email protected]>
2026-06-15 20:35     ` Christoph Berg <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox