Below is the list of changes that have just been committed into a local
5.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-05 11:55:06+05:00, ramil@stripped +3 -0
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@stripped, 2007-07-05 11:55:04+05:00, ramil@stripped +16 -2
Fix for bug #29411: deleting from a csv table leads to the table corruption
- test result.
mysql-test/t/csv.test@stripped, 2007-07-05 11:55:04+05:00, ramil@stripped +13 -0
Fix for bug #29411: deleting from a csv table leads to the table corruption
- test case.
storage/csv/ha_tina.cc@stripped, 2007-07-05 11:55:04+05:00, ramil@stripped +23 -7
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().
diff -Nrup a/mysql-test/r/csv.result b/mysql-test/r/csv.result
--- a/mysql-test/r/csv.result 2007-07-03 17:17:45 +05:00
+++ b/mysql-test/r/csv.result 2007-07-05 11:55:04 +05:00
@@ -4945,8 +4945,6 @@ SELECT * FROM bug13894;
val
6
6
-5
-11
DROP TABLE bug13894;
DROP TABLE IF EXISTS bug14672;
CREATE TABLE bug14672 (c1 integer) engine = CSV;
@@ -5290,5 +5288,21 @@ a b
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
+drop table t1;
+create table t1(a int) engine=csv;
+insert into t1 values (0), (1), (2);
+delete from t1 limit 2;
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+select * from t1;
+a
+2
+delete from t1;
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+select * from t1;
+a
drop table t1;
End of 5.1 tests
diff -Nrup a/mysql-test/t/csv.test b/mysql-test/t/csv.test
--- a/mysql-test/t/csv.test 2007-06-27 16:19:58 +05:00
+++ b/mysql-test/t/csv.test 2007-07-05 11:55:04 +05:00
@@ -1698,4 +1698,17 @@ select * from t1;
check table t1;
drop table t1;
+#
+# Bug #29411: deleting from a csv table leads to the table corruption
+#
+create table t1(a int) engine=csv;
+insert into t1 values (0), (1), (2);
+delete from t1 limit 2;
+check table t1;
+select * from t1;
+delete from t1;
+check table t1;
+select * from t1;
+drop table t1;
+
--echo End of 5.1 tests
diff -Nrup a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
--- a/storage/csv/ha_tina.cc 2007-07-03 17:17:45 +05:00
+++ b/storage/csv/ha_tina.cc 2007-07-05 11:55:04 +05:00
@@ -960,6 +960,11 @@ int ha_tina::delete_row(const uchar * bu
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);
}
| Thread |
|---|
| • bk commit into 5.1 tree (ramil:1.2536) BUG#29411 | ramil | 5 Jul |