X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A855CD1D3F6 for ; Wed, 28 Jan 2004 06:42:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39857-07 for ; Wed, 28 Jan 2004 02:41:57 -0400 (AST) Received: from pd4mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by svr1.postgresql.org (Postfix) with ESMTP id E24E4D1D42F for ; Wed, 28 Jan 2004 02:41:55 -0400 (AST) Received: from pd3mr1so.prod.shaw.ca (pd3mr1so-ser.prod.shaw.ca [10.0.141.177]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0HS600H7AT1BRN@l-daemon> for pgsql-sql@postgresql.org; Tue, 27 Jan 2004 23:36:47 -0700 (MST) Received: from pn2ml9so.prod.shaw.ca (pn2ml9so-qfe0.prod.shaw.ca [10.0.121.7]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0HS600JKDT1BIR@l-daemon> for pgsql-sql@postgresql.org; Tue, 27 Jan 2004 23:36:47 -0700 (MST) Received: from myrealbox.com (h68-146-184-143.cg.shawcable.net [68.146.184.143]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0HS60017CT1AXB@l-daemon> for pgsql-sql@postgresql.org; Tue, 27 Jan 2004 23:36:47 -0700 (MST) Date: Tue, 27 Jan 2004 23:36:55 -0700 From: j knight Subject: Aggregate function error in 7.4 To: pgsql-sql@postgresql.org Message-id: <40175887.2080108@myrealbox.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/229 X-Sequence-Number: 16622 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