Bug #27639 truncate table causes disk columns to become memory columns
Submitted: 4 Apr 2007 8:52 Modified: 10 Apr 2007 6:09
Reporter: Steve Edwards Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Disk Data Severity:S2 (Serious)
Version:5.1.16 OS:Linux (Debian 64bit (sarge))
Assigned to: Assigned Account CPU Architecture:Any
Tags: disk storage column truncate table memory

[4 Apr 2007 8:52] Steve Edwards
Description:
TRUNCATE TABLE; causes disk based columns to become memory columns.

How to repeat:
mysql> CREATE TABLE files (
    ->   id int(11) NOT NULL auto_increment,
    ->   fileName varchar(50) default NULL,
    ->   fileContents mediumblob,
    ->   PRIMARY KEY  (id)
    -> ) TABLESPACE ts_1 STORAGE DISK
    ->   ENGINE NDB;
Query OK, 0 rows affected (1.65 sec)

mysql> quit
Bye
root@xxxxx:~/# ndb_desc -d xxx files
...
-- Attributes --
id Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
fileName Varchar(50;latin1_swedish_ci) NULL AT=FIXED ST=DISK
fileContents Blob(256,4000;8) NULL AT=FIXED ST=MEMORY

mysql> truncate table files;
Query OK, 0 rows affected (2.53 sec)

root@xxxxx:~/# ndb_desc -d xxx files
-- Attributes --
id Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
fileName Varchar(50;latin1_swedish_ci) NULL AT=SHORT_VAR ST=MEMORY
fileContents Blob(256,4000;8) NULL AT=FIXED ST=MEMORY

Suggested fix:
Make TRUNCATE copy/drop/create table operation aware of disk based attributes.
[5 Apr 2007 7:23] Jonas Oreland
Hmm...this looks very much like
http://bugs.mysql.com/bug.php?id=25296

But that is reported as fixed...weird
[5 Apr 2007 11:39] Hartmut Holzgraefe
The fix for bug #25296 fixed the SHOW CREATE TABLE symptom 
only but not the actual problem it seems
[5 Apr 2007 11:57] Hartmut Holzgraefe
The fix only changes the SHOW CREATE TABLE output, the actual columns 
still change from ST=DISK to ST=MEMORY in ndb_desc output.

So the bug still exists, and even worse it is now "covered" by the
now wrong SHOW CREATE output.

ndb_desc differences before and after truncate:

--- n1  2007-04-05 13:56:25.000000000 +0200
+++ n2  2007-04-05 13:56:32.000000000 +0200
@@ -1,6 +1,6 @@
 > ndb_desc -d test t1
 -- t1 --
-Version: 5
+Version: 6
 Fragment type: 5
 K Value: 6
 Min load factor: 78
@@ -16,8 +16,8 @@
 member_id Unsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
 last_name Varchar(50;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
 first_name Varchar(50;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
-dob Date NOT NULL AT=FIXED ST=DISK
-joined Date NOT NULL AT=FIXED ST=DISK
+dob Date NOT NULL AT=FIXED ST=MEMORY
+joined Date NOT NULL AT=FIXED ST=MEMORY
 
 -- Indexes -- 
 PRIMARY KEY(member_id) - UniqueHashIndex
[5 Apr 2007 11:59] Hartmut Holzgraefe
Duplicate of bug 25296, reopened that bug with additional info from this one