mirror of
https://github.com/MariaDB/server.git
synced 2025-11-28 17:36:30 +03:00
Merge 10.0 into 10.1
This commit is contained in:
@@ -1348,3 +1348,15 @@ t CREATE TABLE `t` (
|
||||
KEY `i` (`i`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1
|
||||
DROP TABLE t;
|
||||
#
|
||||
# MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
|
||||
#
|
||||
SET sql_mode=STRICT_ALL_TABLES;
|
||||
CREATE TABLE t1 (
|
||||
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
|
||||
INSERT INTO t1 VALUES ();
|
||||
SELECT * FROM t1;
|
||||
c1
|
||||
1e19
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -680,3 +680,15 @@ INSERT INTO t VALUES (NULL);
|
||||
SELECT * FROM t;
|
||||
SHOW CREATE TABLE t;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
|
||||
--echo #
|
||||
|
||||
SET sql_mode=STRICT_ALL_TABLES;
|
||||
CREATE TABLE t1 (
|
||||
c1 DOUBLE NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000000000000000000;
|
||||
INSERT INTO t1 VALUES ();
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
10
mysql-test/suite/parts/r/partition_alter_myisam.result
Normal file
10
mysql-test/suite/parts/r/partition_alter_myisam.result
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE t1 (i INT) ENGINE=MYISAM
|
||||
PARTITION BY LIST(i) (
|
||||
PARTITION p0 VALUES IN (1),
|
||||
PARTITION p1 VALUES IN (2)
|
||||
);
|
||||
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
|
||||
ALTER TABLE t1 DROP PARTITION p1;
|
||||
SELECT * FROM t1;
|
||||
i
|
||||
DROP TABLE t1;
|
||||
17
mysql-test/suite/parts/t/partition_alter_myisam.test
Normal file
17
mysql-test/suite/parts/t/partition_alter_myisam.test
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine
|
||||
#
|
||||
|
||||
--source include/have_partition.inc
|
||||
|
||||
CREATE TABLE t1 (i INT) ENGINE=MYISAM
|
||||
PARTITION BY LIST(i) (
|
||||
PARTITION p0 VALUES IN (1),
|
||||
PARTITION p1 VALUES IN (2)
|
||||
);
|
||||
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
|
||||
ALTER TABLE t1 DROP PARTITION p1;
|
||||
SELECT * FROM t1;
|
||||
|
||||
# Cleanup
|
||||
DROP TABLE t1;
|
||||
@@ -4729,7 +4729,7 @@ double Field_double::val_real(void)
|
||||
return j;
|
||||
}
|
||||
|
||||
longlong Field_double::val_int(void)
|
||||
longlong Field_double::val_int_from_real(bool want_unsigned_result)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_READ;
|
||||
double j;
|
||||
@@ -4737,7 +4737,7 @@ longlong Field_double::val_int(void)
|
||||
bool error;
|
||||
float8get(j,ptr);
|
||||
|
||||
res= double_to_longlong(j, 0, &error);
|
||||
res= double_to_longlong(j, want_unsigned_result, &error);
|
||||
if (error)
|
||||
{
|
||||
THD *thd= get_thd();
|
||||
|
||||
@@ -745,6 +745,10 @@ public:
|
||||
{ return store(ls->str, ls->length, cs); }
|
||||
virtual double val_real(void)=0;
|
||||
virtual longlong val_int(void)=0;
|
||||
virtual ulonglong val_uint(void)
|
||||
{
|
||||
return (ulonglong) val_int();
|
||||
}
|
||||
virtual bool val_bool(void)= 0;
|
||||
virtual my_decimal *val_decimal(my_decimal *);
|
||||
inline String *val_str(String *str) { return val_str(str, str); }
|
||||
@@ -1999,6 +2003,7 @@ private:
|
||||
|
||||
|
||||
class Field_double :public Field_real {
|
||||
longlong val_int_from_real(bool want_unsigned_result);
|
||||
public:
|
||||
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||
uchar null_bit_arg,
|
||||
@@ -2025,7 +2030,8 @@ public:
|
||||
int store(longlong nr, bool unsigned_val);
|
||||
int reset(void) { bzero(ptr,sizeof(double)); return 0; }
|
||||
double val_real(void);
|
||||
longlong val_int(void);
|
||||
longlong val_int(void) { return val_int_from_real(false); }
|
||||
ulonglong val_uint(void) { return (ulonglong) val_int_from_real(true); }
|
||||
String *val_str(String*,String *);
|
||||
bool send_binary(Protocol *protocol);
|
||||
int cmp(const uchar *,const uchar *);
|
||||
|
||||
@@ -1764,6 +1764,13 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st,
|
||||
used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET);
|
||||
return false;
|
||||
}
|
||||
ulong table_options_with_row_type()
|
||||
{
|
||||
if (row_type == ROW_TYPE_DYNAMIC || row_type == ROW_TYPE_PAGE)
|
||||
return table_options | HA_OPTION_PACK_RECORD;
|
||||
else
|
||||
return table_options;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6831,10 +6831,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
lpt->part_info= part_info;
|
||||
lpt->alter_info= alter_info;
|
||||
lpt->create_info= create_info;
|
||||
lpt->db_options= create_info->table_options;
|
||||
if (create_info->row_type != ROW_TYPE_FIXED &&
|
||||
create_info->row_type != ROW_TYPE_DEFAULT)
|
||||
lpt->db_options|= HA_OPTION_PACK_RECORD;
|
||||
lpt->db_options= create_info->table_options_with_row_type();
|
||||
lpt->table= table;
|
||||
lpt->key_info_buffer= 0;
|
||||
lpt->key_count= 0;
|
||||
|
||||
@@ -4414,10 +4414,7 @@ handler *mysql_create_frm_image(THD *thd,
|
||||
|
||||
set_table_default_charset(thd, create_info, (char*) db);
|
||||
|
||||
db_options= create_info->table_options;
|
||||
if (create_info->row_type == ROW_TYPE_DYNAMIC ||
|
||||
create_info->row_type == ROW_TYPE_PAGE)
|
||||
db_options|= HA_OPTION_PACK_RECORD;
|
||||
db_options= create_info->table_options_with_row_type();
|
||||
|
||||
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root,
|
||||
create_info->db_type)))
|
||||
|
||||
@@ -8297,7 +8297,7 @@ no_commit:
|
||||
table->next_number_field);
|
||||
|
||||
/* Get the value that MySQL attempted to store in the table.*/
|
||||
auto_inc = table->next_number_field->val_int();
|
||||
auto_inc = table->next_number_field->val_uint();
|
||||
|
||||
switch (error) {
|
||||
case DB_DUPLICATE_KEY:
|
||||
@@ -8891,7 +8891,7 @@ ha_innobase::update_row(
|
||||
ulonglong auto_inc;
|
||||
ulonglong col_max_value;
|
||||
|
||||
auto_inc = table->next_number_field->val_int();
|
||||
auto_inc = table->next_number_field->val_uint();
|
||||
|
||||
/* We need the upper limit of the col type to check for
|
||||
whether we update the table autoinc counter or not. */
|
||||
|
||||
@@ -75,7 +75,7 @@ UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
|
||||
|
||||
/** Chain node of the list of tables to drop in the background. */
|
||||
struct row_mysql_drop_t{
|
||||
char* table_name; /*!< table name */
|
||||
table_id_t table_id; /*!< table id */
|
||||
UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list;
|
||||
/*!< list chain node */
|
||||
};
|
||||
@@ -138,19 +138,6 @@ row_mysql_is_system_table(
|
||||
|| 0 == strcmp(name + 6, "db"));
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
If a table is not yet in the drop list, adds the table to the list of tables
|
||||
which the master thread drops in background. We need this on Unix because in
|
||||
ALTER TABLE MySQL may call drop table even if the table has running queries on
|
||||
it. Also, if there are running foreign key checks on the table, we drop the
|
||||
table lazily.
|
||||
@return TRUE if the table was not yet in the drop list, and was added there */
|
||||
static
|
||||
ibool
|
||||
row_add_table_to_background_drop_list(
|
||||
/*==================================*/
|
||||
const char* name); /*!< in: table name */
|
||||
|
||||
/*******************************************************************//**
|
||||
Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */
|
||||
static
|
||||
@@ -2770,7 +2757,7 @@ loop:
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
ut_a(row_mysql_drop_list_inited);
|
||||
|
||||
next:
|
||||
drop = UT_LIST_GET_FIRST(row_mysql_drop_list);
|
||||
|
||||
n_tables = UT_LIST_GET_LEN(row_mysql_drop_list);
|
||||
@@ -2783,62 +2770,39 @@ loop:
|
||||
return(n_tables + n_tables_dropped);
|
||||
}
|
||||
|
||||
DBUG_EXECUTE_IF("row_drop_tables_in_background_sleep",
|
||||
os_thread_sleep(5000000);
|
||||
);
|
||||
table = dict_table_open_on_id(drop->table_id, FALSE,
|
||||
DICT_TABLE_OP_NORMAL);
|
||||
|
||||
table = dict_table_open_on_name(drop->table_name, FALSE, FALSE,
|
||||
DICT_ERR_IGNORE_NONE);
|
||||
|
||||
if (table == NULL) {
|
||||
/* If for some reason the table has already been dropped
|
||||
through some other mechanism, do not try to drop it */
|
||||
|
||||
goto already_dropped;
|
||||
}
|
||||
|
||||
if (!table->to_be_dropped) {
|
||||
/* There is a scenario: the old table is dropped
|
||||
just after it's added into drop list, and new
|
||||
table with the same name is created, then we try
|
||||
to drop the new table in background. */
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
goto already_dropped;
|
||||
if (!table) {
|
||||
n_tables_dropped++;
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
ut_free(drop);
|
||||
goto next;
|
||||
}
|
||||
|
||||
ut_a(!table->can_be_evicted);
|
||||
|
||||
if (!table->to_be_dropped) {
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list,
|
||||
drop);
|
||||
goto next;
|
||||
}
|
||||
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
if (DB_SUCCESS != row_drop_table_for_mysql_in_background(
|
||||
drop->table_name)) {
|
||||
table->name)) {
|
||||
/* If the DROP fails for some table, we return, and let the
|
||||
main thread retry later */
|
||||
|
||||
return(n_tables + n_tables_dropped);
|
||||
}
|
||||
|
||||
n_tables_dropped++;
|
||||
|
||||
already_dropped:
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
|
||||
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Dropped table ", stderr);
|
||||
ut_print_name(stderr, NULL, TRUE, drop->table_name);
|
||||
fputs(" in background drop queue.\n", stderr);
|
||||
|
||||
mem_free(drop->table_name);
|
||||
|
||||
mem_free(drop);
|
||||
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
@@ -2870,14 +2834,13 @@ which the master thread drops in background. We need this on Unix because in
|
||||
ALTER TABLE MySQL may call drop table even if the table has running queries on
|
||||
it. Also, if there are running foreign key checks on the table, we drop the
|
||||
table lazily.
|
||||
@return TRUE if the table was not yet in the drop list, and was added there */
|
||||
@return whether background DROP TABLE was scheduled for the first time */
|
||||
static
|
||||
ibool
|
||||
row_add_table_to_background_drop_list(
|
||||
/*==================================*/
|
||||
const char* name) /*!< in: table name */
|
||||
bool
|
||||
row_add_table_to_background_drop_list(table_id_t table_id)
|
||||
{
|
||||
row_mysql_drop_t* drop;
|
||||
bool added = true;
|
||||
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
@@ -2888,31 +2851,21 @@ row_add_table_to_background_drop_list(
|
||||
drop != NULL;
|
||||
drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) {
|
||||
|
||||
if (strcmp(drop->table_name, name) == 0) {
|
||||
/* Already in the list */
|
||||
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
return(FALSE);
|
||||
if (drop->table_id == table_id) {
|
||||
added = false;
|
||||
goto func_exit;
|
||||
}
|
||||
}
|
||||
|
||||
drop = static_cast<row_mysql_drop_t*>(
|
||||
mem_alloc(sizeof(row_mysql_drop_t)));
|
||||
|
||||
drop->table_name = mem_strdup(name);
|
||||
drop = static_cast<row_mysql_drop_t*>(ut_malloc(sizeof *drop));
|
||||
drop->table_id = table_id;
|
||||
|
||||
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
|
||||
MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
|
||||
/* fputs("InnoDB: Adding table ", stderr);
|
||||
ut_print_name(stderr, trx, TRUE, drop->table_name);
|
||||
fputs(" to background drop list\n", stderr); */
|
||||
|
||||
func_exit:
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
return(TRUE);
|
||||
return added;
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
@@ -4131,7 +4084,7 @@ row_drop_table_for_mysql(
|
||||
|
||||
|
||||
DBUG_EXECUTE_IF("row_drop_table_add_to_background",
|
||||
row_add_table_to_background_drop_list(table->name);
|
||||
row_add_table_to_background_drop_list(table->id);
|
||||
err = DB_SUCCESS;
|
||||
goto funct_exit;
|
||||
);
|
||||
@@ -4143,33 +4096,22 @@ row_drop_table_for_mysql(
|
||||
checks take an IS or IX lock on the table. */
|
||||
|
||||
if (table->n_foreign_key_checks_running > 0) {
|
||||
|
||||
const char* save_tablename = table->name;
|
||||
ibool added;
|
||||
|
||||
added = row_add_table_to_background_drop_list(save_tablename);
|
||||
|
||||
if (added) {
|
||||
if (row_add_table_to_background_drop_list(table->id)) {
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: You are trying to drop table ",
|
||||
stderr);
|
||||
ut_print_name(stderr, trx, TRUE, save_tablename);
|
||||
ut_print_name(stderr, trx, TRUE, table->name);
|
||||
fputs("\n"
|
||||
"InnoDB: though there is a"
|
||||
" foreign key check running on it.\n"
|
||||
"InnoDB: Adding the table to"
|
||||
" the background drop queue.\n",
|
||||
stderr);
|
||||
}
|
||||
|
||||
/* We return DB_SUCCESS to MySQL though the drop will
|
||||
happen lazily later */
|
||||
|
||||
err = DB_SUCCESS;
|
||||
} else {
|
||||
/* The table is already in the background drop list */
|
||||
err = DB_ERROR;
|
||||
}
|
||||
|
||||
goto funct_exit;
|
||||
}
|
||||
|
||||
@@ -4194,11 +4136,7 @@ row_drop_table_for_mysql(
|
||||
lock_remove_all_on_table(table, TRUE);
|
||||
ut_a(table->n_rec_locks == 0);
|
||||
} else if (table->n_ref_count > 0 || table->n_rec_locks > 0) {
|
||||
ibool added;
|
||||
|
||||
added = row_add_table_to_background_drop_list(table->name);
|
||||
|
||||
if (added) {
|
||||
if (row_add_table_to_background_drop_list(table->id)) {
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Warning: MySQL is"
|
||||
" trying to drop table ", stderr);
|
||||
|
||||
@@ -8881,7 +8881,7 @@ no_commit:
|
||||
table->next_number_field);
|
||||
|
||||
/* Get the value that MySQL attempted to store in the table.*/
|
||||
auto_inc = table->next_number_field->val_int();
|
||||
auto_inc = table->next_number_field->val_uint();
|
||||
|
||||
switch (error) {
|
||||
case DB_DUPLICATE_KEY:
|
||||
@@ -9473,7 +9473,7 @@ ha_innobase::update_row(
|
||||
ulonglong auto_inc;
|
||||
ulonglong col_max_value;
|
||||
|
||||
auto_inc = table->next_number_field->val_int();
|
||||
auto_inc = table->next_number_field->val_uint();
|
||||
|
||||
/* We need the upper limit of the col type to check for
|
||||
whether we update the table autoinc counter or not. */
|
||||
|
||||
@@ -74,7 +74,7 @@ UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
|
||||
|
||||
/** Chain node of the list of tables to drop in the background. */
|
||||
struct row_mysql_drop_t{
|
||||
char* table_name; /*!< table name */
|
||||
table_id_t table_id; /*!< table id */
|
||||
UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list;
|
||||
/*!< list chain node */
|
||||
};
|
||||
@@ -137,19 +137,6 @@ row_mysql_is_system_table(
|
||||
|| 0 == strcmp(name + 6, "db"));
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
If a table is not yet in the drop list, adds the table to the list of tables
|
||||
which the master thread drops in background. We need this on Unix because in
|
||||
ALTER TABLE MySQL may call drop table even if the table has running queries on
|
||||
it. Also, if there are running foreign key checks on the table, we drop the
|
||||
table lazily.
|
||||
@return TRUE if the table was not yet in the drop list, and was added there */
|
||||
static
|
||||
ibool
|
||||
row_add_table_to_background_drop_list(
|
||||
/*==================================*/
|
||||
const char* name); /*!< in: table name */
|
||||
|
||||
/*******************************************************************//**
|
||||
Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */
|
||||
static
|
||||
@@ -2787,7 +2774,7 @@ loop:
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
ut_a(row_mysql_drop_list_inited);
|
||||
|
||||
next:
|
||||
drop = UT_LIST_GET_FIRST(row_mysql_drop_list);
|
||||
|
||||
n_tables = UT_LIST_GET_LEN(row_mysql_drop_list);
|
||||
@@ -2800,62 +2787,39 @@ loop:
|
||||
return(n_tables + n_tables_dropped);
|
||||
}
|
||||
|
||||
DBUG_EXECUTE_IF("row_drop_tables_in_background_sleep",
|
||||
os_thread_sleep(5000000);
|
||||
);
|
||||
table = dict_table_open_on_id(drop->table_id, FALSE,
|
||||
DICT_TABLE_OP_NORMAL);
|
||||
|
||||
table = dict_table_open_on_name(drop->table_name, FALSE, FALSE,
|
||||
DICT_ERR_IGNORE_NONE);
|
||||
|
||||
if (table == NULL) {
|
||||
/* If for some reason the table has already been dropped
|
||||
through some other mechanism, do not try to drop it */
|
||||
|
||||
goto already_dropped;
|
||||
}
|
||||
|
||||
if (!table->to_be_dropped) {
|
||||
/* There is a scenario: the old table is dropped
|
||||
just after it's added into drop list, and new
|
||||
table with the same name is created, then we try
|
||||
to drop the new table in background. */
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
goto already_dropped;
|
||||
if (!table) {
|
||||
n_tables_dropped++;
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
ut_free(drop);
|
||||
goto next;
|
||||
}
|
||||
|
||||
ut_a(!table->can_be_evicted);
|
||||
|
||||
if (!table->to_be_dropped) {
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list,
|
||||
drop);
|
||||
goto next;
|
||||
}
|
||||
|
||||
dict_table_close(table, FALSE, FALSE);
|
||||
|
||||
if (DB_SUCCESS != row_drop_table_for_mysql_in_background(
|
||||
drop->table_name)) {
|
||||
table->name)) {
|
||||
/* If the DROP fails for some table, we return, and let the
|
||||
main thread retry later */
|
||||
|
||||
return(n_tables + n_tables_dropped);
|
||||
}
|
||||
|
||||
n_tables_dropped++;
|
||||
|
||||
already_dropped:
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
|
||||
MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Dropped table ", stderr);
|
||||
ut_print_name(stderr, NULL, TRUE, drop->table_name);
|
||||
fputs(" in background drop queue.\n", stderr);
|
||||
|
||||
mem_free(drop->table_name);
|
||||
|
||||
mem_free(drop);
|
||||
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
@@ -2887,14 +2851,13 @@ which the master thread drops in background. We need this on Unix because in
|
||||
ALTER TABLE MySQL may call drop table even if the table has running queries on
|
||||
it. Also, if there are running foreign key checks on the table, we drop the
|
||||
table lazily.
|
||||
@return TRUE if the table was not yet in the drop list, and was added there */
|
||||
@return whether background DROP TABLE was scheduled for the first time */
|
||||
static
|
||||
ibool
|
||||
row_add_table_to_background_drop_list(
|
||||
/*==================================*/
|
||||
const char* name) /*!< in: table name */
|
||||
bool
|
||||
row_add_table_to_background_drop_list(table_id_t table_id)
|
||||
{
|
||||
row_mysql_drop_t* drop;
|
||||
bool added = true;
|
||||
|
||||
mutex_enter(&row_drop_list_mutex);
|
||||
|
||||
@@ -2905,31 +2868,21 @@ row_add_table_to_background_drop_list(
|
||||
drop != NULL;
|
||||
drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) {
|
||||
|
||||
if (strcmp(drop->table_name, name) == 0) {
|
||||
/* Already in the list */
|
||||
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
return(FALSE);
|
||||
if (drop->table_id == table_id) {
|
||||
added = false;
|
||||
goto func_exit;
|
||||
}
|
||||
}
|
||||
|
||||
drop = static_cast<row_mysql_drop_t*>(
|
||||
mem_alloc(sizeof(row_mysql_drop_t)));
|
||||
|
||||
drop->table_name = mem_strdup(name);
|
||||
drop = static_cast<row_mysql_drop_t*>(ut_malloc(sizeof *drop));
|
||||
drop->table_id = table_id;
|
||||
|
||||
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop);
|
||||
|
||||
MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE);
|
||||
|
||||
/* fputs("InnoDB: Adding table ", stderr);
|
||||
ut_print_name(stderr, trx, TRUE, drop->table_name);
|
||||
fputs(" to background drop list\n", stderr); */
|
||||
|
||||
func_exit:
|
||||
mutex_exit(&row_drop_list_mutex);
|
||||
|
||||
return(TRUE);
|
||||
return added;
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
@@ -4150,7 +4103,7 @@ row_drop_table_for_mysql(
|
||||
|
||||
|
||||
DBUG_EXECUTE_IF("row_drop_table_add_to_background",
|
||||
row_add_table_to_background_drop_list(table->name);
|
||||
row_add_table_to_background_drop_list(table->id);
|
||||
err = DB_SUCCESS;
|
||||
goto funct_exit;
|
||||
);
|
||||
@@ -4162,33 +4115,22 @@ row_drop_table_for_mysql(
|
||||
checks take an IS or IX lock on the table. */
|
||||
|
||||
if (table->n_foreign_key_checks_running > 0) {
|
||||
|
||||
const char* save_tablename = table->name;
|
||||
ibool added;
|
||||
|
||||
added = row_add_table_to_background_drop_list(save_tablename);
|
||||
|
||||
if (added) {
|
||||
if (row_add_table_to_background_drop_list(table->id)) {
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: You are trying to drop table ",
|
||||
stderr);
|
||||
ut_print_name(stderr, trx, TRUE, save_tablename);
|
||||
ut_print_name(stderr, trx, TRUE, table->name);
|
||||
fputs("\n"
|
||||
"InnoDB: though there is a"
|
||||
" foreign key check running on it.\n"
|
||||
"InnoDB: Adding the table to"
|
||||
" the background drop queue.\n",
|
||||
stderr);
|
||||
}
|
||||
|
||||
/* We return DB_SUCCESS to MySQL though the drop will
|
||||
happen lazily later */
|
||||
|
||||
err = DB_SUCCESS;
|
||||
} else {
|
||||
/* The table is already in the background drop list */
|
||||
err = DB_ERROR;
|
||||
}
|
||||
|
||||
goto funct_exit;
|
||||
}
|
||||
|
||||
@@ -4213,11 +4155,7 @@ row_drop_table_for_mysql(
|
||||
lock_remove_all_on_table(table, TRUE);
|
||||
ut_a(table->n_rec_locks == 0);
|
||||
} else if (table->n_ref_count > 0 || table->n_rec_locks > 0) {
|
||||
ibool added;
|
||||
|
||||
added = row_add_table_to_background_drop_list(table->name);
|
||||
|
||||
if (added) {
|
||||
if (row_add_table_to_background_drop_list(table->id)) {
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Warning: MySQL is"
|
||||
" trying to drop table ", stderr);
|
||||
|
||||
Reference in New Issue
Block a user