aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2019-02-06 01:09:32 -0800
committerAndres Freund <andres@anarazel.de>2019-02-06 01:09:42 -0800
commit297d627e074ad4aa2a9936b029a4b9231f9a150e (patch)
tree0cfdb106a79fe45a103fb2711f51339f87ad3375 /src/backend
parent77173d0cca4df1df1f423a467e2af4a4db9a0d10 (diff)
downloadpostgresql-297d627e074ad4aa2a9936b029a4b9231f9a150e.tar.gz
postgresql-297d627e074ad4aa2a9936b029a4b9231f9a150e.zip
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
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/common/heaptuple.c2
-rw-r--r--src/backend/commands/trigger.c5
2 files changed, 2 insertions, 5 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 5f34b26a2ce..1d03b7dd136 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -80,7 +80,7 @@
/*
* Return the missing value of an attribute, or NULL if there isn't one.
*/
-static Datum
+Datum
getmissingattr(TupleDesc tupleDesc,
int attnum, bool *isnull)
{
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index a0cc82c2a36..d7ffc9c3e2b 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -3396,10 +3396,7 @@ ltrmark:;
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
}
- if (HeapTupleHeaderGetNatts(tuple.t_data) < relation->rd_att->natts)
- result = heap_expand_tuple(&tuple, relation->rd_att);
- else
- result = heap_copytuple(&tuple);
+ result = heap_copytuple(&tuple);
ReleaseBuffer(buffer);
return result;