aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2018-09-24 16:11:24 -0400
committerAndrew Dunstan <andrew@dunslane.net>2018-09-24 16:11:24 -0400
commit7636e5c60fea83a9f3cd2ad278c0819b98941c74 (patch)
tree285eb988abdec36c3e3835eafdf08125d6aeac3f /src/backend/commands/trigger.c
parent60e612b602999e670f2d57a01e52799eaa903ca9 (diff)
downloadpostgresql-7636e5c60fea83a9f3cd2ad278c0819b98941c74.tar.gz
postgresql-7636e5c60fea83a9f3cd2ad278c0819b98941c74.zip
Fast default trigger and expand_tuple fixes
Ensure that triggers get properly filled in tuples for the OLD value. Also fix the logic of detecting missing null values. The previous logic failed to detect a missing null column before the first missing column with a default. Fixing this has simplified the logic a bit. Regression tests are added to test changes. This should ensure better coverage of expand_tuple(). Original bug reports, and some code and test scripts from Tomas Vondra Backpatch to release 11.
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 2436692eb85..0665f110ba3 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -3396,7 +3396,10 @@ ltrmark:;
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
}
- result = heap_copytuple(&tuple);
+ if (HeapTupleHeaderGetNatts(tuple.t_data) < relation->rd_att->natts)
+ result = heap_expand_tuple(&tuple, relation->rd_att);
+ else
+ result = heap_copytuple(&tuple);
ReleaseBuffer(buffer);
return result;