summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-03-02 10:56:13 +0100
committerunknown <ingo@mysql.com>2005-03-02 10:56:13 +0100
commitcc4455631a51c999324759391f6f843cf97fd923 (patch)
tree04e597e0f2cb62e0de40965ce2cecaf4f015f6ab
parentc4409a7cbf9b43ed450340ba9dd6a33f821df5f2 (diff)
parent26f75ffc83e39ee915e8d4973955c950ddabb35b (diff)
downloadmariadb-git-cc4455631a51c999324759391f6f843cf97fd923.tar.gz
Merge
innobase/include/srv0srv.h: Auto merged innobase/srv/srv0srv.c: Auto merged myisam/mi_create.c: Auto merged myisam/mi_open.c: Auto merged myisam/myisamdef.h: Auto merged sql/ha_innodb.cc: Auto merged mysql-test/r/myisam.result: SCCS merged mysql-test/t/myisam.test: SCCS merged sql/ha_innodb.h: SCCS merged
-rw-r--r--innobase/include/srv0srv.h6
-rw-r--r--innobase/srv/srv0srv.c7
-rw-r--r--myisam/mi_create.c15
-rw-r--r--myisam/mi_open.c2
-rw-r--r--myisam/myisamdef.h1
-rw-r--r--mysql-test/r/myisam.result18
-rw-r--r--mysql-test/t/myisam.test26
-rw-r--r--sql/ha_innodb.cc4
-rw-r--r--sql/ha_innodb.h1
9 files changed, 69 insertions, 11 deletions
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index 27cdaf2e505..5d76ac3d775 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -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;
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 39bb5094053..538fd6ffc08 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -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
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 1f6ed87182c..3e144cfcbfb 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -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,
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 9a6cfe9f33c..504bc33ecc1 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -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;
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 9a92a916558..b66d7e71a05 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -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);
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index b0cb6462252..73550d97dad 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -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 ---
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index df3b8743b10..9464513413a 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -528,6 +528,32 @@ 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
#
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 37dcad691e6..75d1e2d8353 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -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.
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index e5a43a64df0..1c8063b9373 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -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;
}