Bug #29411 deleting from a csv table leads to the table corruption
Submitted: 28 Jun 2007 6:39 Modified: 10 Jul 2007 22:39
Reporter: Ramil Kalimullin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: CSV Severity:S1 (Critical)
Version:5.1 source OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any

[28 Jun 2007 6:39] Ramil Kalimullin
Description:
mysql> create table t1(a int) engine=csv;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(1);
Query OK, 1 row affected (0.01 sec)

mysql> delete from t1;
Query OK, 1 row affected (0.01 sec)

mysql> check table t1;
+---------+-------+----------+----------+
| Table   | Op    | Msg_type | Msg_text |
+---------+-------+----------+----------+
| test.t1 | check | error    | Corrupt  | 
+---------+-------+----------+----------+
1 row in set (0.00 sec)

The same after delete from t1 limit 1;

How to repeat:
create table t1(a int) engine=csv;
insert into t1 values(1);
delete from t1;
check table t1;

or 

create table t1(a int) engine=csv;
insert into t1 values(1);
delete from t1 limit 1;
check table t1;
[5 Jul 2007 6:55] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/30348

ChangeSet@1.2536, 2007-07-05 11:55:06+05:00, ramil@mysql.com +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.
[5 Jul 2007 7:46] Sergey Vojtovich
ok to push.
[5 Jul 2007 8:05] Alexander Barkov
ok to push
[10 Jul 2007 13:27] Bugs System
Pushed into 5.1.21-beta
[10 Jul 2007 22:39] Paul DuBois
Noted in 5.1.21 changelog.

Deleting from a CSV table could corrupt it.