1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

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.
This commit is contained in:
unknown
2005-03-02 10:35:00 +01:00
parent 22e0b300a4
commit 26f75ffc83
5 changed files with 61 additions and 1 deletions

View File

@ -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,