mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #11946: Review fixes.
sql/ha_innodb.cc: Add 'value' parameter to reset_auto_increment. sql/ha_innodb.h: Add 'value' parameter to reset_auto_increment. sql/handler.h: Add 'value' parameter to reset_auto_increment. sql/mysql_priv.h: Add 'reset_auto_increment' parameter to mysql_delete. sql/sql_delete.cc: Add 'reset_auto_increment' parameter to mysql_delete, and use it instead of checking for SQLCOM_TRUNCATE. mysql_truncate: Adapt to changes in mysql_delete. sql/sql_parse.cc: mysql_execute_command: Adapt to changes in mysql_delete.
This commit is contained in:
@ -6890,7 +6890,7 @@ ha_innobase::get_auto_increment()
|
|||||||
|
|
||||||
/* See comment in handler.h */
|
/* See comment in handler.h */
|
||||||
int
|
int
|
||||||
ha_innobase::reset_auto_increment()
|
ha_innobase::reset_auto_increment(ulonglong value)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("ha_innobase::reset_auto_increment");
|
DBUG_ENTER("ha_innobase::reset_auto_increment");
|
||||||
|
|
||||||
@ -6905,7 +6905,7 @@ ha_innobase::reset_auto_increment()
|
|||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
dict_table_autoinc_initialize(prebuilt->table, 0);
|
dict_table_autoinc_initialize(prebuilt->table, value);
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class ha_innobase: public handler
|
|||||||
enum thr_lock_type lock_type);
|
enum thr_lock_type lock_type);
|
||||||
void init_table_handle_for_HANDLER();
|
void init_table_handle_for_HANDLER();
|
||||||
ulonglong get_auto_increment();
|
ulonglong get_auto_increment();
|
||||||
int reset_auto_increment();
|
int reset_auto_increment(ulonglong value);
|
||||||
|
|
||||||
uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
|
uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
|
||||||
/*
|
/*
|
||||||
|
@ -651,12 +651,13 @@ public:
|
|||||||
virtual ulonglong get_auto_increment();
|
virtual ulonglong get_auto_increment();
|
||||||
virtual void restore_auto_increment();
|
virtual void restore_auto_increment();
|
||||||
|
|
||||||
/* This is called after TRUNCATE is emulated by doing a 'DELETE FROM t',
|
/*
|
||||||
in which case we need a separate operation for resetting the table's
|
Reset the auto-increment counter to the given value, i.e. the next row
|
||||||
auto-increment counter. HA_ERR_WRONG_COMMAND is returned by storage
|
inserted will get the given value. This is called e.g. after TRUNCATE
|
||||||
engines that have no need for this, i.e. those that can always do a
|
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
|
||||||
fast TRUNCATE. */
|
returned by storage engines that don't support this operation.
|
||||||
virtual int reset_auto_increment()
|
*/
|
||||||
|
virtual int reset_auto_increment(ulonglong value)
|
||||||
{ return HA_ERR_WRONG_COMMAND; }
|
{ return HA_ERR_WRONG_COMMAND; }
|
||||||
|
|
||||||
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
|
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
|
||||||
|
@ -740,8 +740,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
|
|||||||
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
|
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
|
||||||
TABLE_LIST *table_list);
|
TABLE_LIST *table_list);
|
||||||
bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
|
bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
|
||||||
bool mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order,
|
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||||
ha_rows rows, ulonglong options);
|
SQL_LIST *order, ha_rows rows, ulonglong options,
|
||||||
|
bool reset_auto_increment);
|
||||||
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
|
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
|
||||||
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
|
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
|
||||||
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);
|
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#include "sql_trigger.h"
|
#include "sql_trigger.h"
|
||||||
|
|
||||||
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||||
SQL_LIST *order, ha_rows limit, ulonglong options)
|
SQL_LIST *order, ha_rows limit, ulonglong options,
|
||||||
|
bool reset_auto_increment)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
@ -230,18 +231,18 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
if (options & OPTION_QUICK)
|
if (options & OPTION_QUICK)
|
||||||
(void) table->file->extra(HA_EXTRA_NORMAL);
|
(void) table->file->extra(HA_EXTRA_NORMAL);
|
||||||
|
|
||||||
if ((error < 0) && (thd->lex->sql_command == SQLCOM_TRUNCATE))
|
if (reset_auto_increment && (error < 0))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
We're really doing a truncate and need to reset the table's
|
We're really doing a truncate and need to reset the table's
|
||||||
auto-increment counter.
|
auto-increment counter.
|
||||||
*/
|
*/
|
||||||
int error2 = table->file->reset_auto_increment();
|
int error2= table->file->reset_auto_increment(0);
|
||||||
|
|
||||||
if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
|
if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
|
||||||
{
|
{
|
||||||
table->file->print_error(error2, MYF(0));
|
table->file->print_error(error2, MYF(0));
|
||||||
error = 1;
|
error= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,7 +829,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
|
|||||||
ha_enable_transaction(thd, FALSE);
|
ha_enable_transaction(thd, FALSE);
|
||||||
mysql_init_select(thd->lex);
|
mysql_init_select(thd->lex);
|
||||||
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
|
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
|
||||||
HA_POS_ERROR, LL(0));
|
HA_POS_ERROR, LL(0), TRUE);
|
||||||
ha_enable_transaction(thd, TRUE);
|
ha_enable_transaction(thd, TRUE);
|
||||||
thd->options= save_options;
|
thd->options= save_options;
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
@ -3321,7 +3321,8 @@ end_with_restore_list:
|
|||||||
unit->set_limit(select_lex);
|
unit->set_limit(select_lex);
|
||||||
res = mysql_delete(thd, all_tables, select_lex->where,
|
res = mysql_delete(thd, all_tables, select_lex->where,
|
||||||
&select_lex->order_list,
|
&select_lex->order_list,
|
||||||
unit->select_limit_cnt, select_lex->options);
|
unit->select_limit_cnt, select_lex->options,
|
||||||
|
FALSE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SQLCOM_DELETE_MULTI:
|
case SQLCOM_DELETE_MULTI:
|
||||||
|
Reference in New Issue
Block a user