So… in removing the FRM file in Drizzle, I found a bit of a nugget on how drop table works (currently in the MySQL server and now “did” in Drizzle).
If you DROP TABLE t1; this is what happens
- open the .frm file
- read first 10bytes (oh, and if you get EIO there, in a SELECT * FROM INFORMATION_SCHEMA.TABLES you’ll get “Error” instead of “Base Table”)
- if (header != (unsigned char) 254 || header != 1 ||
(header != FRM_VER && header != FRM_VER+1 &&
(header < FRM_VER+3 || header > FRM_VER+4)))
Which means that you probably (well, should have) set your enum legacy_db_type to DB_TYPE_UNKNOWN in the caller of bool mysql_frm_type(Session *, char *path, enum legacy_db_type *dbt) otherwise you end up in some form of pain.
- Else, *dbt= (enum legacy_db_type) (uint) *(header + 3);
return true;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Is probably a .frm table
I do like the “probably”.
Oh, and on a “storage engine api” front, some places seem to expect handler::delete_table(const char* name) to return ENOENT on table not existing. In reality however:
- int ha_heap::delete_table(const char *name)
-Â int error= heap_delete_table(name);
-Â return error == ENOENT ? 0 : error;
+Â return heap_delete_table(name);
- InnoDB (note the behaviour of returning DB_TABLE_NOT_FOUND… which isn’t ENOENT)
err = DB_TABLE_NOT_FOUND;
fputs(“Â InnoDB: Error: table “, stderr);
ut_print_name(stderr, trx, TRUE, name);
fputs(” does not exist in the InnoDB internaln”
“InnoDB: data dictionary though MySQL is”
” trying to drop it.n”
“InnoDB: Have you copied the .frm file”
” of the table to then”
“InnoDB: MySQL database directory”
” from another database?n”
“InnoDB: You can look for further help fromn”
- and MyISAM would generate the error message itself, but that’s fixed with:
-Â if (my_delete_with_symlink(from, MYF(MY_WME)))
+Â if (my_delete_with_symlink(from, 0))
and just to add to the fun, elsewhere in the code, a access(2) call on the frm file name is used to determine if the table exists or not.
The road to removing the FRM has all sorts of these weird-ass things along it. Kinda nice to be able to replace this with something better (and, hopefully – good).
But let me sum up with sql_table.cc:
“This code is wrong and will be removed, please do not copy.”