diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-16 14:05:45 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-16 14:05:45 +0300 |
commit | f458e198c0bea67c6a3787738108bbfb139639bd (patch) | |
tree | e01d8c096a63bacfb5895de6e55d011d666e9d38 /sql | |
parent | 8c5e18c9cfde61197a9f653efa08450ae9a6ce0a (diff) | |
parent | 19f0d6b2d9930f83688943b8f98a8b7397584df9 (diff) | |
download | mariadb-git-f458e198c0bea67c6a3787738108bbfb139639bd.tar.gz |
Merge with 5.2
Diffstat (limited to 'sql')
-rw-r--r-- | sql/create_options.cc | 3 | ||||
-rw-r--r-- | sql/create_options.h | 2 | ||||
-rw-r--r-- | sql/field.h | 5 | ||||
-rw-r--r-- | sql/handler.h | 11 | ||||
-rw-r--r-- | sql/mysql_priv.h | 5 | ||||
-rw-r--r-- | sql/sql_cache.cc | 12 | ||||
-rw-r--r-- | sql/sql_rename.cc | 16 | ||||
-rw-r--r-- | sql/sql_repl.cc | 5 | ||||
-rw-r--r-- | sql/sql_show.cc | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 84 | ||||
-rw-r--r-- | sql/structs.h | 3 | ||||
-rw-r--r-- | sql/table.h | 2 |
12 files changed, 130 insertions, 28 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc index a7124310279..42c69436897 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -258,7 +258,7 @@ static const size_t ha_option_type_sizeof[]= @retval FALSE OK */ -my_bool parse_option_list(THD* thd, void **option_struct, +my_bool parse_option_list(THD* thd, void *option_struct_arg, engine_option_value *option_list, ha_create_table_option *rules, my_bool suppress_warning, @@ -267,6 +267,7 @@ my_bool parse_option_list(THD* thd, void **option_struct, ha_create_table_option *opt; size_t option_struct_size= 0; engine_option_value *val= option_list; + void **option_struct= (void**)option_struct_arg; DBUG_ENTER("parse_option_list"); DBUG_PRINT("enter", ("struct: 0x%lx list: 0x%lx rules: 0x%lx suppres %u root 0x%lx", diff --git a/sql/create_options.h b/sql/create_options.h index b66bbf43570..174abb1a59a 100644 --- a/sql/create_options.h +++ b/sql/create_options.h @@ -70,7 +70,7 @@ class Create_field; my_bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share); -my_bool parse_option_list(THD* thd, void **option_struct, +my_bool parse_option_list(THD* thd, void *option_struct, engine_option_value *option_list, ha_create_table_option *rules, my_bool suppress_warning, diff --git a/sql/field.h b/sql/field.h index ae294ea6081..3e3dcc10970 100644 --- a/sql/field.h +++ b/sql/field.h @@ -32,6 +32,7 @@ class Send_field; class Protocol; class Create_field; class Relay_log_info; +struct ha_field_option_struct; struct st_cache_field; int field_conv(Field *to,Field *from); @@ -140,7 +141,7 @@ public: const char *field_name; /** reference to the list of options or NULL */ engine_option_value *option_list; - void *option_struct; /* structure with parsed options */ + ha_field_option_struct *option_struct; /* structure with parsed options */ LEX_STRING comment; /* Field is part of the following keys */ key_map key_start, part_of_key, part_of_key_not_clustered; @@ -2164,7 +2165,7 @@ public: Field *field; // For alter table engine_option_value *option_list; /** structure with parsed options (for comparing fields in ALTER TABLE) */ - void *option_struct; + ha_field_option_struct *option_struct; uint8 row,col,sc_length,interval_id; // For rea_create_table uint offset,pack_flag; diff --git a/sql/handler.h b/sql/handler.h index 59d6aaf4b7f..d929181088a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -599,6 +599,11 @@ struct handler_log_file_data { See ha_example.cc for an example. */ + +struct ha_table_option_struct; +struct ha_field_option_struct; +struct ha_index_option_struct; + enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ HA_OPTION_TYPE_STRING, /* char * */ HA_OPTION_TYPE_ENUM, /* uint */ @@ -1167,9 +1172,9 @@ typedef struct st_ha_create_information enum ha_choice page_checksum; ///< If we have page_checksums engine_option_value *option_list; ///< list of table create options /* the following three are only for ALTER TABLE, check_if_incompatible_data() */ - void *option_struct; ///< structure with parsed table options - void **fileds_option_struct; ///< array of field option structures - void **indexes_option_struct; ///< array of index option structures + ha_table_option_struct *option_struct; ///< structure with parsed table options + ha_field_option_struct **fields_option_struct; ///< array of field option structures + ha_index_option_struct **indexes_option_struct; ///< array of index option structures } HA_CREATE_INFO; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index fe0643cdae0..9c4b887091a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1289,6 +1289,11 @@ bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd, TABLE_LIST *table)); bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t); bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t); +bool check_table_file_presence(char *old_path, char *path, + const char *db, + const char *table_name, + const char *alias, + bool issue_error); Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, Field **def_field, diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 81cc87723c5..8c68f4c44bc 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2253,6 +2253,18 @@ void Query_cache::free_cache() { DBUG_ENTER("Query_cache::free_cache"); + /* Destroy locks */ + Query_cache_block *block= queries_blocks; + if (block) + { + do + { + Query_cache_query *query= block->query(); + rwlock_destroy(&query->lock); + block= block->next; + } while (block != queries_blocks); + } + my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR)); make_disabled(); hash_free(&queries); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 3da0fafb830..69dc635be16 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -245,7 +245,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, char *new_table_alias, bool skip_error) { int rc= 1; - char name[FN_REFLEN + 1]; + char new_name[FN_REFLEN + 1], old_name[FN_REFLEN + 1]; const char *new_alias, *old_alias; frm_type_enum frm_type; enum legacy_db_type table_type; @@ -264,17 +264,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, } DBUG_ASSERT(new_alias); - build_table_filename(name, sizeof(name) - 1, + build_table_filename(new_name, sizeof(new_name) - 1, new_db, new_alias, reg_ext, 0); - if (!access(name,F_OK)) + build_table_filename(old_name, sizeof(old_name) - 1, + ren_table->db, old_alias, reg_ext, 0); + if (check_table_file_presence(old_name, + new_name, new_db, new_alias, new_alias, TRUE)) { - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); DBUG_RETURN(1); // This can't be skipped } - build_table_filename(name, sizeof(name) - 1, - ren_table->db, old_alias, reg_ext, 0); - frm_type= mysql_frm_type(thd, name, &table_type); + frm_type= mysql_frm_type(thd, old_name, &table_type); switch (frm_type) { case FRMTYPE_TABLE: @@ -319,7 +319,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, default: DBUG_ASSERT(0); // should never happen case FRMTYPE_ERROR: - my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); + my_error(ER_FILE_NOT_FOUND, MYF(0), old_name, my_errno); break; } if (rc && !skip_error) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index bce687ebcb9..fc472c17e57 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -706,6 +706,11 @@ impossible position"; DBUG_ASSERT(opt_debug_sync_timeout > 0); DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); + const char act2[]= + "now " + "signal signal.continued"; + DBUG_ASSERT(!debug_sync_set_action(current_thd, + STRING_WITH_LEN(act2))); } }); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0886671d8b5..18e5189f3ca 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3792,9 +3792,15 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) it.rewind(); /* To get access to new elements in basis list */ while ((db_name= it++)) { - /* db_name can be changed in make_table_list() func */ - LEX_STRING orig_db_name= *db_name; + LEX_STRING orig_db_name; + /* + db_name can be changed in make_table_list() func. + We need copy of db_name because it can change case. + */ + if (!thd->make_lex_string(&orig_db_name, db_name->str, + db_name->length, FALSE)) + goto err; #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!(check_access(thd,SELECT_ACL, db_name->str, &thd->col_access, 0, 1, with_i_schema) || diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 222991b1ed2..42f2abeca1e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3659,6 +3659,68 @@ static inline int write_create_table_bin_log(THD *thd, } +/** + Check that there is no frm file for given table + + @param old_path path to the old frm file + @param path path to the frm file in new encoding + @param db database name + @param table_name table name + @param alias table name for error message (for new encoding) + @param issue_error should we issue error messages + + @retval FALSE there is no frm file + @retval TRUE there is frm file +*/ + +bool check_table_file_presence(char *old_path, + char *path, + const char *db, + const char *table_name, + const char *alias, + bool issue_error) +{ + if (!access(path,F_OK)) + { + if (issue_error) + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),alias); + return TRUE; + } + { + /* + Check if file of the table in 5.0 file name encoding exists. + + Except case when it is the same table. + */ + char tbl50[FN_REFLEN]; +#ifdef _WIN32 + if (check_if_legal_tablename(table_name) != 0) + { + /* + Check for reserved device names for which access() returns 0 + (CON, AUX etc). + */ + return FALSE; + } +#endif + strxmov(tbl50, mysql_data_home, "/", db, "/", table_name, NullS); + fn_format(tbl50, tbl50, "", reg_ext, MY_UNPACK_FILENAME); + if (!access(tbl50, F_OK) && + (old_path == NULL || + strcmp(old_path, tbl50) != 0)) + { + if (issue_error) + { + strxmov(tbl50, MYSQL50_TABLE_NAME_PREFIX, table_name, NullS); + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tbl50); + } + return TRUE; + } + } + return FALSE; +} + + /* Create a table @@ -3944,11 +4006,12 @@ bool mysql_create_table_no_lock(THD *thd, VOID(pthread_mutex_lock(&LOCK_open)); if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { - if (!access(path,F_OK)) + if (check_table_file_presence(NULL, path, db, table_name, table_name, + !(create_info->options & + HA_LEX_CREATE_IF_NOT_EXISTS))) { if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) goto warn; - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto unlock_and_end; } /* @@ -5856,10 +5919,10 @@ compare_tables(TABLE *table, DBUG_RETURN(0); } - if ((create_info->fileds_option_struct= - (void**)thd->calloc(sizeof(void*) * table->s->fields)) == NULL || - (create_info->indexes_option_struct= - (void**)thd->calloc(sizeof(void*) * table->s->keys)) == NULL) + if ((create_info->fields_option_struct= (ha_field_option_struct**) + thd->calloc(sizeof(void*) * table->s->fields)) == NULL || + (create_info->indexes_option_struct= (ha_index_option_struct**) + thd->calloc(sizeof(void*) * table->s->keys)) == NULL) DBUG_RETURN(1); /* @@ -5880,7 +5943,7 @@ compare_tables(TABLE *table, tmp_new_field= tmp_new_field_it++) { DBUG_ASSERT(i < table->s->fields); - create_info->fileds_option_struct[i]= tmp_new_field->option_struct; + create_info->fields_option_struct[i]= tmp_new_field->option_struct; /* reset common markers of how field changed */ field->flags&= ~(FIELD_IS_RENAMED | FIELD_IN_ADD_INDEX); @@ -6607,6 +6670,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, TABLE *table, *new_table= 0, *name_lock= 0; int error= 0; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1]; + char old_name_buff[FN_REFLEN + 1]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; char path[FN_REFLEN + 1]; @@ -6836,10 +6900,12 @@ view_err: build_table_filename(new_name_buff, sizeof(new_name_buff) - 1, new_db, new_name_buff, reg_ext, 0); - if (!access(new_name_buff, F_OK)) + build_table_filename(old_name_buff, sizeof(old_name_buff) - 1, + db, table_name, reg_ext, 0); + if (check_table_file_presence(old_name_buff, new_name_buff, new_db, + new_name, new_alias, TRUE)) { /* Table will be closed in do_command() */ - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); goto err; } } diff --git a/sql/structs.h b/sql/structs.h index 86d1f12424e..29ccde3fb03 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -70,6 +70,7 @@ typedef struct st_key_part_info { /* Info about a key part */ } KEY_PART_INFO ; class engine_option_value; +struct ha_index_option_struct; typedef struct st_key { uint key_length; /* Tot length of key */ @@ -104,7 +105,7 @@ typedef struct st_key { struct st_table *table; /** reference to the list of options or NULL */ engine_option_value *option_list; - void *option_struct; /* structure with parsed options */ + ha_index_option_struct *option_struct; /* structure with parsed options */ } KEY; diff --git a/sql/table.h b/sql/table.h index d43f5c85849..ca4e50d99e1 100644 --- a/sql/table.h +++ b/sql/table.h @@ -343,7 +343,7 @@ typedef struct st_table_share struct st_table *open_tables; /* link to open tables */ #endif engine_option_value *option_list; /* text options for table */ - void *option_struct; /* structure with parsed options */ + ha_table_option_struct *option_struct; /* structure with parsed options */ /* The following is copied to each TABLE on OPEN */ Field **field; |