dbsake
dbsake copied to clipboard
frmsearch
I've been asked a few times to allow frmdump to search existing frms. Namely looking for things like certain column types (i.e. old DATE/TIME types) or no primary keys.
Frms are obviously being deprecated in 5.7, but older versions will be around a while and this has proven useful from time to time. I think it may be worth putting some effort in, since frmdump already exposes a lot of this information.
Here's a little proof of concept I wrote a while back that wraps the frmdump internal command to find tables without primary keys:
https://gist.github.com/abg/83af056a568f07b7b895
I think an frmsearch command should probably have a simpler output format (probably just database.table, but maybe allow a generic printf() feature similar to Percona Toolkit's pt-find script). I envision an initial set of filters along these lines:
frmsearch [options] <path-to-datadir>
Generic identifier matching options:
--database=glob -> find tables whose parent directory matches X (with filename decoding)
--table=glob -> find tables whose basename matches Y
Base table only options:
--no-primary-key -> find tables without a primary key
--engine=name -> find tables with the specified storage engine
--type-code=MYSQL_TYPE_{name} -> find tables that have a column matching the given type code
--index-type=<name> -> find tables that have a key with the given type (FULLTEXT, BTREE, etc.)
--index-name=glob -> find tables that have an index name matching the pattern
--version-before=<version string> -> frms created before <version>
--version-after=<version string> -> frms created after <version>
--version-matches=<version string> -> frms created with exactly <version>
View only options:
--definer=X (only applies to views)
--no-creation-context (i.e. no character set fields attached - a pre 5.1 view)
The database/table filters can be a fast filter that can skip parsing by just evaluating the filename path. The other filters require parsing the .frm contents.