ExternalCommand 1.0.0
My first C++ and Qt project, hope you enjoy it.
ERROR 1168 (HY000): Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
The causes outlined below should cover 98% of all the situations where you encounter this error.
ALTER TABLE `test`.`my_merged_table` ENGINE=MERGE UNION=( `table1`,`table2`,`table3` );
You would expect MySQL to be smart enough to figure out that table1,table2,table3 are in the test database since that is where the merged table is being saved.
Except, it doesn't. It assumes table1,table2,table3 refer to the current database, and will create the merged table like that.
SELECT * FROM `information_schema`.`tables` WHERE `table_name`='one'\G *************************** 1. row *************************** TABLE_CATALOG: def TABLE_SCHEMA: sync TABLE_NAME: one TABLE_TYPE: BASE TABLE ENGINE: MyISAM VERSION: 10 ROW_FORMAT: Fixed TABLE_ROWS: 2000 AVG_ROW_LENGTH: 7 DATA_LENGTH: 14000 MAX_DATA_LENGTH: 1970324836974591 INDEX_LENGTH: 22528 DATA_FREE: 0 AUTO_INCREMENT: 2049 CREATE_TIME: 2018-09-13 19:02:01 UPDATE_TIME: 2018-09-13 19:02:01 CHECK_TIME: NULL TABLE_COLLATION: utf8_general_ci CHECKSUM: NULL CREATE_OPTIONS: TABLE_COMMENT: 1 row in set (0.00 sec)You can see the VERSION: 10 entry. All of the tables in your MERGE need to have identical versions.
Once you encounter this error on your MERGE table, MySQL clams shut and the only thing that you can now do is drop the table1. It is not possible to inspect it via SHOW commands or even via the information_schema.
If you are not sure why you are getting this error, you may want to look at exactly how MySQL defined your merge. Since
DESCRIBEand
SHOW CREATE TABLEand the likes do not work on a busted merge table. Your only other option is to look at the physical merge definition file on the disk.
The file you are looking for is in the MySQL data directory, in the subdirectory of your database, and is called example.MRG.
The format of the file is plain ASCII and it just lists, one entry per line, the tables, in order, that are part of the union for that table
It is possible to edit this file2 and remove the entries MySQL complains about. After doing this, issue a
FLUSH TABLE `thetable`;command, and you should now have a working MERGE table. 1 Ok, I lied, you can still issue every conceived MySQL command against the table, it is just that MySQL will sound like a broken record and almost petulantly refuse to honour your wishes.
The introduction To avoid looking silly and being made fun the world over for having made a program that prints hair-raising butchered Eng...