From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: tuomas.leikola@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16111: Unexpected query compilation error “negative bitmapset member not allowed”
Date: Wed, 13 Nov 2019 14:41:14 +0100
Message-ID: <20191113134114.rxcli5c6zjmryvf6@development> (raw)
In-Reply-To: <16111-687799584c3a7e73@postgresql.org>
References: <16111-687799584c3a7e73@postgresql.org>
On Wed, Nov 13, 2019 at 10:42:32AM +0000, PG Bug reporting form wrote:
>The following bug has been logged on the website:
>
>Bug reference: 16111
>Logged by: Tuomas Leikola
>Email address: tuomas.leikola@gmail.com
>PostgreSQL version: 12.0
>Operating system: windows, linux
>Description:
>
>I’ve been trying to cook up some kind of online reorganizer, which requires
>looking at rows’ physical locations and rearranging those that are
>suboptimal. In this endeavor, I stumbled on what appears to be a compiler
>bug introduced with multivariate statistics.
>
Yeah, this is a bug in estimate_multivariate_ndistinct, which fails to
ignore system attributes :-(
The attached patch fixes it, but unfortunatly we've missed this round of
minor releases :-( I'll get it pushed in a couple of days.
Thanks for the report and the reproducer, very helpful!
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:estimate_multivariate_ndistinct.patch (text/plain, 901B) downloaddiff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.cindex 8dddc5eb93..a3cccc455f 100644--- a/src/backend/utils/adt/selfuncs.c+++ b/src/backend/utils/adt/selfuncs.c@@ -3592,15 +3592,21 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
/* Determine the attnums we're looking for */
foreach(lc, *varinfos)
{
+ Var *var;
GroupVarInfo *varinfo = (GroupVarInfo *) lfirst(lc);
Assert(varinfo->rel == rel);
- if (IsA(varinfo->var, Var))- {- attnums = bms_add_member(attnums,- ((Var *) varinfo->var)->varattno);- }+ if (!IsA(varinfo->var, Var))+ continue;++ var = (Var *) varinfo->var;++ if (!AttrNumberIsForUserDefinedAttr(var->varattno))+ continue;++ attnums = bms_add_member(attnums,+ ((Var *) varinfo->var)->varattno);
}
/* look for the ndistinct statistics matching the most vars */
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-bugs@postgresql.org
Cc: tomas.vondra@2ndquadrant.com, tuomas.leikola@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16111: Unexpected query compilation error “negative bitmapset member not allowed”
In-Reply-To: <20191113134114.rxcli5c6zjmryvf6@development>
* 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