pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti
Date: Fri, 05 Aug 2022 17:59:07 +0000
Message-ID: <E1oK1bG-000SXa-S7@gemulon.postgresql.org> (raw)

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.

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c102d1106732189de2bfeb93c11b358f9c6b4e1f

Modified Files
--------------
src/backend/statistics/extended_stats.c | 13 +++++++++++--
src/backend/statistics/mcv.c            | 24 +++++++++++-------------
src/test/regress/expected/stats_ext.out | 22 ++++++++++++++++++----
src/test/regress/sql/stats_ext.sql      | 14 ++++++++++----
4 files changed, 50 insertions(+), 23 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1oK1bG-000SXa-S7@gemulon.postgresql.org>
Permalink:  ../E1oK1bG-000SXa-S7@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oK1bG-000SXa-S7@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti
  In-Reply-To: <E1oK1bG-000SXa-S7@gemulon.postgresql.org>
  References: <E1oK1bG-000SXa-S7@gemulon.postgresql.org>

* 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