aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 41bd59ca0d4..a5e27227cf2 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -28,6 +28,7 @@
#include "utils/inval.h"
#include "utils/builtins.h"
#include "utils/syscache.h"
+#include "executor/executor.h"
#ifndef NO_SECURITY
#include "miscadmin.h"
@@ -790,6 +791,8 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
return;
}
+extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
+
static HeapTuple
GetTupleForTrigger(EState *estate, ItemPointer tid, bool before)
{
@@ -806,6 +809,7 @@ GetTupleForTrigger(EState *estate, ItemPointer tid, bool before)
* mark tuple for update
*/
tuple.t_self = *tid;
+ltrmark:;
test = heap_mark4update(relation, &tuple, &buffer);
switch (test)
{
@@ -820,8 +824,23 @@ GetTupleForTrigger(EState *estate, ItemPointer tid, bool before)
ReleaseBuffer(buffer);
if (XactIsoLevel == XACT_SERIALIZABLE)
elog(ERROR, "Can't serialize access due to concurrent update");
- else
- elog(ERROR, "Isolation level %u is not supported", XactIsoLevel);
+ else if (!(ItemPointerEquals(&(tuple.t_self), tid)))
+ {
+ TupleTableSlot *slot = EvalPlanQual(estate,
+ estate->es_result_relation_info->ri_RangeTableIndex,
+ &(tuple.t_self));
+
+ if (!(TupIsNull(slot)))
+ {
+ *tid = tuple.t_self;
+ goto ltrmark;
+ }
+ }
+ /*
+ * if tuple was deleted or PlanQual failed
+ * for updated tuple - we have not process
+ * this tuple!
+ */
return(NULL);
default: