diff options
author | ingo@mysql.com <> | 2005-03-02 10:35:00 +0100 |
---|---|---|
committer | ingo@mysql.com <> | 2005-03-02 10:35:00 +0100 |
commit | d3d7c46b1c6ea65cd4a6108be2c9e57334bd741d (patch) | |
tree | 26e67311fd029bf9026836ac8fe24ecb83ac29e1 /myisam/mi_create.c | |
parent | af2999b75318fc0bcb5c2a067e1174cbbf9b3a01 (diff) | |
download | mariadb-git-d3d7c46b1c6ea65cd4a6108be2c9e57334bd741d.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.
Diffstat (limited to 'myisam/mi_create.c')
-rw-r--r-- | myisam/mi_create.c | 15 |
1 files changed, 15 insertions, 0 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, |