pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Peter Eisentraut <peter_e@gmx.net>
To: Dan Langille <dan@langille.org>
Cc: Chad Thompson <chad@weblinkservices.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: 7.3 "group by" issue
Date: Sat, 22 Feb 2003 11:34:45 -0800
Message-ID: <200302221134.45226.josh@agliodbs.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0302220245460.2067-100000@peter.localdomain>
References: <Pine.LNX.4.44.0302220245460.2067-100000@peter.localdomain>

Peter,

> This does not work because the first select list item references a column
> inside a join, which is not (necessarily) mathematically identical to the
> column that arrives outside of the join and is in the GROUP BY clause.
> (Think of an outer join: the column outside the join might contain added
> null values.  Of course you are using an inner join, but the constructs
> work the same either way.)

Hmmm ... I don't see that.   I can see that it might be practically 
difficult-to-impossible to make the planner distinguish between cases where 
the columns in the select list are different from the columns in the JOIN 
series and when they aren't, but as a theory issue I just don't buy it.

What Dan's doing is:

SELECT a.c1, count(a.c2)
FROM a JOIN b
WHERE b.c5 = x
GROUP BY c1

In a case like this, a.c1 == c1 without possibility of ambiguity.  The only 
difference is whether or not a table qualifier is used on the name, which in 
theory should *only* make a difference when there are more than one table in 
the query with that column name.   

So if you're saying that that kind of equivalency is a challenging parser 
implementation issue, then I'm with you.   If you're saying its a SQL theory 
issue, though, I don't agree at all.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (14+ messages)  latest in thread

Message-ID: <200302221134.45226.josh@agliodbs.com>
Permalink:  ../200302221134.45226.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200302221134.45226.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, peter_e@gmx.net, dan@langille.org, chad@weblinkservices.com
  Subject: Re: 7.3 "group by" issue
  In-Reply-To: <200302221134.45226.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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