Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5F7A9B5DBE5 for ; Tue, 12 Jul 2011 12:20:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 86699-02 for ; Tue, 12 Jul 2011 15:20:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 22771B5DBBF for ; Tue, 12 Jul 2011 12:20:42 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p6CFKdKr012937; Tue, 12 Jul 2011 11:20:39 -0400 (EDT) To: Jeff Davis cc: pgsql-bugs@postgresql.org Subject: Re: Window function bug In-reply-to: <12015.1310480904@sss.pgh.pa.us> References: <1310431686.497.26.camel@jdavis-ux.asterdata.local> <12015.1310480904@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 12 Jul 2011 10:28:24 -0400" Date: Tue, 12 Jul 2011 11:20:39 -0400 Message-ID: <12936.1310484039@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/104 X-Sequence-Number: 30716 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? regards, tom lane