> 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.
> I backed out my patch, and discovered the bug was still present. The
> bug does not exist in version 6.3.2.
Nor in my cvs tree from around the second week in July (on or before
July 9, with a few patches committed to the Postgres tree afterwards).
Haven't tried a current source tree...
- Tom
>
> -- This crashes the backend
> select upper(a) as x, count(k) from t group by x;
tgl=> create table t (a text, k int);
CREATE
tgl=> select upper(a) as x, count(k) from t group by x;
x|count
-+-----
| 0
(1 row)
tgl=> insert into t values ('one', 1);
INSERT 643434 1
tgl=> insert into t values ('two', 2);
INSERT 643435 1
tgl=> insert into t values ('two', 2);
INSERT 643436 1
tgl=> select upper(a) as x, count(k) from t group by x;
x |count
---+-----
ONE| 1
TWO| 2
(2 rows)
And with your test case instead:
tgl=> select upper(a) as x, count(k) from t group by x;
x|count
-+-----
A| 4
B| 3
C| 3
(3 rows)