From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andreas Seltenreich <seltenreich@gmx.de>
Cc: pgsql-hackers@lists.postgresql.org, Tomas Vondra <tomas.vondra@postgresql.org>
Subject: Re: [sqlsmith] Crash in mcv_get_match_bitmap
Date: Wed, 10 Jul 2019 23:59:04 +0200
Message-ID: <20190710215904.ncaqlswrylliisv3@development> (raw)
In-Reply-To: <17042.1562795124@sss.pgh.pa.us>
References: <8736jdhbhc.fsf@ansel.ydns.eu>
<15097.1562792274@sss.pgh.pa.us>
<20190710212609.5mrl7hltbozoxpq7@development>
<17042.1562795124@sss.pgh.pa.us>
On Wed, Jul 10, 2019 at 05:45:24PM -0400, Tom Lane wrote:
>Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
>> Yeah, that's a bug. Will fix (not sure how yet).
>
>You could do worse than replace this:
>
> ok = (NumRelids(clause) == 1) &&
> (is_pseudo_constant_clause(lsecond(expr->args)) ||
> (varonleft = false,
> is_pseudo_constant_clause(linitial(expr->args))));
>
>with something like
>
> if (IsA(linitial(expr->args), Var) &&
> IsA(lsecond(expr->args), Const))
> ok = true, varonleft = true;
> else if (IsA(linitial(expr->args), Const) &&
> IsA(lsecond(expr->args), Var))
> ok = true, varonleft = false;
>
>Or possibly get rid of varonleft as such, and merge extraction of the
>"var" and "cst" variables into this test.
>
OK, thanks for the suggestion.
I probably also need to look at the "is compatible" test in
extended_stats.c which also looks at the clauses. It may not crash as it
does not attempt to extract the const values etc. but it likely needs to
be in sync with this part.
>BTW, I bet passing a unary-argument OpExpr also makes this code
>unhappy.
Whooops :-(
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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-hackers@postgresql.org
Cc: tomas.vondra@2ndquadrant.com, tgl@sss.pgh.pa.us, seltenreich@gmx.de, tomas.vondra@postgresql.org
Subject: Re: [sqlsmith] Crash in mcv_get_match_bitmap
In-Reply-To: <20190710215904.ncaqlswrylliisv3@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