From 3c06a0b7dc121eb606f1d56d0509326e4e7d52b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 4 Mar 2022 14:23:33 +0200 Subject: MDEV-28004 ha_innobase::reset_auto_increment() is never executed The virtual member function handler::reset_auto_increment(ulonglong) is only ever invoked by the default implementation of the virtual member function handler::truncate(). Because ha_innobase::truncate() overrides handler::truncate() without ever invoking handler::truncate(), some InnoDB member functions are never called. ha_innobase::innobase_reset_autoinc(), ha_innobase::reset_auto_increment(): Removed (unreachable code). ha_innobase::delete_all_rows(): Removed. The default implementation handler::delete_all_rows() works just as fine. --- storage/innobase/handler/ha_innodb.cc | 68 ----------------------------------- storage/innobase/handler/ha_innodb.h | 6 +--- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a128d7fb0bc..33aafa00113 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2702,64 +2702,6 @@ overflow: return(~(ulonglong) 0); } -/********************************************************************//** -Reset the autoinc value in the table. -@return DB_SUCCESS if all went well else error code */ -UNIV_INTERN -dberr_t -ha_innobase::innobase_reset_autoinc( -/*================================*/ - ulonglong autoinc) /*!< in: value to store */ -{ - dberr_t error; - - error = innobase_lock_autoinc(); - - if (error == DB_SUCCESS) { - - dict_table_autoinc_initialize(m_prebuilt->table, autoinc); - - dict_table_autoinc_unlock(m_prebuilt->table); - } - - return(error); -} - -/*******************************************************************//** -Reset the auto-increment counter to the given value, i.e. the next row -inserted will get the given value. This is called e.g. after TRUNCATE -is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is -returned by storage engines that don't support this operation. -@return 0 or error code */ -UNIV_INTERN -int -ha_innobase::reset_auto_increment( -/*==============================*/ - ulonglong value) /*!< in: new value for table autoinc */ -{ - DBUG_ENTER("ha_innobase::reset_auto_increment"); - - dberr_t error; - - update_thd(ha_thd()); - - error = row_lock_table_autoinc_for_mysql(m_prebuilt); - - if (error != DB_SUCCESS) { - DBUG_RETURN(convert_error_code_to_mysql( - error, m_prebuilt->table->flags, m_user_thd)); - } - - /* The next value can never be 0. */ - if (value == 0) { - value = 1; - } - - innobase_reset_autoinc(value); - - DBUG_RETURN(0); -} - /*********************************************************************//** Initializes some fields in an InnoDB transaction object. */ static @@ -9119,16 +9061,6 @@ ha_innobase::delete_row( error, m_prebuilt->table->flags, m_user_thd)); } -/** Delete all rows from the table. -@return error number or 0 */ - -int -ha_innobase::delete_all_rows() -{ - DBUG_ENTER("ha_innobase::delete_all_rows"); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - /**********************************************************************//** Removes a new lock set on a row, if it was not read optimistically. This can be called after a row has been read in the processing of an UPDATE or a DELETE diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index b11bb14714d..9468edcf226 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2021, MariaDB Corporation. +Copyright (c) 2013, 2022, MariaDB Corporation. 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 the Free Software @@ -113,8 +113,6 @@ public: double read_time(uint index, uint ranges, ha_rows rows); - int delete_all_rows(); - int write_row(uchar * buf); int update_row(const uchar * old_data, const uchar * new_data); @@ -253,7 +251,6 @@ public: ulonglong nb_desired_values, ulonglong* first_value, ulonglong* nb_reserved_values); - int reset_auto_increment(ulonglong value); virtual bool get_error_message(int error, String *buf); @@ -441,7 +438,6 @@ protected: dberr_t innobase_lock_autoinc(); ulonglong innobase_peek_autoinc(); dberr_t innobase_set_max_autoinc(ulonglong auto_inc); - dberr_t innobase_reset_autoinc(ulonglong auto_inc); /** Resets a query execution 'template'. @see build_template() */ -- cgit v1.2.1