diff options
author | unknown <jan@hundin.mysql.fi> | 2004-12-13 15:44:45 +0200 |
---|---|---|
committer | unknown <jan@hundin.mysql.fi> | 2004-12-13 15:44:45 +0200 |
commit | 08973f5c93d9f70da97a00a54b0c676c5eb6def2 (patch) | |
tree | 9a42fd02de4ce6a14589ec301aab8cab44d60311 /sql/ha_innodb.cc | |
parent | 3bee89076ee2a18ce73f2283db44fdb76fa4145d (diff) | |
download | mariadb-git-08973f5c93d9f70da97a00a54b0c676c5eb6def2.tar.gz |
Fixed a bug no error message for ALTER with InnoDB and AUTO_INCREMENT (Bug #7061).
sql/ha_innodb.cc:
Fixed a bug no error message for ALTER with InnoDB and AUTO_INCREMENT (Bug #7061).
It cant be put on commit because ALTER TABLE will commit on every 10000 rows.
Therefore, this change must be done when a new temporary table is created
in the ALTER TABLE.
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r-- | sql/ha_innodb.cc | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index ff6239cf4ce..3e535385ed0 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1327,12 +1327,6 @@ innobase_commit( that the current SQL statement ended */ { trx_t* trx; - dict_table_t* table; - ib_longlong auto_inc_value; - ib_longlong aic_new; - char table_name[1000]; - ulint db_name_len; - ulint table_name_len; DBUG_ENTER("innobase_commit"); DBUG_PRINT("trans", ("ending transaction")); @@ -1367,41 +1361,6 @@ innobase_commit( "InnoDB: but trx->conc_state != TRX_NOT_STARTED\n"); } - if (thd->lex->sql_command == SQLCOM_ALTER_TABLE && - (thd->lex->create_info.used_fields & HA_CREATE_USED_AUTO) && - (thd->lex->create_info.auto_increment_value != 0)) { - - /* Query was ALTER TABLE...AUTO_INC = x; Find out a table - definition from the dictionary and get the current value - of the auto increment field. Set a new value to the - auto increment field if the new value is creater than - the current value. */ - - aic_new = thd->lex->create_info.auto_increment_value; - db_name_len = strlen(thd->lex->query_tables->db); - table_name_len = strlen(thd->lex->query_tables->real_name); - - ut_ad((db_name_len + 1 + table_name_len) < 999); - strcpy(table_name, thd->lex->query_tables->db); - strcat(table_name, "/"); - strcat(table_name, thd->lex->query_tables->real_name); - - table = dict_table_get(table_name, trx); - - if (table) { - auto_inc_value = dict_table_autoinc_peek(table); - - if( auto_inc_value < aic_new) { - - /* We have to decrease the new auto increment - value by one because this function will increase - the value given by one. */ - - dict_table_autoinc_update(table, aic_new - 1); - } - } - } - if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) { @@ -3871,6 +3830,7 @@ ha_innobase::create( char name2[FN_REFLEN]; char norm_name[FN_REFLEN]; THD *thd= current_thd; + ib_longlong auto_inc_value; DBUG_ENTER("ha_innobase::create"); @@ -4041,6 +4001,20 @@ ha_innobase::create( DBUG_ASSERT(innobase_table != 0); + if (thd->lex->sql_command == SQLCOM_ALTER_TABLE && + (thd->lex->create_info.used_fields & HA_CREATE_USED_AUTO) && + (thd->lex->create_info.auto_increment_value != 0)) { + + /* Query was ALTER TABLE...AUTO_INC = x; Find out a table + definition from the dictionary and get the current value + of the auto increment field. Set a new value to the + auto increment field if the new value is creater than + the current value. */ + + auto_inc_value = thd->lex->create_info.auto_increment_value; + dict_table_autoinc_initialize(innobase_table, auto_inc_value); + } + /* Tell the InnoDB server that there might be work for utility threads: */ |