diff options
author | Sachin <sachin.setiya@mariadb.com> | 2018-10-14 23:16:53 +0530 |
---|---|---|
committer | Sachin <sachin.setiya@mariadb.com> | 2018-10-17 10:46:20 +0530 |
commit | e31e697f17f79ffa6913499e7e2d29866f24b475 (patch) | |
tree | 552621e98a0227d5993e8827728ba6ddc07aa8bb /sql/log_event.cc | |
parent | 28ad5abade79d4cc3248aee621f99ae293a19211 (diff) | |
download | mariadb-git-e31e697f17f79ffa6913499e7e2d29866f24b475.tar.gz |
MDEV-15919 lower_case_table_names does not behave as expected(nor...
consistently) on Replication Slave
lower_case_table_names 0 -> 1 replication works, it's safe as long as
mixed case names mapping to the lower case ones is one-to-one
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index a33704bdd03..f84cfc94f6f 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -245,6 +245,27 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error, } #endif +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) +static void set_thd_db(THD *thd,const char *db, uint32 db_len) +{ + char lcase_db_buf[NAME_LEN +1]; + LEX_STRING new_db; + new_db.length= db_len; + if (lower_case_table_names == 1) + { + strmov(lcase_db_buf, db); + my_casedn_str(system_charset_info, lcase_db_buf); + new_db.str= lcase_db_buf; + } + else + new_db.str= (char*) db; + /* TODO WARNING this makes rewrite_db respect lower_case_table_names values + * for more info look MDEV-17446 */ + new_db.str= (char*) rpl_filter->get_rewrite_db(new_db.str, + &new_db.length); + thd->set_db(new_db.str, new_db.length); +} +#endif /* Cache that will automatically be written to a dedicated file on destruction. @@ -3619,7 +3640,6 @@ bool test_if_equal_repl_errors(int expected_error, int actual_error) int Query_log_event::do_apply_event(Relay_log_info const *rli, const char *query_arg, uint32 q_len_arg) { - LEX_STRING new_db; int expected_error,actual_error= 0; HA_CREATE_INFO db_options; DBUG_ENTER("Query_log_event::do_apply_event"); @@ -3646,9 +3666,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, goto end; } - new_db.length= db_len; - new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); - thd->set_db(new_db.str, new_db.length); /* allocates a copy of 'db' */ + set_thd_db(thd, db, db_len); /* Setting the character set and collation of the current database thd->db. @@ -5424,13 +5442,10 @@ void Load_log_event::set_fields(const char* affected_db, int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli, bool use_rli_only_for_errors) { - LEX_STRING new_db; DBUG_ENTER("Load_log_event::do_apply_event"); - new_db.length= db_len; - new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); - thd->set_db(new_db.str, new_db.length); DBUG_ASSERT(thd->query() == 0); + set_thd_db(thd, db, db_len); thd->reset_query_inner(); // Should not be needed thd->is_slave_error= 0; clear_all_errors(thd, const_cast<Relay_log_info*>(rli)); @@ -5485,6 +5500,8 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli, thd->warning_info->opt_clear_warning_info(thd->query_id); TABLE_LIST tables; + if (lower_case_table_names) + my_casedn_str(system_charset_info, (char *)table_name); tables.init_one_table(thd->strmake(thd->db, thd->db_length), thd->db_length, table_name, strlen(table_name), @@ -9678,7 +9695,7 @@ check_table_map(Relay_log_info const *rli, RPL_TABLE_LIST *table_list) int Table_map_log_event::do_apply_event(Relay_log_info const *rli) { RPL_TABLE_LIST *table_list; - char *db_mem, *tname_mem; + char *db_mem, *tname_mem, *ptr; size_t dummy_len; void *memory; DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)"); @@ -9694,8 +9711,17 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) NullS))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); - strmov(db_mem, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len)); + strmov(db_mem, m_dbnam); strmov(tname_mem, m_tblnam); + if (lower_case_table_names) + { + my_casedn_str(files_charset_info, (char*)tname_mem); + my_casedn_str(files_charset_info, (char*)db_mem); + } + + /* rewrite rules changed the database */ + if (((ptr= (char*) rpl_filter->get_rewrite_db(db_mem, &dummy_len)) != db_mem)) + strmov(db_mem, ptr); table_list->init_one_table(db_mem, strlen(db_mem), tname_mem, strlen(tname_mem), |