summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index d7ad9501ffd..a5f9b28de32 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -6402,7 +6402,7 @@ static int find_and_fetch_row(TABLE *table, byte *key)
table->record[0] if the engine allows it. We first compute a
row reference using the position() member function (it will be
stored in table->file->ref) and the use rnd_pos() to position
- the "cursor" at the correct row.
+ the "cursor" (i.e., record[0] in this case) at the correct row.
*/
table->file->position(table->record[0]);
DBUG_RETURN(table->file->rnd_pos(table->record[0], table->file->ref));
@@ -6797,19 +6797,25 @@ int Update_rows_log_event::do_exec_row(TABLE *table)
return error;
/*
- This is only a precaution to make sure that the call to
- ha_update_row is using record[1].
-
- If this is not needed/required, then we could use m_after_image in
- that call instead.
+ We have to ensure that the new record (i.e., the after image) is
+ in record[0] and the old record (i.e., the before image) is in
+ record[1]. This since some storage engines require this (for
+ example, the partition engine).
+
+ Since find_and_fetch_row() puts the fetched record (i.e., the old
+ record) in record[0], we have to move it out of the way and into
+ record[1]. After that, we can put the new record (i.e., the after
+ image) into record[0].
*/
- bmove_align(table->record[1], m_after_image,(size_t) table->s->reclength);
+ bmove_align(table->record[1], table->record[0], table->s->reclength);
+ bmove_align(table->record[0], m_after_image, table->s->reclength);
/*
- Now we should have the right row to update. The record that has
- been fetched is guaranteed to be in record[0], so we use that.
+ Now we should have the right row to update. The old row (the one
+ we're looking for) has to be in record[1] and the new row has to
+ be in record[0] for all storage engines to work correctly.
*/
- error= table->file->ha_update_row(table->record[0], table->record[1]);
+ error= table->file->ha_update_row(table->record[1], table->record[0]);
return error;
}