With every major release DB_TYPE_FIRST_DYNAMIC changes so dynamic engine plugins shift IDs with it. FRM files are not automatically updated which can cause issues in code that uses these IDs.
For example in 10.2 an engine will have ID 44, in 10.3 ID 44 is reserved for DB_TYPE_SEQUENCE. When a TRUNCATE is called after an upgrade MariaDB calls certain functions in the SEQUENCE engine instead of the intended engine plugin which can cause a crash.
The only workaround appears to be "ALTER TABLE comment=''"
There are several ways this could be solved. mysql_upgrade should probably be aware of this. Maybe the start ID for legacy_db_type should be something high like 100?
all new frms store the engine name, the server doesn't have to trust frm's legacy_db_type. On the opposite, it can assume that it's wrong and infer it from the engine name when the frm is opened.
Sergei Golubchik
added a comment - all new frms store the engine name , the server doesn't have to trust frm's legacy_db_type. On the opposite, it can assume that it's wrong and infer it from the engine name when the frm is opened.
"ALTER TABLE comment=''" is not an option, because important information will be stored in the comment field for spider.
A modified version of columnstore_upgrade for spider could be based on alter table engine = spider like
DELIMITER //
create procedure spider_upgrade()
`spider_upgrade`: BEGIN
DECLARE done INTEGER DEFAULT 0;
DECLARE schema_table VARCHAR(100) CHARACTER SET utf8 DEFAULT "";
DECLARE table_list CURSOR FOR select concat('`', table_schema,'`.`',table_name,'`') from information_schema.tables where engine='spider';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN table_list;
tlist: LOOP
FETCH table_list INTO schema_table;
IF done = 1 THEN LEAVE tlist;
END IF;
SET @sql_query = concat('ALTER TABLE ', schema_table, ' engine=spider');
PREPARE stmt FROM @sql_query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP;
END //
DELIMITER ;
Richard Stracke
added a comment - The same issue exists with spider engine.
"ALTER TABLE comment=''" is not an option, because important information will be stored in the comment field for spider.
A modified version of columnstore_upgrade for spider could be based on alter table engine = spider like
DELIMITER //
create procedure spider_upgrade()
`spider_upgrade`: BEGIN
DECLARE done INTEGER DEFAULT 0 ;
DECLARE schema_table VARCHAR( 100 ) CHARACTER SET utf8 DEFAULT "" ;
DECLARE table_list CURSOR FOR select concat( '`' , table_schema, '`.`' ,table_name, '`' ) from information_schema.tables where engine= 'spider' ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1 ;
OPEN table_list;
tlist: LOOP
FETCH table_list INTO schema_table;
IF done = 1 THEN LEAVE tlist;
END IF;
SET @sql_query = concat( 'ALTER TABLE ' , schema_table, ' engine=spider' );
PREPARE stmt FROM @sql_query ;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP;
END //
DELIMITER ;
all new frms store the engine name, the server doesn't have to trust frm's legacy_db_type. On the opposite, it can assume that it's wrong and infer it from the engine name when the frm is opened.