pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix heap_getattr() handling of fast defaults.
Date: Wed, 06 Feb 2019 09:17:09 +0000
Message-ID: <E1grJKP-0002pg-9C@gemulon.postgresql.org> (raw)

Fix heap_getattr() handling of fast defaults.

Previously heap_getattr() returned NULL for attributes with a fast
default value (c.f. 16828d5c0273), as it had no handling whatsoever
for that case.

A previous fix, 7636e5c60f, attempted to fix issues caused by this
oversight, but just expanding OLD tuples for triggers doesn't actually
solve the underlying issue.

One known consequence of this bug is that the check for HOT updates
can return the wrong result, when a previously fast-default'ed column
is set to NULL. Which in turn means that an index over a column with
fast default'ed columns might be corrupt if the underlying column(s)
allow NULLs.

Fix by handling fast default columns in heap_getattr(), remove now
superfluous expansion in GetTupleForTrigger().

Author: Andres Freund
Discussion: https://postgr.es/m/20190201162404.onngi77f26baem4g@alap3.anarazel.de
Backpatch: 11, where fast defaults were introduced

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/297d627e074ad4aa2a9936b029a4b9231f9a150e

Modified Files
--------------
src/backend/access/common/heaptuple.c      |  2 +-
src/backend/commands/trigger.c             |  5 +----
src/include/access/htup_details.h          |  7 +++----
src/test/regress/expected/fast_default.out | 27 +++++++++++++++++++++++++++
src/test/regress/sql/fast_default.sql      | 20 ++++++++++++++++++++
5 files changed, 52 insertions(+), 9 deletions(-)



view thread (2+ messages)

Message-ID: <E1grJKP-0002pg-9C@gemulon.postgresql.org>
Permalink:  ../E1grJKP-0002pg-9C@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1grJKP-0002pg-9C@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: andres@anarazel.de
  Subject: Re: pgsql: Fix heap_getattr() handling of fast defaults.
  In-Reply-To: <E1grJKP-0002pg-9C@gemulon.postgresql.org>
  References: <E1grJKP-0002pg-9C@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