Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.0.6
-
None
-
None
Description
IMO, this should work, or should be prohibited to prevent disasters:
MariaDB [test]> CREATE TABLE t (c INT NOT NULL) ENGINE=CONNECT; |
Query OK, 0 rows affected, 2 warnings (0.13 sec) |
|
Warning (Code 1105): No table_type. Will be set to DOS |
Warning (Code 1105): No file name. Table will use t.dos |
MariaDB [test]> INSERT INTO t VALUES (1), (2), (3); |
Query OK, 3 rows affected (0.00 sec) |
Records: 3 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> SELECT * FROM t; |
+---+ |
| c |
|
+---+ |
| 1 |
|
| 2 |
|
| 3 |
|
+---+ |
3 rows in set (0.01 sec) |
|
MariaDB [test]> ALTER TABLE t ENGINE = InnoDB; |
Query OK, 1 row affected (0.71 sec)
|
Records: 1 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> SELECT * FROM t; |
+---+ |
| c |
|
+---+ |
| 0 |
|
+---+ |
1 row in set (0.01 sec) |
This is a difficult and complex issue because ALTER TABLE can be used for a great variety of action. Therefore it will take some time to fix. Meanwhile, as it is almost impossible for a storage engine to know for sure what an ALTER TABLE will do, prohibiting would be completely prohibiting the ALTER TABLE command. It may be too drastic even most of the time it is possible to simply drop and recreate the table (for the CONNECT engine this generally does not erase the data but there is the exception of tables created without giving the file name for which the data file is erased on DROP)
Therefore, waiting for a fix, just try to avoid using ALTER TABLE with the CONNECT engine. For instance use CREATE or DROP INDEX instead of ALTER, and instead of doing:
ALTER TABLE t ENGINE = InnoDB;
do:
CREATE TABLE t1 ENGINE=InnoDB select * from t; DROP t; RENAME TABLE t1 TO t;
Normally CONNECT warns users that using ALTER TABLE is unsafe but unfortunately in the above problem the function check_if_incompatible_data was not called.