aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-08-21 18:16:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-08-21 18:16:02 -0400
commit38c9eb8fee298a9242bb2049c4fdf94407187d0c (patch)
treee403c803a48bf184cf83bb36db2d9c82fc469a7b /src/backend/commands/trigger.c
parent548d1f752be7a11e240f1eadd4f9987a7b9793c5 (diff)
downloadpostgresql-38c9eb8fee298a9242bb2049c4fdf94407187d0c.tar.gz
postgresql-38c9eb8fee298a9242bb2049c4fdf94407187d0c.zip
Fix trigger WHEN conditions when both BEFORE and AFTER triggers exist.
Due to tuple-slot mismanagement, evaluation of WHEN conditions for AFTER ROW UPDATE triggers could crash if there had been a BEFORE ROW trigger fired for the same update. Fix by not trying to overload the use of estate->es_trig_tuple_slot. Per report from Yoran Heling. Back-patch to 9.0, when trigger WHEN conditions were introduced.
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 0b3f93faca7..f4352aef4eb 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -2755,13 +2755,13 @@ TriggerEnabled(EState *estate, ResultRelInfo *relinfo,
}
if (HeapTupleIsValid(newtup))
{
- if (estate->es_trig_tuple_slot == NULL)
+ if (estate->es_trig_newtup_slot == NULL)
{
oldContext = MemoryContextSwitchTo(estate->es_query_cxt);
- estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate);
+ estate->es_trig_newtup_slot = ExecInitExtraTupleSlot(estate);
MemoryContextSwitchTo(oldContext);
}
- newslot = estate->es_trig_tuple_slot;
+ newslot = estate->es_trig_newtup_slot;
if (newslot->tts_tupleDescriptor != tupdesc)
ExecSetSlotDescriptor(newslot, tupdesc);
ExecStoreTuple(newtup, newslot, InvalidBuffer, false);