In order to fix these bugs without regressions:
let's add MTR debug tests to print verbose information about keys and key segments.
The following members of the underlying structures are of interest:
1. KEY::name and KEY::flag in mysql_prepare_create_table()
2. MI_KEYDEF::flag, HA_KEYSEG::type and HA_KEYSEG::flags in ha_myisam::create(), after copying from KEY.
The underlying code is very hard to understand and simplify. The way how flags HA_SPACE_PACK_USED, HA_VAR_LENGTH_KEY, HA_PACK_KEY, HA_BINARY_PACK_KEY walk through the code are especually hard to follow.
The proposed test should work in debug builds and display flags using server Notes:
About the following output should be descriptive enough:
The new test should cover all essential data type pairs as well as partial key lengths for TEXT. Pairs are needed because flags are calculated in different ways on the first key segment versus other key segments.