Bug #1389 ALTER TABLE allows changing TYPE of MERGE table
Submitted: 24 Sep 2003 6:52 Modified: 12 Dec 2003 14:04
Reporter: Jeremy Cole (Basic Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:All OS:Any (All)
Assigned to: Paul DuBois CPU Architecture:Any

[24 Sep 2003 6:52] Jeremy Cole
Description:
ALTER TABLE allows you to change the TYPE of a MERGE table to another type without any error or warning.  It actually copies the rows from the underlying MyISAM tables to the new table.

How to repeat:
mysql> create table t1 (i int);
Query OK, 0 rows affected (0.00 sec)

mysql> create table t2 (i int);
Query OK, 0 rows affected (0.00 sec)

mysql> create table total (i int) type=merge union=(t1, t2);
Query OK, 0 rows affected (0.00 sec)

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

mysql> insert into t2 (i) values (2);
Query OK, 1 row affected (0.00 sec)

mysql> show table status like 'total' \G
*************************** 1. row ***************************
           Name: total
           Type: MRG_MyISAM
     Row_format: Fixed
           Rows: 2
 Avg_row_length: 5
    Data_length: 10
Max_data_length: NULL
   Index_length: 0
      Data_free: 0
 Auto_increment: NULL
    Create_time: NULL
    Update_time: NULL
     Check_time: NULL
        Charset: latin1_swedish_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.01 sec)

mysql> alter table total type=myisam;
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> show table status like 'total' \G
*************************** 1. row ***************************
           Name: total
           Type: MyISAM
     Row_format: Fixed
           Rows: 2
 Avg_row_length: 5
    Data_length: 10
Max_data_length: 21474836479
   Index_length: 1024
      Data_free: 0
 Auto_increment: NULL
    Create_time: 2003-09-24 09:48:49
    Update_time: 2003-09-24 09:48:49
     Check_time: NULL
        Charset: latin1_swedish_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.00 sec)

Suggested fix:
I would recommend it to be an error to change the TYPE of a MERGE table.  Doing so could cause a lot of trouble if it was a merge of many large tables.

At very least it should generate a warning on 4.1.
[16 Oct 2003 8:53] Victor Vagin
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

it may be useful to change type.
warning will not help you, because you will see it after converting.
[16 Oct 2003 9:13] Jeremy Cole
If this is an expected behaviour and there is no intention to change it, then at very least it should be documented properly.

I will however disagree that it is a useful feature, as there are many other, more proper ways to achieve the same goal.  I would still prefer that it returned an error (which could suggest a proper way).
[12 Dec 2003 8:57] Victor Vagin
[20:44] <vva> monty: btw, could you settle a dispute between 
    me and Jeremy Cole about Bug #1389 "ALTER TABLE allows changing 
    TYPE of MERGE table " (http://bugs.mysql.com/bug.php?id=1389)
[20:44] <vva> shall I fix it?
[20:55] <monty> checking
[20:57] <monty> I agree with you that it works like intended
[20:58] <monty> I don't see anything wrong with the current one;  
    The only differnce compared to a normal ALTER TABLE is that 
    you still have the original data left in the mapped tables
[20:59] <monty> send an email to docs-request to document this 
    properly and change bug report to docs-request
[12 Dec 2003 14:04] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).