]> granicus.if.org Git - postgresql/commit
Fix handling of opclauses in extended statistics
authorTomas Vondra <tomas.vondra@postgresql.org>
Fri, 12 Jul 2019 22:12:16 +0000 (00:12 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Thu, 18 Jul 2019 09:30:12 +0000 (11:30 +0200)
commit42276976a1437c88fb6176fc1a876fd79a139eb0
tree6d9a7f134784361070c3b2900915aef8ddf4c779
parent3944e855bc5bee32d99a9ba2245a026d4bafe282
Fix handling of opclauses in extended statistics

We expect opclauses to have exactly one Var and one Const, but the code
was checking the Const by calling is_pseudo_constant_clause() which is
incorrect - we need a proper constant.

Fixed by using plain IsA(x,Const) to check type of the node. We need to
do these checks in two places, so move it into a separate function that
can be called in both places.

Reported by Andreas Seltenreich, based on crash reported by sqlsmith.

Backpatch to v12, where this code was introduced.

Discussion: https://postgr.es/m/8736jdhbhc.fsf%40ansel.ydns.eu
Backpatch-to: 12
src/backend/statistics/extended_stats.c
src/backend/statistics/mcv.c
src/include/statistics/extended_stats_internal.h