Small bug in GROUP BY

From: Andriy I Pilipenko <bamby(at)marka(dot)net(dot)ua>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Small bug in GROUP BY
Date: 2000-06-29 13:42:34
Message-ID: Pine.BSF.4.21.0006291547420.437-100000@bamby.marka.net.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Andriy I Pilipenko
Your email address : bamby(at)marka(dot)net(dot)ua

System Configuration
---------------------
Architecture (example: Intel Pentium) : Intel Pentium

Operating System (example: Linux 2.0.26 ELF) : FreeBSD-3.x

PostgreSQL version (example: PostgreSQL-7.0): PostgreSQL-7.0.2
PostgreSQL-7.0beta5

Compiler used (example: gcc 2.8.0) : gcc 2.7.2.3

Please enter a FULL description of your problem:
------------------------------------------------

This problem is new to version 7. In PostgreSQL 6.x this problem not
present.

There is a bug where backend dumps core while executing such a request:

SELECT sum(a), b
FROM t
GROUP BY b
UNION SELECT sum(a), 1 as b
FROM t
GROUP BY b

I know, that last 'GROUP BY' clause is not necessary to use, but it's not
necessary for backend to dump core in such a harmless situation ;-) This
query works pretty well without last 'GROUP BY' clause.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

First create the table:

CREATE TABLE t (a int, b int)

Next insert some data into the table. It's necessary part - without data
you cannot catch the bug.

INSERT INTO t VALUES (0, 0)

And finally:

SELECT sum(a), b
FROM t
GROUP BY b
UNION SELECT sum(a), 1 as b
FROM t
GROUP BY b

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Sorry, I don't :-(

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2000-06-29 15:51:16 Re: Small bug in GROUP BY
Previous Message Sergei Laskavy 2000-06-28 08:18:02 compilation of PostgreSQL 7.0.2 fails on Sun Solaris 2.5.1 using gcc 2.95.2 in interfaces/libpq++ if GNU ld is first in the $PATH