summaryrefslogtreecommitdiff
path: root/storage/csv
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-07-05 11:55:06 +0500
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-07-05 11:55:06 +0500
commit558aeb0f0bfd83726ffe84f5739c0317df48980c (patch)
tree3f66f5e61fc025c642ab1bd7a6ce7d6e83813072 /storage/csv
parentbd8b9746bfbb620b0f37d030169e2ae459aec4de (diff)
downloadmariadb-git-558aeb0f0bfd83726ffe84f5739c0317df48980c.tar.gz
Fix for bug #29411: deleting from a csv table leads to the table corruption
Problem: we don't adjust share->rows_recorded and local_saved_data_file_length deleting rows from a CSV table, so following table check may fail. Fix: properly adjust those values. mysql-test/r/csv.result: Fix for bug #29411: deleting from a csv table leads to the table corruption - test result. mysql-test/t/csv.test: Fix for bug #29411: deleting from a csv table leads to the table corruption - test case. storage/csv/ha_tina.cc: Fix for bug #29411: deleting from a csv table leads to the table corruption - decrement share->rows_recorded in the ha_tina::delete_row(). - set share->rows_recorded and local_saved_data_file_length to 0 in the ha_tina::delete_all_rows(). - adjust local_saved_data_file_length after cleaning up in the ha_tina::rnd_end().
Diffstat (limited to 'storage/csv')
-rw-r--r--storage/csv/ha_tina.cc30
1 files changed, 23 insertions, 7 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 2ee96fd5d05..c6cbcbd422f 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -960,6 +960,11 @@ int ha_tina::delete_row(const uchar * buf)
DBUG_RETURN(-1);
stats.records--;
+ /* Update shared info */
+ DBUG_ASSERT(share->rows_recorded);
+ pthread_mutex_lock(&share->mutex);
+ share->rows_recorded--;
+ pthread_mutex_unlock(&share->mutex);
/* DELETE should never happen on the log table */
DBUG_ASSERT(!share->is_log_table);
@@ -1146,6 +1151,7 @@ int ha_tina::rnd_end()
if ((chain_ptr - chain) > 0)
{
+ off_t temp_file_length= 0;
tina_set *ptr= chain;
/*
@@ -1171,15 +1177,18 @@ int ha_tina::rnd_end()
while ((file_buffer_start != -1)) // while not end of file
{
bool in_hole= get_write_pos(&write_end, ptr);
+ off_t write_length= write_end - write_begin;
/* if there is something to write, write it */
- if ((write_end - write_begin) &&
- (my_write(update_temp_file,
- (uchar*)(file_buff->ptr() +
- (write_begin - file_buff->start())),
- write_end - write_begin, MYF_RW)))
- goto error;
-
+ if (write_length)
+ {
+ if (my_write(update_temp_file,
+ (uchar*) (file_buff->ptr() +
+ (write_begin - file_buff->start())),
+ write_length, MYF_RW))
+ goto error;
+ temp_file_length+= write_length;
+ }
if (in_hole)
{
/* skip hole */
@@ -1232,6 +1241,8 @@ int ha_tina::rnd_end()
Here we record this fact to the meta-file.
*/
(void)write_meta_file(share->meta_file, share->rows_recorded, FALSE);
+
+ local_saved_data_file_length= temp_file_length;
}
DBUG_RETURN(0);
@@ -1390,6 +1401,11 @@ int ha_tina::delete_all_rows()
rc= my_chsize(share->tina_write_filedes, 0, 0, MYF(MY_WME));
stats.records=0;
+ /* Update shared info */
+ pthread_mutex_lock(&share->mutex);
+ share->rows_recorded= 0;
+ pthread_mutex_unlock(&share->mutex);
+ local_saved_data_file_length= 0;
DBUG_RETURN(rc);
}