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_pkPRIMARY KEY (day, address)
);
CREATE TABLE maillog_recv ( day date NOT NULL, tally integer NOT NULL, address text NOT NULL, CONSTRAINT
maillog_recv_pkPRIMARY 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