diff options
author | unknown <ingo@mysql.com> | 2005-03-02 10:35:00 +0100 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2005-03-02 10:35:00 +0100 |
commit | 26f75ffc83e39ee915e8d4973955c950ddabb35b (patch) | |
tree | 26e67311fd029bf9026836ac8fe24ecb83ac29e1 /myisam | |
parent | 22e0b300a47321ec8dfef0bb8bc5f7c0f1449ce1 (diff) | |
download | mariadb-git-26f75ffc83e39ee915e8d4973955c950ddabb35b.tar.gz |
Bug#8306 - TRUNCATE leads to index corruption
Added a check, if the table, which we are going to create, is open.
This can happen if a MERGE mapped table is TRUNCATEd.
myisam/mi_open.c:
Bug#8306 - TRUNCATE leads to index corruption
Made test_if_reopen() globally available.
myisam/myisamdef.h:
Bug#8306 - TRUNCATE leads to index corruption
Declared test_if_reopen() as globally available.
mysql-test/r/myisam.result:
Bug#8306 - TRUNCATE leads to index corruption
The test result.
mysql-test/t/myisam.test:
Bug#8306 - TRUNCATE leads to index corruption
The test case.
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_create.c | 15 | ||||
-rw-r--r-- | myisam/mi_open.c | 2 | ||||
-rw-r--r-- | myisam/myisamdef.h | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c index f99a2c655d2..da3330627a7 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -533,6 +533,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 2a327e4bd35..2c85a03c6f4 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 736ce3f3869..916932c9eb3 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -705,6 +705,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); |