Commit 204964b7 authored by marko's avatar marko

Merge a change from MySQL AB:

ChangeSet@1.2528.116.40  2007-09-08 11:19:35-07:00  acurtis@xiphis.org

Bug#30907
  "Regression: "--innodb_autoinc_lock_mode=0" (off) not same as older releases"
Bug#28430
  "Failure in replication of innodb partitioned tables on row/mixed format"
Bug#30888
  "Innodb table + stored procedure + row deletion = server crash"

  Apply Oracle patch from Sunny
  Include tests cases by Omer
  Ensure that innobase_read_and_init_auto performs table autoinc lock when
  lock_mode = 0
  No need for "if" guard around row_unlock_table_autoinc_for_mysql() because
  it already performs same check.
  Make autoinc_lock_mode variable read-only for duration of running
  mysqld process.

ha_innodb.cc:
Bug30907/28430
  "Regression: "--innodb_autoinc_lock_mode=0" (off) not same as older releases"
  "Failure in replication of innodb partitioned tables on row/mixed format"
  Apply Oracle patch from Sunny
  Ensure that innobase_read_and_init_auto performs table autoinc lock when
  lock_mode = 0
  No need for "if" guard around row_unlock_table_autoinc_for_mysql() because
  it already performs same check.
  Make autoinc_lock_mode variable read-only for duration of running
  mysqld process.
parent faabd6de
...@@ -603,7 +603,6 @@ convert_error_code_to_mysql( ...@@ -603,7 +603,6 @@ convert_error_code_to_mysql(
thd_mark_transaction_to_rollback(thd, TRUE); thd_mark_transaction_to_rollback(thd, TRUE);
return(HA_ERR_LOCK_DEADLOCK); return(HA_ERR_LOCK_DEADLOCK);
} else if (error == (int) DB_LOCK_WAIT_TIMEOUT) { } else if (error == (int) DB_LOCK_WAIT_TIMEOUT) {
/* Starting from 5.0.13, we let MySQL just roll back the /* Starting from 5.0.13, we let MySQL just roll back the
...@@ -1892,12 +1891,11 @@ innobase_commit( ...@@ -1892,12 +1891,11 @@ innobase_commit(
/* We just mark the SQL statement ended and do not do a /* We just mark the SQL statement ended and do not do a
transaction commit */ transaction commit */
if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some /* If we had reserved the auto-inc lock for some
table in this SQL statement we release it now */ table in this SQL statement we release it now */
row_unlock_table_autoinc_for_mysql(trx); row_unlock_table_autoinc_for_mysql(trx);
}
/* Store the current undo_no of the transaction so that we /* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next know where to roll back if we have to roll back the next
SQL statement */ SQL statement */
...@@ -1950,13 +1948,11 @@ innobase_rollback( ...@@ -1950,13 +1948,11 @@ innobase_rollback(
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some table (if /* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we we come here to roll back the latest SQL statement) we
release it now before a possibly lengthy rollback */ release it now before a possibly lengthy rollback */
row_unlock_table_autoinc_for_mysql(trx); row_unlock_table_autoinc_for_mysql(trx);
}
if (all if (all
|| !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
...@@ -1990,13 +1986,11 @@ innobase_rollback_trx( ...@@ -1990,13 +1986,11 @@ innobase_rollback_trx(
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some table (if /* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we we come here to roll back the latest SQL statement) we
release it now before a possibly lengthy rollback */ release it now before a possibly lengthy rollback */
row_unlock_table_autoinc_for_mysql(trx); row_unlock_table_autoinc_for_mysql(trx);
}
error = trx_rollback_for_mysql(trx); error = trx_rollback_for_mysql(trx);
...@@ -7167,6 +7161,7 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7167,6 +7161,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
int mysql_error = 0; int mysql_error = 0;
dict_table_t* innodb_table = prebuilt->table; dict_table_t* innodb_table = prebuilt->table;
ibool trx_was_not_started = FALSE; ibool trx_was_not_started = FALSE;
ulint error;
ut_a(prebuilt); ut_a(prebuilt);
ut_a(prebuilt->table); ut_a(prebuilt->table);
...@@ -7187,7 +7182,11 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7187,7 +7182,11 @@ ha_innobase::innobase_read_and_init_auto_inc(
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
dict_table_autoinc_lock(prebuilt->table); error = innobase_autoinc_lock();
if (error != DB_SUCCESS) {
mysql_error = 1;
goto err;
}
auto_inc = dict_table_autoinc_read(prebuilt->table); auto_inc = dict_table_autoinc_read(prebuilt->table);
...@@ -7200,7 +7199,6 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7200,7 +7199,6 @@ ha_innobase::innobase_read_and_init_auto_inc(
if (auto_inc == 0) { if (auto_inc == 0) {
dict_index_t* index; dict_index_t* index;
ulint error = DB_SUCCESS;
const char* autoinc_col_name; const char* autoinc_col_name;
ut_a(!innodb_table->autoinc_inited); ut_a(!innodb_table->autoinc_inited);
...@@ -7229,6 +7227,7 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7229,6 +7227,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
dict_table_autoinc_unlock(prebuilt->table); dict_table_autoinc_unlock(prebuilt->table);
err:
/* Since MySQL does not seem to call autocommit after SHOW TABLE /* Since MySQL does not seem to call autocommit after SHOW TABLE
STATUS (even if we would register the trx here), we commit our STATUS (even if we would register the trx here), we commit our
transaction here if it was started here. This is to eliminate a transaction here if it was started here. This is to eliminate a
...@@ -7279,12 +7278,10 @@ ha_innobase::innobase_get_auto_increment( ...@@ -7279,12 +7278,10 @@ ha_innobase::innobase_get_auto_increment(
trx = prebuilt->trx; trx = prebuilt->trx;
dict_table_autoinc_unlock(prebuilt->table); dict_table_autoinc_unlock(prebuilt->table);
if (trx->auto_inc_lock) {
/* If we had reserved the AUTO-INC /* If we had reserved the AUTO-INC
lock in this SQL statement we release lock in this SQL statement we release
it before retrying.*/ it before retrying.*/
row_unlock_table_autoinc_for_mysql(trx); row_unlock_table_autoinc_for_mysql(trx);
}
/* Just to make sure */ /* Just to make sure */
ut_a(!trx->auto_inc_lock); ut_a(!trx->auto_inc_lock);
...@@ -7358,15 +7355,10 @@ ha_innobase::get_auto_increment( ...@@ -7358,15 +7355,10 @@ ha_innobase::get_auto_increment(
trx = prebuilt->trx; trx = prebuilt->trx;
/* Note: We can't rely on *first_value since some MySQL engines,
in particular the partition engine, don't initialize it to 0 when
invoking this method. So we are not sure if it's guaranteed to
be 0 or not. */
/* Called for the first time ? */ /* Called for the first time ? */
if (trx->n_autoinc_rows == 0) { if (trx->n_autoinc_rows == 0) {
trx->n_autoinc_rows = (ulint) nb_desired_values; trx->n_autoinc_rows = nb_desired_values;
/* It's possible for nb_desired_values to be 0: /* It's possible for nb_desired_values to be 0:
e.g., INSERT INTO T1(C) SELECT C FROM T2; */ e.g., INSERT INTO T1(C) SELECT C FROM T2; */
...@@ -7710,12 +7702,10 @@ innobase_xa_prepare( ...@@ -7710,12 +7702,10 @@ innobase_xa_prepare(
/* We just mark the SQL statement ended and do not do a /* We just mark the SQL statement ended and do not do a
transaction prepare */ transaction prepare */
if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some /* If we had reserved the auto-inc lock for some
table in this SQL statement we release it now */ table in this SQL statement we release it now */
row_unlock_table_autoinc_for_mysql(trx); row_unlock_table_autoinc_for_mysql(trx);
}
/* Store the current undo_no of the transaction so that we /* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next know where to roll back if we have to roll back the next
...@@ -8071,7 +8061,7 @@ static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path, ...@@ -8071,7 +8061,7 @@ static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
NULL, NULL, NULL); NULL, NULL, NULL);
static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode, static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The AUTOINC lock modes supported by InnoDB:\n" "The AUTOINC lock modes supported by InnoDB:\n"
" 0 => Old style AUTOINC locking (for backward compatibility)\n" " 0 => Old style AUTOINC locking (for backward compatibility)\n"
" 1 => New style AUTOINC locking\n" " 1 => New style AUTOINC locking\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment