6.4 Aggregate Bug

From: David Hartwig <daybee(at)bellatlantic(dot)net>
To: hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: 6.4 Aggregate Bug
Date: 1998-08-01 09:19:43
Message-ID: 35C2DDAF.4E174FC0@bellatlantic.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While testing my 6.4 patch to allow functions/expressions to be
specified in the ORDER/GROUP BY clause (and not in the target list) I
came across a nasty little bug. A segmentation fault gets thrown
somewhere in replace_agg_clause() when using aggregates, in combination
with a function or expression. (I am still tracking down the
offending lines of code. Sorry, the Linux/GCC environment is still new
to me.)

I backed out my patch, and discovered the bug was still present. The
bug does not exist in version 6.3.2. Here is an example:

-- This crashes the backend
select upper(a) as x, count(k) from t group by x;

-- This works fine
select upper(a) as x, count(a) from t group by x;

Notice how in the first query, (the one that does not work) upper() has
a different argument than count(). And in the second query (the one
that works) upper() has the same argument as count(). When using
count(*) it will always fail.

This is the the pattern that I have observed. If the arguments in the
aggregate and non-aggregate functions are the same, it runs; if the
arguments in the aggregate and non-aggregate functions are different, it
crashes.

I have attached a test script for anyone able to help with (or verify)
this problem.

Attachment Content-Type Size
t.sql text/plain 919 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 1998-08-01 10:06:55 Re: [HACKERS] Dropping tables...
Previous Message Peter T Mount 1998-08-01 08:18:42 Re: [HACKERS] User authentication bug?