]> 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:48 +0000 (13:58 -0400)
commitea6c916962c4fc87c3d26d938e0149d4c91f2ca0
treedf52c8864c17ee8d7bbaf62817e99881b3675c93
parentfff3f3333fdc34d9f412fc8c87bef47ce4007ce9
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