Re: fast defaults in heap_getattr vs heap_deform_tuple - Mailing list pgsql-hackers

From Andres Freund
Subject Re: fast defaults in heap_getattr vs heap_deform_tuple
Date
Msg-id 20190202144816.jyijnadjjxw5hiw7@alap3.anarazel.de
Whole thread Raw
In response to Re: fast defaults in heap_getattr vs heap_deform_tuple  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

On 2019-02-02 05:35:21 -0800, Andres Freund wrote:
> This breaks HOT (and probably also foreign keys), when fast default
> columns are set to NULL, because HeapDetermineModifiedColumns() gets the
> values with heap_getattr(), which returns a spurious NULL for the old
> value (instead of the fast default value). That then would compare equal
> to the new column value set to NULL.

Repro:

BEGIN;
CREATE TABLE t();
INSERT INTO t DEFAULT VALUES;
ALTER TABLE t ADD COLUMN a int default 1;
CREATE INDEX ON t(a);
UPDATE t SET a = NULL;

SET LOCAL enable_seqscan = true;
SELECT * FROM t WHERE a IS NULL;
SET LOCAL enable_seqscan = false;
SELECT * FROM t WHERE a IS NULL;
ROLLBACK;

output:
...
UPDATE 1
SET
┌────────┐
│   a    │
├────────┤
│ (null) │
└────────┘
(1 row)

SET
┌───┐
│ a │
├───┤
└───┘
(0 rows)



Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: Able to do ALTER DEFAULT PRIVILEGES from a user who is not the owner
Next
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Block level parallel vacuum