Re: fast defaults in heap_getattr vs heap_deform_tuple
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org, Andrew Dunstan <andrew@dunslane.net>
Date: 2019-02-02T14:48:16Z
Lists: 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
Commits
-
Fix heap_getattr() handling of fast defaults.
- 297d627e074a 11.2 landed
- 171e0418b03d 12.0 landed
-
Fast default trigger and expand_tuple fixes
- 7636e5c60fea 12.0 cited