From 47c0ec508467b4941e6e388e33dc688b7247befb Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 29 Dec 2008 16:50:51 +0400 Subject: Bug#41441 repair csv table crashes debug server The problem: data file can not be deleted on win because there is another opened instance of this file. Data file might be opened twice, on table opening stage and during write_row execution. We need to close both instances to satisfy Win. mysql-test/r/csv.result: test result mysql-test/t/csv.test: test case storage/csv/ha_tina.cc: The problem: data file can not be deleted on win because there is another opened instance of this file. Data file might be opened twice, on table opening stage and during write_row execution. We need to close both instances to satisfy Win. --- storage/csv/ha_tina.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'storage/csv/ha_tina.cc') diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index a1ff0e29ad1..368ce7e28f3 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -1439,6 +1439,17 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) a file, which descriptor is still open. EACCES will be returned when trying to delete the "to"-file in my_rename(). */ + if (share->tina_write_opened) + { + /* + Data file might be opened twice, on table opening stage and + during write_row execution. We need to close both instances + to satisfy Win. + */ + if (my_close(share->tina_write_filedes, MYF(0))) + DBUG_RETURN(my_errno ? my_errno : -1); + share->tina_write_opened= FALSE; + } if (my_close(data_file,MYF(0)) || my_close(repair_file, MYF(0)) || my_rename(repaired_fname, share->data_file_name, MYF(0))) DBUG_RETURN(-1); -- cgit v1.2.1