]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Aug 2022 17:58:37 +0000 (13:58 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Aug 2022 17:58:49 +0000 (13:58 -0400)
commitc102d1106732189de2bfeb93c11b358f9c6b4e1f
treefcef30edb9932c3741e7fe47f108c185d8bb413d
parentc122a99bd6af1d764fa74b5e1c811b4cd73987cd
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics.

statext_is_compatible_clause_internal() checked that the arguments
of a ScalarArrayOpExpr are one Var and one Const, but it would allow
cases where the Const was on the left.  Subsequent uses of the clause
are not expecting that and would suffer assertion failures or core
dumps.  mcv.c also had not bothered to cope with the case of a NULL
array constant, which seems really unacceptably sloppy of somebody.
(Although our tools failed us there too, since AFAIK neither Coverity
nor any compiler warned of the obvious use-of-uninitialized-variable
condition.)  It seems best to handle that by having
statext_is_compatible_clause_internal() reject it.

Noted while fixing bug #17570.  Back-patch to v13 where the
extended stats code grew some awareness of ScalarArrayOpExpr.
src/backend/statistics/extended_stats.c
src/backend/statistics/mcv.c
src/test/regress/expected/stats_ext.out
src/test/regress/sql/stats_ext.sql