From: | j knight <enabled(at)myrealbox(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Aggregate function error in 7.4 |
Date: | 2004-01-28 06:36:55 |
Message-ID: | 40175887.2080108@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all.
I'm trying to migrate from 7.3.4 to 7.4.1. I've performed a pg_dumpall
using the pg_dumpall from 7.4.1. Once 7.4 is running and I try to import
the dump, I get the following error:
psql:pgsql.dump:301: ERROR: column "r.day" must appear in the GROUP BY
clause or be used in an aggregate function
The SQL it's choking on is:
CREATE VIEW maillog_day_tally AS
SELECT
day,
COALESCE(sum(r.tally), 0) AS received,
COALESCE(sum(s.tally), 0) AS sent
FROM
maillog_recv r FULL JOIN maillog_sent s USING (day, address)
GROUP BY day;
The tables:
CREATE TABLE maillog_sent (
day date NOT NULL,
tally integer NOT NULL,
address text NOT NULL,
CONSTRAINT maillog_sent_pk PRIMARY KEY (day, address)
);
CREATE TABLE maillog_recv (
day date NOT NULL,
tally integer NOT NULL,
address text NOT NULL,
CONSTRAINT maillog_recv_pk PRIMARY KEY (day, address)
);
Of course if I change the query to read "SELECT r.day ..." it will
parse, however, I need to be able to select the day column from the
result of the JOIN, not just from one of the two tables.
I'm at a loss to explain why 7.4 is treating that SELECT query
differently than previous versions. I can't see anything in the 7.4
release notes that would help explain this. Can anyone provide any insight?
maillog=> select version();
version
---------------------------------------------------------------------
PostgreSQL 7.4.1 on i386-unknown-freebsd4.7, compiled by GCC 2.95.4
.joel
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-01-28 07:50:01 | Re: Aggregate function error in 7.4 |
Previous Message | Raman Garg | 2004-01-28 06:09:23 | Re: Query TIME ZONE |