wrong field in example

Started by PG Bug reporting formover 1 year ago7 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

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

In the second query, we could not have written SELECT * FROM test1 GROUP

BY x, because there is no single value for the column y that could be
associated with each group. The grouped-by columns can be referenced in the
select list since they have a single value in each group.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: wrong field in example

On Tuesday, July 23, 2024, PG Doc comments form <noreply@postgresql.org>
wrote:

The following documentation comment has been logged on the website:

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

In the second query, we could not have written SELECT * FROM test1 GROUP

BY x, because there is no single value for the column y that could be
associated with each group. The grouped-by columns can be referenced in the
select list since they have a single value in each group.

I think you mis-copied the query - the one on the page has “select x”, not
“select *”.

David J.

#3David Rowley
dgrowleyml@gmail.com
In reply to: David G. Johnston (#2)
Re: wrong field in example

On Thu, 25 Jul 2024, 12:57 am David G. Johnston, <david.g.johnston@gmail.com>
wrote:

I think you mis-copied the query - the one on the page has “select x”, not
“select *”.

That text exists as it was quoted. What the report is lacking is an
indication of what is wrong with the text.

David

Show quoted text
#4David G. Johnston
david.g.johnston@gmail.com
In reply to: David Rowley (#3)
Re: wrong field in example

On Wednesday, July 24, 2024, David Rowley <dgrowleyml@gmail.com> wrote:

On Thu, 25 Jul 2024, 12:57 am David G. Johnston, <
david.g.johnston@gmail.com> wrote:

I think you mis-copied the query - the one on the page has “select x”,
not “select *”.

That text exists as it was quoted. What the report is lacking is an
indication of what is wrong with the text.

Ok, I was just looking at the examples, thinking the report indicated a
broken example. I agree nothing seems wrong with the text and the report
has zero comment.

David J.

#5David G. Johnston
david.g.johnston@gmail.com
In reply to: David G. Johnston (#4)
Re: wrong field in example

Just noticed you replied to me only. Send replies to the list. You can
leave individuals cc'd. The convention here is also to inline your replies
- top-posting is undesirable.

In any case, in order to write "select *" you have to group on both x and y
at the same time. If you group on either column only, the query will
fail. So the choice of x versus y is immaterial. Having grouped on x the
text is explaining that the failure to also group on y is a problem.

I don't know that the existing wording is the most clear, but it is correct.

David J.

On Wed, Jul 24, 2024 at 8:02 AM Yaroslav Saburov <y.saburov@gmail.com>
wrote:

Show quoted text

because there is no single value for the column y that could be

associated with each group.

24 лип. 2024 р. о 17:51 David G. Johnston <david.g.johnston@gmail.com>
пише:



On Wed, Jul 24, 2024, 07:45 Yaroslav Saburov <y.saburov@gmail.com> wrote:

group by y, not by x

Why?

David J.

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#5)
Re: wrong field in example

"David G. Johnston" <david.g.johnston@gmail.com> writes:

I don't know that the existing wording is the most clear, but it is correct.

Perhaps it'd be better to write "... we could not have written
SELECT x, y FROM test1 GROUP BY x, because ..." ? The first
half of the example uses "SELECT *", and this bit was meant
to be consistent with that; but if the reader is confused about
how "y" got into the discussion then writing it out explicitly
should help.

regards, tom lane

#7Yaroslav Saburov
y.saburov@gmail.com
In reply to: Tom Lane (#6)
Re: wrong field in example

first query
=> SELECT * FROM test1;
x | y
---+---
a | 3
c | 2
b | 5
a | 1
(4 rows)

second query
=> SELECT x FROM test1 GROUP BY x;
x
---
a
b
c
(3 rows)
In the second query, we could not have written SELECT * FROM test1 GROUP BY x, because there is no single value for the column y that could be associated with each group. The grouped-by columns can be referenced in the select list since they have a single value in each group.

Show quoted text

24 лип. 2024 р. о 19:17 Tom Lane <tgl@sss.pgh.pa.us> пише:

"David G. Johnston" <david.g.johnston@gmail.com> writes:

I don't know that the existing wording is the most clear, but it is correct.

Perhaps it'd be better to write "... we could not have written
SELECT x, y FROM test1 GROUP BY x, because ..." ? The first
half of the example uses "SELECT *", and this bit was meant
to be consistent with that; but if the reader is confused about
how "y" got into the discussion then writing it out explicitly
should help.

regards, tom lane