diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2190353a9cb..b9b5ff47cf6 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -386,6 +386,25 @@ uint filename_to_tablename(const char *from, char *to, uint to_length) /** + Check if given string begins with "#mysql50#" prefix + + @param name string to check cut + + @retval + FALSE no prefix found + @retval + TRUE prefix found +*/ + +bool check_mysql50_prefix(const char *name) +{ + return (name[0] == '#' && + !strncmp(name, MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH)); +} + + +/** Check if given string begins with "#mysql50#" prefix, cut it if so. @param from string to check and cut @@ -400,9 +419,7 @@ uint filename_to_tablename(const char *from, char *to, uint to_length) uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length) { - if (from[0] == '#' && - !strncmp(from, MYSQL50_TABLE_NAME_PREFIX, - MYSQL50_TABLE_NAME_PREFIX_LENGTH)) + if (check_mysql50_prefix(from)) return (uint) (strmake(to, from + MYSQL50_TABLE_NAME_PREFIX_LENGTH, to_length - 1) - to); return 0; @@ -2232,10 +2249,10 @@ static int sort_keys(KEY *a, KEY *b) { if (!(b_flags & HA_NOSAME)) return -1; - if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) + if ((a_flags ^ b_flags) & HA_NULL_PART_KEY) { /* Sort NOT NULL keys before other keys */ - return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1; + return (a_flags & HA_NULL_PART_KEY) ? 1 : -1; } if (a->name == primary_key_name) return -1; @@ -4633,7 +4650,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, table->next_global= 0; save_next_local= table->next_local; table->next_local= 0; - select->table_list.first= (uchar*)table; + select->table_list.first= table; /* Time zone tables and SP tables can be add to lex->query_tables list, so it have to be prepared. @@ -5347,6 +5364,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { + if (src_table->table->file->ht == partition_hton) + { + my_error(ER_PARTITION_NO_TEMPORARY, MYF(0)); + goto err; + } if (find_temporary_table(thd, db, table_name)) goto table_exists; dst_path_length= build_tmptable_filename(thd, dst_path, sizeof(dst_path)); @@ -5411,14 +5433,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, /* For partitioned tables we need to copy the .par file as well since it is used in open_table_def to even be able to create a new handler. - There is no way to find out here if the original table is a - partitioned table so we copy the file and ignore any errors. */ - fn_format(tmp_path, dst_path, reg_ext, ".par", MYF(MY_REPLACE_EXT)); - strmov(dst_path, tmp_path); - fn_format(tmp_path, src_path, reg_ext, ".par", MYF(MY_REPLACE_EXT)); - strmov(src_path, tmp_path); - my_copy(src_path, dst_path, MYF(MY_DONT_OVERWRITE_FILE)); + if (src_table->table->file->ht == partition_hton) + { + fn_format(tmp_path, dst_path, reg_ext, ".par", MYF(MY_REPLACE_EXT)); + strmov(dst_path, tmp_path); + fn_format(tmp_path, src_path, reg_ext, ".par", MYF(MY_REPLACE_EXT)); + strmov(src_path, tmp_path); + my_copy(src_path, dst_path, MYF(MY_DONT_OVERWRITE_FILE)); + } #endif DBUG_EXECUTE_IF("sleep_create_like_before_ha_create", my_sleep(6000000);); @@ -6604,6 +6627,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, uint *index_add_buffer= NULL; uint candidate_key_count= 0; bool no_pk; + ulong explicit_used_fields= 0; DBUG_ENTER("mysql_alter_table"); /* @@ -6874,6 +6898,7 @@ view_err: change the row format in update_create_info(). */ create_info->used_fields|= HA_CREATE_USED_ROW_FORMAT; + explicit_used_fields|= HA_CREATE_USED_ROW_FORMAT; } DBUG_PRINT("info", ("old type: %s new type: %s", @@ -7034,6 +7059,9 @@ view_err: if (mysql_prepare_alter_table(thd, table, create_info, alter_info)) goto err; + /* Remove markers set for update_create_info */ + create_info->used_fields&= ~explicit_used_fields; + if (need_copy_table == ALTER_TABLE_METADATA_ONLY) need_copy_table= alter_info->change_level; |