Commit 306bd2fc authored by ingo@mysql.com's avatar ingo@mysql.com

Merge

parents b9ae89a1 d3d7c46b
......@@ -52,7 +52,7 @@ extern ulint* srv_data_file_is_raw_partition;
extern ibool srv_auto_extend_last_data_file;
extern ulint srv_last_file_size_max;
extern ulint srv_auto_extend_increment;
extern ulong srv_auto_extend_increment;
extern ibool srv_created_new_raw;
......@@ -112,11 +112,9 @@ extern ibool srv_use_checksums;
extern ibool srv_set_thread_priorities;
extern int srv_query_thread_priority;
extern ulint srv_max_purge_lag;
extern ulong srv_max_purge_lag;
extern ibool srv_use_awe;
extern ibool srv_use_adaptive_hash_indexes;
extern ulint srv_max_purge_lag;
/*-------------------------------------------*/
extern ulint srv_n_rows_inserted;
......
......@@ -97,7 +97,7 @@ ulint srv_last_file_size_max = 0; /* if != 0, this tells
the max size auto-extending
may increase the last data
file size */
ulint srv_auto_extend_increment = 8; /* If the last data file is
ulong srv_auto_extend_increment = 8; /* If the last data file is
auto-extended, we add this
many pages to it at a time */
ulint* srv_data_file_is_raw_partition = NULL;
......@@ -323,9 +323,6 @@ disable adaptive hash indexes */
ibool srv_use_awe = FALSE;
ibool srv_use_adaptive_hash_indexes = TRUE;
/* Maximum allowable purge history length. <=0 means 'infinite'. */
ulint srv_max_purge_lag = 0;
/*-------------------------------------------*/
ulint srv_n_spin_wait_rounds = 20;
ulint srv_n_free_tickets_to_enter = 500;
......@@ -972,6 +969,8 @@ srv_general_init(void)
/*======================= InnoDB Server FIFO queue =======================*/
/* Maximum allowable purge history length. <=0 means 'infinite'. */
ulong srv_max_purge_lag = 0;
/*************************************************************************
Puts an OS thread to wait if there are too many concurrent threads
......
......@@ -558,6 +558,21 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
create_flag=MY_DELETE_OLD;
}
/*
If a MRG_MyISAM table is in use, the mapped MyISAM tables are open,
but no entry is made in the table cache for them.
A TRUNCATE command checks for the table in the cache only and could
be fooled to believe, the table is not open.
Pull the emergency brake in this situation. (Bug #8306)
*/
if (test_if_reopen(filename))
{
my_printf_error(0, "MyISAM table '%s' is in use "
"(most likely by a MERGE table). Try FLUSH TABLES.",
MYF(0), name + dirname_length(name));
goto err;
}
if ((file= my_create_with_symlink(linkname_ptr,
filename,
0, O_RDWR | O_TRUNC,
......
......@@ -50,7 +50,7 @@ if (pos > end_pos) \
** In MySQL the server will handle version issues.
******************************************************************************/
static MI_INFO *test_if_reopen(char *filename)
MI_INFO *test_if_reopen(char *filename)
{
LIST *pos;
......
......@@ -708,6 +708,7 @@ void mi_copy_status(void* to,void *from);
my_bool mi_check_status(void* param);
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
extern MI_INFO *test_if_reopen(char *filename);
my_bool check_table_is_closed(const char *name, const char *where);
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup);
int mi_open_keyfile(MYISAM_SHARE *share);
......
......@@ -568,6 +568,24 @@ select count(*) from t1 where a is null;
count(*)
2
drop table t1;
create table t1 (c1 int, index(c1));
create table t2 (c1 int, index(c1)) engine=merge union=(t1);
insert into t1 values (1);
flush tables;
select * from t2;
c1
1
flush tables;
truncate table t1;
insert into t1 values (1);
flush tables;
select * from t2;
c1
1
truncate table t1;
ERROR HY000: MyISAM table 't1' is in use (most likely by a MERGE table). Try FLUSH TABLES.
insert into t1 values (1);
drop table t1,t2;
set storage_engine=MyISAM;
drop table if exists t1,t2,t3;
--- Testing varchar ---
......
......@@ -527,6 +527,32 @@ explain select count(*) from t1 where a is null;
select count(*) from t1 where a is null;
drop table t1;
#
# Bug #8306: TRUNCATE leads to index corruption
#
create table t1 (c1 int, index(c1));
create table t2 (c1 int, index(c1)) engine=merge union=(t1);
insert into t1 values (1);
# Close all tables.
flush tables;
# Open t2 and (implicitly) t1.
select * from t2;
# Truncate after flush works (unless another threads reopens t2 in between).
flush tables;
truncate table t1;
insert into t1 values (1);
# Close all tables.
flush tables;
# Open t2 and (implicitly) t1.
select * from t2;
# Truncate t1, wich was not recognized as open without the bugfix.
# Now, it should fail with a table-in-use error message.
--error 1105
truncate table t1;
# The insert used to fail on the crashed table.
insert into t1 values (1);
drop table t1,t2;
#
# Test varchar
#
......
......@@ -2631,7 +2631,9 @@ ha_innobase::write_row(
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time();
if (user_thd->lex->sql_command == SQLCOM_ALTER_TABLE
if ((user_thd->lex->sql_command == SQLCOM_ALTER_TABLE
|| user_thd->lex->sql_command == SQLCOM_CREATE_INDEX
|| user_thd->lex->sql_command == SQLCOM_DROP_INDEX)
&& num_write_row >= 10000) {
/* ALTER TABLE is COMMITted at every 10000 copied rows.
The IX table lock for the original table has to be re-issued.
......
......@@ -239,7 +239,6 @@ extern ulong srv_auto_extend_increment;
extern ulong srv_n_spin_wait_rounds;
extern ulong srv_n_free_tickets_to_enter;
extern ulong srv_thread_sleep_delay;
extern ulong srv_max_purge_lag;
extern ulong srv_thread_concurrency;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment