bdr: integration of conflict handlers for UPDATE vs DELETE
authorChristian Kruse <[email protected]>
Fri, 9 May 2014 13:21:19 +0000 (15:21 +0200)
committerAndres Freund <[email protected]>
Thu, 3 Jul 2014 15:55:34 +0000 (17:55 +0200)
contrib/bdr/bdr_apply.c

index f41e0769623ba68f9a2ef5ebb3ca8e0c2499e4e9..5b5abfeefd9d8ba2fbd51729ff3263624f74329c 100644 (file)
@@ -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, &microsecs);
+
+       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",