diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/sql/table.cc b/sql/table.cc index 69b0faf0a9e..5b8809bbced 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -831,6 +831,24 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, } +/** ensures that the enum value (read from frm) is within limits + + if not - issues a warning and resets the value to 0 + (that is, 0 is assumed to be a default value) +*/ + +static uint enum_value_with_check(THD *thd, TABLE_SHARE *share, + const char *name, uint value, uint limit) +{ + if (value < limit) + return value; + + sql_print_warning("%s.frm: invalid value %d for the field %s", + share->normalized_path.str, value, name); + return 0; +} + + /** Check if a collation has changed number @@ -840,8 +858,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, @retval new collation number (same as current collation number of no change) */ -static uint -upgrade_collation(ulong mysql_version, uint cs_number) +static uint upgrade_collation(ulong mysql_version, uint cs_number) { if (mysql_version >= 50300 && mysql_version <= 50399) { @@ -865,8 +882,6 @@ upgrade_collation(ulong mysql_version, uint cs_number) } - - /** Read data from a binary .frm file image into a TABLE_SHARE @@ -1050,9 +1065,12 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, share->incompatible_version|= HA_CREATE_USED_CHARSET; share->avg_row_length= uint4korr(frm_image+34); - share->transactional= (ha_choice) (frm_image[39] & 3); - share->page_checksum= (ha_choice) ((frm_image[39] >> 2) & 3); - share->row_type= (enum row_type) frm_image[40]; + share->transactional= (ha_choice) + enum_value_with_check(thd, share, "transactional", frm_image[39] & 3, HA_CHOICE_MAX); + share->page_checksum= (ha_choice) + enum_value_with_check(thd, share, "page_checksum", (frm_image[39] >> 2) & 3, HA_CHOICE_MAX); + share->row_type= (enum row_type) + enum_value_with_check(thd, share, "row_format", frm_image[40], ROW_TYPE_MAX); if (cs_new && !(share->table_charset= get_charset(cs_new, MYF(MY_WME)))) goto err; |