pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix deserialization of pg_mcv_list values
Date: Thu, 28 Mar 2019 19:22:43 +0000
Message-ID: <E1h9abr-0008DR-J5@gemulon.postgresql.org> (raw)

Fix deserialization of pg_mcv_list values

There were multiple issues in deserialization of pg_mcv_list values.

Firstly, the data is loaded from syscache, but the deserialization was
performed after ReleaseSysCache(), at which point the data might have
already disappeared.  Fixed by moving the calls in statext_mcv_load,
and using the same NULL-handling code as existing stats.

Secondly, the deserialized representation used pointers into the
serialized representation.  But that is also unsafe, because the data
may disappear at any time.  Fixed by reworking and simplifying the
deserialization code to always copy all the data.

And thirdly, when deserializing values for types passed by value, the
code simply did memcpy(d,s,typlen) which however does not work on
bigendian machines.  Fixed by using fetch_att/store_att_byval.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/62bf0fb35cb370e9650981ff0333d198e955bd54

Modified Files
--------------
src/backend/statistics/mcv.c        | 436 +++++++++++++++++-------------------
src/include/statistics/statistics.h |   2 +-
2 files changed, 207 insertions(+), 231 deletions(-)



Message-ID: <E1h9abr-0008DR-J5@gemulon.postgresql.org>
Permalink:  ../E1h9abr-0008DR-J5@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1h9abr-0008DR-J5@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: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Fix deserialization of pg_mcv_list values
  In-Reply-To: <E1h9abr-0008DR-J5@gemulon.postgresql.org>
  References: <E1h9abr-0008DR-J5@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