--- apply-old	2007-12-13 14:31:38.000000000 +0100
+++ apply-new	2007-12-13 14:32:17.000000000 +0100
@@ -1,14 +1,18 @@
-    int const type_code= ev->get_type_code();
+int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli,
+                               bool skip)
+{
     int exec_res= 0;
 
+  DBUG_ENTER("apply_event_and_update_pos");
+
     DBUG_PRINT("exec_event",("%s(type_code: %d; server_id: %d)",
-                       ev->get_type_str(), type_code, ev->server_id));
+                           ev->get_type_str(), ev->get_type_code(),
+                           ev->server_id));
     DBUG_PRINT("info", ("thd->options: %s%s; rli->last_event_start_time: %lu",
                         FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT),
                         FLAGSTR(thd->options, OPTION_BEGIN),
                         rli->last_event_start_time));
 
-
     /*
       Execute the event to change the database and update the binary
       log coordinates, but first we set some data that is needed for
@@ -40,6 +44,8 @@
       ev->when= my_time(0);
     ev->thd = thd; // because up to this point, ev->thd == 0
 
+  if (skip)
+  {
     int reason= ev->shall_skip(rli);
     if (reason == Log_event::EVENT_SKIP_COUNT)
       --rli->slave_skip_counter;
@@ -66,6 +72,9 @@
     DBUG_PRINT("skip_event", ("%s event was %s",
                               ev->get_type_str(), explain[reason]));
 #endif
+  }
+  else
+    exec_res= ev->apply_event(rli);
 
     DBUG_PRINT("info", ("apply_event error = %d", exec_res));
     if (exec_res == 0)
@@ -95,6 +104,9 @@
                     " Stopped in %s position %s",
                     rli->group_relay_log_name,
                     llstr(rli->group_relay_log_pos, buf));
-        DBUG_RETURN(1);
+      DBUG_RETURN(2);
       }
     }
+
+  DBUG_RETURN(exec_res ? 1 : 0);
+}


