diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 5bc11e942f6..a29d474fbfc 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -555,7 +555,10 @@ int mysql_update(THD *thd, if (select && select->skip_record(thd, &skip_record)) { error= 1; - table->file->unlock_row(); + /* + Don't try unlocking the row if skip_record reported an error since + in this case the transaction might have been rolled back already. + */ break; } if (!skip_record) @@ -801,8 +804,17 @@ int mysql_update(THD *thd, } } } - else + /* + Don't try unlocking the row if skip_record reported an error since in + this case the transaction might have been rolled back already. + */ + else if (!thd->is_error()) table->file->unlock_row(); + else + { + error= 1; + break; + } thd->warning_info->inc_current_row_for_warning(); if (thd->is_error()) {