From: j knight <enabled@myrealbox.com>
To: pgsql-sql@postgresql.org
Subject: Aggregate function error in 7.4
Date: Tue, 27 Jan 2004 23:36:55 -0700
Message-ID: <40175887.2080108@myrealbox.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: enabled@myrealbox.com
Subject: Re: Aggregate function error in 7.4
In-Reply-To: <40175887.2080108@myrealbox.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox