summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.>2006-04-11 12:19:28 +0200
committerunknown <msvensson@shellback.>2006-04-11 12:19:28 +0200
commitc73df2254f75a4f9565df55446bb9c75adea10dd (patch)
tree80b8074b1996566113c46b23fe7d023918200f51 /storage
parent08dd4932ce3d3ef14342b5b7ffd81eb8be4a66c2 (diff)
parentea28e412ecac5bf2d6da8b613b68e034fc7ffb3c (diff)
downloadmariadb-git-c73df2254f75a4f9565df55446bb9c75adea10dd.tar.gz
Merge 192.168.0.10:mysql/mysql-5.1
into shellback.:C:/mysql/my51-bug17368 sql/ha_partition.cc: Auto merged
Diffstat (limited to 'storage')
-rw-r--r--storage/csv/ha_tina.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 537e5b1bcc4..810292488fa 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -451,6 +451,7 @@ static int free_share(TINA_SHARE *share)
result_code= 1;
if (share->mapped_file)
my_munmap(share->mapped_file, share->file_stat.st_size);
+ share->mapped_file= NULL;
result_code= my_close(share->data_file,MYF(0));
hash_delete(&tina_open_tables, (byte*) share);
thr_lock_delete(&share->lock);
@@ -1228,9 +1229,10 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
my_free((char*)buf, MYF(0));
- /* The file is ok */
if (rc == HA_ERR_END_OF_FILE)
{
+ /* All rows were read ok until end of file, the file does not need repair. */
+
/*
If rows_recorded != rows_repaired, we should update
rows_recorded value to the current amount of rows.
@@ -1258,11 +1260,29 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
if (my_munmap(share->mapped_file, share->file_stat.st_size))
DBUG_RETURN(-1);
-
- my_rename(repaired_fname, share->data_file_name, MYF(0));
-
/* We set it to null so that get_mmap() won't try to unmap it */
share->mapped_file= NULL;
+
+ /*
+ Close the "to"-file before renaming
+ On Windows one cannot rename a file, which descriptor
+ is still open. EACCES will be returned when trying to delete
+ the "to"-file in my_rename()
+ */
+ my_close(share->data_file,MYF(0));
+
+ if (my_rename(repaired_fname, share->data_file_name, MYF(0)))
+ DBUG_RETURN(-1);
+
+ /* Open the file again, it should now be repaired */
+ if ((share->data_file= my_open(share->data_file_name, O_RDWR|O_APPEND,
+ MYF(0))) == -1)
+ DBUG_RETURN(-1);
+
+ /* Seek to end of file, any inserts will be appended there */
+ if (my_seek(share->data_file, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR)
+ DBUG_RETURN(-1);
+
if (get_mmap(share, 0) > 0)
DBUG_RETURN(-1);