Index: mysql-5.1-runtime/storage/innobase/handler/ha_innodb.cc =================================================================== --- mysql-5.1-runtime.orig/storage/innobase/handler/ha_innodb.cc +++ mysql-5.1-runtime/storage/innobase/handler/ha_innodb.cc @@ -6387,6 +6387,7 @@ ha_innobase::external_lock( int lock_type) /* in: lock type */ { trx_t* trx; + ulint error = 0; DBUG_ENTER("ha_innobase::external_lock"); DBUG_PRINT("enter",("lock_type: %d", lock_type)); @@ -6484,13 +6485,13 @@ ha_innobase::external_lock( && thd_test_options(thd, OPTION_NOT_AUTOCOMMIT) && thd_in_lock_tables(thd)) { - ulint error = row_lock_table_for_mysql( + error = row_lock_table_for_mysql( prebuilt, NULL, 0); if (error != DB_SUCCESS) { error = convert_error_code_to_mysql( (int) error, thd); - DBUG_RETURN((int) error); + goto err_cleanup; } } @@ -6500,6 +6501,7 @@ ha_innobase::external_lock( DBUG_RETURN(0); } +err_cleanup: /* MySQL is releasing a table lock */ trx->n_mysql_tables_in_use--; @@ -6535,7 +6537,7 @@ ha_innobase::external_lock( } } - DBUG_RETURN(0); + DBUG_RETURN((int) error); } /**********************************************************************