Re: [SQL] What's wrong with this group by clause?

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: mkoi-pg(at)aon(dot)at
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] What's wrong with this group by clause?
Date: 2003-03-13 16:15:16
Message-ID: 3E70AE93.F370199A@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

>
> On Tue, 4 Nov 2003 18:28:12 -0300, Franco Bruno Borghesi
> <franco(at)akyasociados(dot)com(dot)ar> wrote:
> >Below you can find a simplified example of a real case.
> >I don't understand why I'm getting the "john" record twice.
>
> ISTM you have found a Postgres 7.3 bug.
>
> I get one john with
> PostgreSQL 7.1.3 on i686-pc-cygwin, compiled by GCC 2.95.3-5
> and
> PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.7.2.1
>
> but two johns with
> PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.7.2.1
>
> >/*EXAMPLE*/
> >CREATE TABLE people
> >(
> > name TEXT
> >);
> >INSERT INTO people VALUES ('john');
> >INSERT INTO people VALUES ('john');
> >INSERT INTO people VALUES ('pete');
> >INSERT INTO people VALUES ('pete');
> >INSERT INTO people VALUES ('ernest');
> >INSERT INTO people VALUES ('john');
> >
> >SELECT
> > 0 AS field1,
> > 0 AS field2,
> > name
> >FROM
> > people
> >GROUP BY
> > field1,
> > field2,
> > name;
> >
> > field1 | field2 | name
> >--------+--------+--------
> > 0 | 0 | john
> > 0 | 0 | pete
> > 0 | 0 | ernest
> > 0 | 0 | john
> >(4 rows)
>
PostgreSQL 7.2.3 on hppa-hp-hpux10.20, compiled by GCC 2.95.2

SELECT 0 AS field1, 0 AS field2, name FROM people GROUP BY
field1, field2, name;
field1 | field2 | name
--------+--------+--------
0 | 0 | ernest
0 | 0 | john
0 | 0 | pete
(3 rows)

PostgreSQL 7.3.2 on hppa-hp-hpux10.20, compiled by GCC 2.95.2

SELECT 0 AS field1, 0 AS field2, name FROM people GROUP BY
field1, field2, name;
field1 | field2 | name
--------+--------+--------
0 | 0 | john
0 | 0 | pete
0 | 0 | john
0 | 0 | pete
0 | 0 | john
0 | 0 | ernest
(6 rows)

I doubt this is a bug in 7.3.2 but in prior versions.
I've cross-checked how another DBMS (HP's ALLBASE) handles GROUP BY
without an aggregate, and it acts like 7.3.2.

Regards, Christoph

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-03-13 16:50:32 Re: SQL99 ARRAY support proposal
Previous Message Marc G. Fournier 2003-03-13 16:12:33 Re: Roadmap for FE/BE protocol redesign

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-03-13 17:02:55 Re: [SQL] What's wrong with this group by clause?
Previous Message Richard Huxton 2003-03-13 15:26:20 A Brief Real-World Trigger Example