X-Original-To: pgsql-bugs@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EE528475FD9; Sat, 22 Feb 2003 04:14:14 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 10733-10; Sat, 22 Feb 2003 04:14:04 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 228284760EF; Sat, 22 Feb 2003 03:05:49 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h1M85W5u012330; Sat, 22 Feb 2003 03:05:32 -0500 (EST) To: Stephan Szabo Cc: Dan Langille , pgsql-bugs@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] 7.3 GROUP BY differs from 7.2 In-reply-to: <20030221235057.H66979-100000@megazone23.bigpanda.com> References: <20030221235057.H66979-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Fri, 21 Feb 2003 23:57:48 -0800" Date: Sat, 22 Feb 2003 03:05:32 -0500 Message-ID: <12329.1045901132@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/108 X-Sequence-Number: 5524 Stephan Szabo writes: > On Fri, 21 Feb 2003, Tom Lane wrote: >> Anyone care to offer a gloss on the spec to prove that this behavior >> is correct or not correct? > Hmm, I'd read SQL92 Section 7.5 (joined tables) Syntax Rules as saying > that the non natural/using case is separate from the other cases. > Syntax rule 5 seems to say that A JOIN B ON (...) should have the same > column descriptors as A,B and it explicitly doesn't cover NATURAL or > USING (covered by rule 6). Yeah, but those rules only define the names and types of the JOIN's output columns. They don't say anything about the visibility of those names, nor the visibility of the underlying-table column names, nor particularly about semantic equivalence of the two sets of names. I spent some time digging around in the verbiage about name scopes, but didn't find any joy. It does seem clear that if you stick an alias on the JOIN as a whole, that that hides the individual table names/aliases, which would render the issue moot. But Dan didn't do that in his example, so he is allowed to access both the join columns and the underlying columns. Question is, are they equivalent for the purposes of the grouped-column-reference rules, or not? regards, tom lane