Re: [sqlsmith] Crash in mcv_get_match_bitmap
Tomas Vondra <tomas.vondra@2ndquadrant.com>
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andreas Seltenreich <seltenreich@gmx.de>, pgsql-hackers@lists.postgresql.org, Tomas Vondra <tomas.vondra@postgresql.org>
Date: 2019-07-10T21:59:04Z
Lists: pgsql-hackers
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
Commits
-
Use column collation for extended statistics
- a63378a03ec0 13.0 landed
- 5a8ee9f2dbe0 12.0 landed
-
Rework examine_opclause_expression to use varonleft
- e38a55ba46bb 13.0 landed
- fc4faea17971 12.0 landed
-
Fix handling of NULLs in MCV items and constants
- 1c2acc32dc6c 12.0 landed
- e4deae7396f2 13.0 landed
-
Fix handling of opclauses in extended statistics
- 42276976a143 12.0 landed
- e8b6ae2130e3 13.0 landed
-
Remove unnecessary TYPECACHE_GT_OPR lookup
- 3944e855bc5b 12.0 landed
- a4303a078c66 13.0 landed
-
Simplify bitmap updates in multivariate MCV code
- 79d3a1e52a3c 12.0 landed
- 7d24f6a49076 13.0 landed
-
Make pg_statistic and related code account more honestly for collations.
- 5e09280057a4 12.0 cited