Skip to content

Commit 3c06a0b

Browse files
committed
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.
1 parent 1248fe7 commit 3c06a0b

File tree

2 files changed

+1
-73
lines changed

2 files changed

+1
-73
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,64 +2702,6 @@ innobase_next_autoinc(
27022702
return(~(ulonglong) 0);
27032703
}
27042704

2705-
/********************************************************************//**
2706-
Reset the autoinc value in the table.
2707-
@return DB_SUCCESS if all went well else error code */
2708-
UNIV_INTERN
2709-
dberr_t
2710-
ha_innobase::innobase_reset_autoinc(
2711-
/*================================*/
2712-
ulonglong autoinc) /*!< in: value to store */
2713-
{
2714-
dberr_t error;
2715-
2716-
error = innobase_lock_autoinc();
2717-
2718-
if (error == DB_SUCCESS) {
2719-
2720-
dict_table_autoinc_initialize(m_prebuilt->table, autoinc);
2721-
2722-
dict_table_autoinc_unlock(m_prebuilt->table);
2723-
}
2724-
2725-
return(error);
2726-
}
2727-
2728-
/*******************************************************************//**
2729-
Reset the auto-increment counter to the given value, i.e. the next row
2730-
inserted will get the given value. This is called e.g. after TRUNCATE
2731-
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
2732-
returned by storage engines that don't support this operation.
2733-
@return 0 or error code */
2734-
UNIV_INTERN
2735-
int
2736-
ha_innobase::reset_auto_increment(
2737-
/*==============================*/
2738-
ulonglong value) /*!< in: new value for table autoinc */
2739-
{
2740-
DBUG_ENTER("ha_innobase::reset_auto_increment");
2741-
2742-
dberr_t error;
2743-
2744-
update_thd(ha_thd());
2745-
2746-
error = row_lock_table_autoinc_for_mysql(m_prebuilt);
2747-
2748-
if (error != DB_SUCCESS) {
2749-
DBUG_RETURN(convert_error_code_to_mysql(
2750-
error, m_prebuilt->table->flags, m_user_thd));
2751-
}
2752-
2753-
/* The next value can never be 0. */
2754-
if (value == 0) {
2755-
value = 1;
2756-
}
2757-
2758-
innobase_reset_autoinc(value);
2759-
2760-
DBUG_RETURN(0);
2761-
}
2762-
27632705
/*********************************************************************//**
27642706
Initializes some fields in an InnoDB transaction object. */
27652707
static
@@ -9119,16 +9061,6 @@ ha_innobase::delete_row(
91199061
error, m_prebuilt->table->flags, m_user_thd));
91209062
}
91219063

9122-
/** Delete all rows from the table.
9123-
@return error number or 0 */
9124-
9125-
int
9126-
ha_innobase::delete_all_rows()
9127-
{
9128-
DBUG_ENTER("ha_innobase::delete_all_rows");
9129-
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
9130-
}
9131-
91329064
/**********************************************************************//**
91339065
Removes a new lock set on a row, if it was not read optimistically. This can
91349066
be called after a row has been read in the processing of an UPDATE or a DELETE

storage/innobase/handler/ha_innodb.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2013, 2021, MariaDB Corporation.
4+
Copyright (c) 2013, 2022, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -113,8 +113,6 @@ class ha_innobase: public handler
113113

114114
double read_time(uint index, uint ranges, ha_rows rows);
115115

116-
int delete_all_rows();
117-
118116
int write_row(uchar * buf);
119117

120118
int update_row(const uchar * old_data, const uchar * new_data);
@@ -253,7 +251,6 @@ class ha_innobase: public handler
253251
ulonglong nb_desired_values,
254252
ulonglong* first_value,
255253
ulonglong* nb_reserved_values);
256-
int reset_auto_increment(ulonglong value);
257254

258255
virtual bool get_error_message(int error, String *buf);
259256

@@ -441,7 +438,6 @@ class ha_innobase: public handler
441438
dberr_t innobase_lock_autoinc();
442439
ulonglong innobase_peek_autoinc();
443440
dberr_t innobase_set_max_autoinc(ulonglong auto_inc);
444-
dberr_t innobase_reset_autoinc(ulonglong auto_inc);
445441

446442
/** Resets a query execution 'template'.
447443
@see build_template() */

0 commit comments

Comments
 (0)