Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 55B7BB5DC4D for ; Tue, 12 Jul 2011 12:25:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 02989-01 for ; Tue, 12 Jul 2011 15:25:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 19526B5DBE5 for ; Tue, 12 Jul 2011 12:25:21 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 1B89334C395; Tue, 12 Jul 2011 08:25:21 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8hQkv725r7Bs; Tue, 12 Jul 2011 08:25:19 -0700 (PDT) Received: from perhan.alvh.no-ip.org (unknown [190.95.21.209]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id 0247934C392; Tue, 12 Jul 2011 08:25:19 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 20BC26E5FC; Tue, 12 Jul 2011 11:25:16 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: Jeff Davis , Pg Bugs Subject: Re: Window function bug From: Alvaro Herrera To: Tom Lane In-reply-to: <12936.1310484039@sss.pgh.pa.us> References: <1310431686.497.26.camel@jdavis-ux.asterdata.local> <12015.1310480904@sss.pgh.pa.us> <12936.1310484039@sss.pgh.pa.us> Date: Tue, 12 Jul 2011 11:25:16 -0400 Message-Id: <1310484282-sup-7290@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201107/105 X-Sequence-Number: 30717 Excerpts from Tom Lane's message of mar jul 12 11:20:39 -0400 2011: > I wrote: > > ... so I guess the answer is that this code ought to avoid adding Vars that > > are only mentioned within aggregates. > > The cleanest way to fix this would involve adding another flag parameter > to flatten_tlist and pull_var_clause. This is no problem to do in HEAD > or even 9.1, but I'm a bit worried about breaking third-party code if we > backpatch further than that. So far as I can see, the failure only > occurs if we have a plain (non-grouping) Agg node, which implies that > the user is trying to use windowing functions on a result set that's > guaranteed to contain exactly one aggregated row. That seems pretty > useless, so I'm thinking it's not worth back-patching a fix for. > Comments? Since there have been no previous bug reports on this, it seems clear that a backpatch is not strictly necessary either. -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support