Re: [HACKERS] Open 6.5 items - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Open 6.5 items
Date
Msg-id 999.927146427@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Open 6.5 items  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian <maillist@candle.pha.pa.us> writes:
> That is an excellent point.  GROUP BY has to use a column name, and they
> have to be unique, while WHERE does not require stuff to be in the
> target list, so there is a change of ambiguity.  I am going to remove
> the item from the list.

Good point --- consider this:SELECT a, b AS a FROM tt GROUP BY a;
We do get it right: "ERROR:  GROUP BY 'a' is ambiguous".
Whereas inSELECT a, b AS a FROM tt WHERE a = 1;
the WHERE clause is taken as referring to the "real" column a.

So, unless there's some violation of spec behavior here, there is a
reason for GROUP BY to behave differently from WHERE.  I think I was
the one who complained that they were different --- I withdraw the
complaint.

BTW, which behavior should ORDER BY exhibit?  I find thatSELECT a, b AS a FROM tt ORDER BY a;
is accepted and 'a' is taken to be the real column a.  Considering that
ORDER BY is otherwise much like GROUP BY, I wonder whether it shouldn't
complain that 'a' is ambiguous...
        regards, tom lane


pgsql-hackers by date:

Previous
From: "E Westfield"
Date:
Subject: Looking for Mr. Autonum
Next
From: Charles Tassell
Date:
Subject: Re: [GENERAL] Looking for Mr. Autonum