From: Christian Kruse Date: Fri, 9 May 2014 13:21:19 +0000 (+0200) Subject: bdr: integration of conflict handlers for UPDATE vs DELETE X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=4e91498cef007c19e73be7331ea70e697cafaaa1;p=users%2Fandresfreund%2Fpostgres.git bdr: integration of conflict handlers for UPDATE vs DELETE --- 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",