Commit e69e0cff authored by Zardosht Kasheff's avatar Zardosht Kasheff

refs #42, exit gracefully from ha_tokudb::create if we notice a field that is invalid

parent 1f85678a
...@@ -6961,6 +6961,24 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -6961,6 +6961,24 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
goto cleanup; goto cleanup;
} }
// validate the fields in the table. If the table has fields
// we do not support that came from an old version of MySQL,
// gracefully return an error
for (uint32_t i = 0; i < form->s->fields; i++) {
Field* field = table_share->field[i];
if (!field_valid_for_tokudb_table(field)) {
sql_print_error("Table %s has an invalid field %s, that was created "
"with an old version of MySQL. This field is no longer supported. "
"This is probably due to an alter table engine=TokuDB. To load this "
"table, do a dump and load",
name,
field->field_name
);
error = HA_ERR_UNSUPPORTED;
goto cleanup;
}
}
newname = (char *)my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME)); newname = (char *)my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME));
if (newname == NULL){ error = ENOMEM; goto cleanup;} if (newname == NULL){ error = ENOMEM; goto cleanup;}
......
...@@ -93,6 +93,61 @@ PATENT RIGHTS GRANT: ...@@ -93,6 +93,61 @@ PATENT RIGHTS GRANT:
#error "WORDS_BIGENDIAN not supported" #error "WORDS_BIGENDIAN not supported"
#endif #endif
// returns true if the field is a valid field to be used
// in a TokuDB table. The non-valid fields are those
// that have been deprecated since before 5.1, and can
// only exist through upgrades of old versions of MySQL
bool field_valid_for_tokudb_table(Field* field) {
bool ret_val = false;
enum_field_types mysql_type = field->real_type();
switch (mysql_type) {
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_FLOAT:
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_TIME2:
#endif
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_LONG_BLOB:
ret_val = true;
goto exit;
//
// I believe these are old types that are no longer
// in any 5.1 tables, so tokudb does not need
// to worry about them
// Putting in this assert in case I am wrong.
// Do not support geometry yet.
//
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_NULL:
ret_val = false;
}
exit:
return ret_val;
}
void get_var_field_info( void get_var_field_info(
uint32_t* field_len, // output: length of field uint32_t* field_len, // output: length of field
uint32_t* start_offset, // output, length of offset where data starts uint32_t* start_offset, // output, length of offset where data starts
......
...@@ -197,6 +197,8 @@ typedef struct st_key_and_col_info { ...@@ -197,6 +197,8 @@ typedef struct st_key_and_col_info {
uint32_t num_offset_bytes; //number of bytes needed to encode the offset uint32_t num_offset_bytes; //number of bytes needed to encode the offset
} KEY_AND_COL_INFO; } KEY_AND_COL_INFO;
bool field_valid_for_tokudb_table(Field* field);
void get_var_field_info( void get_var_field_info(
uint32_t* field_len, uint32_t* field_len,
uint32_t* start_offset, uint32_t* start_offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment