From: Andres Freund <andres@anarazel.de>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: wrb <wrb@autistici.org>
Cc: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13863: Select from views gives wrong results
Date: Sat, 16 Jan 2016 14:12:02 +0100
Message-ID: <20160116131202.GP10941@awork2.anarazel.de> (raw)
In-Reply-To: <CAEZATCXF3ZdUWkxUSX3CJUdX14yfVf++CW0KSZ1fSjYgFoFSAA@mail.gmail.com>
References: <20160113183558.12989.56904@wrigleys.postgresql.org>
<CAJrrPGdmBM9=ttRfT24FOzDySE9dSs1Uw0+ynD5FAo+pFR9Z8w@mail.gmail.com>
<82C006C0-07A7-401B-9BDA-0BABD9025099@autistici.org>
<CAEZATCXF3ZdUWkxUSX3CJUdX14yfVf++CW0KSZ1fSjYgFoFSAA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
Thanks for digging!
On 2016-01-16 11:23:31 +0000, Dean Rasheed wrote:
> When the clause is pushed down into the view it is turned from a WHERE
> clause into a HAVING clause, because the view query has grouping. That
> part is OK. However, the query planner then decides that since the new
> HAVING clause doesn't contain any aggregates or volatile expressions,
> it is safe to turn it back into a WHERE clause in the inner query.
> That would be OK for normal grouping, because in that case the clause
> would evaluate the same for all the rows in a group. However, that
> doesn't work for grouping sets, since the output of the grouping sets
> aggregation may contains nulls not present before grouping.
> Probably that change should be undone and the comment expanded to
> explain why it isn't safe when the query has grouping sets.
Hm, I'm a bit hesitant to potentially noticeably regress plans here,
although it seems unikely that already "relies" on this. Can't we
essentially treat references to columns which can be set to null by due
to a grouping set, as containing an agg clause and only prevent moving
in that case?
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andres@anarazel.de, dean.a.rasheed@gmail.com, wrb@autistici.org, kommi.haribabu@gmail.com
Subject: Re: BUG #13863: Select from views gives wrong results
In-Reply-To: <20160116131202.GP10941@awork2.anarazel.de>
References: <20160113183558.12989.56904@wrigleys.postgresql.org> <CAJrrPGdmBM9=ttRfT24FOzDySE9dSs1Uw0+ynD5FAo+pFR9Z8w@mail.gmail.com> <82C006C0-07A7-401B-9BDA-0BABD9025099@autistici.org> <CAEZATCXF3ZdUWkxUSX3CJUdX14yfVf++CW0KSZ1fSjYgFoFSAA@mail.gmail.com> <20160116131202.GP10941@awork2.anarazel.de>
* 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