summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/csv.result13
-rw-r--r--mysql-test/t/csv.test13
-rw-r--r--storage/csv/ha_tina.cc11
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result
index 8bc6114dbc2..9deaf55c535 100644
--- a/mysql-test/r/csv.result
+++ b/mysql-test/r/csv.result
@@ -5394,4 +5394,17 @@ select * from t1;
ERROR HY000: File './test/t1.CSV' not found (Errcode: 2)
unlock tables;
drop table t1;
+create table t1(a enum ('a') not null) engine=csv;
+insert into t1 values (2);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+select * from t1 limit 1;
+ERROR HY000: Table 't1' is marked as crashed and should be repaired
+repair table t1;
+Table Op Msg_type Msg_text
+test.t1 repair Warning Data truncated for column 'a' at row 1
+test.t1 repair status OK
+select * from t1 limit 1;
+a
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index ac628f96a0f..67295e8756f 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -1804,4 +1804,17 @@ unlock tables;
drop table t1;
--disconnect con1
+#
+# Bug#41441 repair csv table crashes debug server
+#
+# Note: The test should be removed after Bug#33717 is fixed
+
+create table t1(a enum ('a') not null) engine=csv;
+insert into t1 values (2);
+--error ER_CRASHED_ON_USAGE
+select * from t1 limit 1;
+repair table t1;
+select * from t1 limit 1;
+drop table t1;
+
--echo End of 5.1 tests
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);