From 4e91498cef007c19e73be7331ea70e697cafaaa1 Mon Sep 17 00:00:00 2001 From: Christian Kruse Date: Fri, 9 May 2014 15:21:19 +0200 Subject: [PATCH] bdr: integration of conflict handlers for UPDATE vs DELETE --- contrib/bdr/bdr_apply.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/contrib/bdr/bdr_apply.c b/contrib/bdr/bdr_apply.c index f41e076962..5b5abfeefd 100644 --- a/contrib/bdr/bdr_apply.c +++ b/contrib/bdr/bdr_apply.c @@ -670,11 +670,36 @@ process_remote_update(StringInfo s) * conflict or if the target tuple came from some 3rd node and hasn't yet * been applied to the local node. */ + + long secs; + int microsecs; + bool skip = false; + + remote_tuple = heap_form_tuple(RelationGetDescr(rel->rel), + new_tuple.values, + new_tuple.isnull); + + ExecStoreTuple(remote_tuple, newslot, InvalidBuffer, true); + + TimestampDifference(replication_origin_timestamp, GetCurrentTimestamp(), + &secs, µsecs); + + user_tuple = bdr_conflict_handlers_resolve(rel, NULL, + remote_tuple, "UPDATE", + BdrConflictType_UpdateDelete, + abs(secs) * 1000000 + abs(microsecs), + &skip); + initStringInfo(&o); tuple_to_stringinfo(&o, RelationGetDescr(rel->rel), oldslot->tts_tuple); bdr_count_update_conflict(); + if (user_tuple) + ereport(ERROR, + (errmsg("UPDATE vs DELETE handler returned a row which" + " isn't allowed for now"))); + ereport(LOG, (errcode(ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION), errmsg("CONFLICT: could not find existing tuple for pkey %s", -- 2.39.5