From fa31a9950babd887086c20419669b484d813f501 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Aug 2005 11:00:20 +0300 Subject: Fix bug #11946, truncate not always resetting the auto-increment counter in InnoDB tables. mysql-test/r/innodb.result: New tests. mysql-test/t/innodb.test: New tests. sql/ha_innodb.cc: Add reset_auto_increment. sql/ha_innodb.h: Add reset_auto_increment. sql/handler.h: Add reset_auto_increment. sql/sql_delete.cc: Call handler->reset_auto_increment when needed. --- sql/ha_innodb.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index bf781e9a5c2..cf91254fd12 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -6782,6 +6782,28 @@ ha_innobase::get_auto_increment() return((ulonglong) nr); } +/* See comment in handler.h */ +int +ha_innobase::reset_auto_increment() +{ + DBUG_ENTER("ha_innobase::reset_auto_increment"); + + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + int error; + + error = row_lock_table_autoinc_for_mysql(prebuilt); + + if (error != DB_SUCCESS) { + error = convert_error_code_to_mysql(error, user_thd); + + DBUG_RETURN(error); + } + + dict_table_autoinc_initialize(prebuilt->table, 0); + + DBUG_RETURN(0); +} + /*********************************************************************** Compares two 'refs'. A 'ref' is the (internal) primary key value of the row. If there is no explicitly declared non-null unique key or a primary key, then -- cgit v1.2.1