summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2018-10-29 18:45:19 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2018-10-29 18:45:19 +0200
commit2ee9343c873ad31c2dd0d2175dec2ef3b48ca5ba (patch)
treeaa51c10a594658b3668ff850c8fa7ece175a2692 /sql/log_event.cc
parent8b92c642981e7b226e0d93b958cc470bb1e6fad0 (diff)
parent893ebb739e24637985892da1555f2e6f1a8ac5b6 (diff)
downloadmariadb-git-2ee9343c873ad31c2dd0d2175dec2ef3b48ca5ba.tar.gz
Merge tag 'mariadb-5.5.62' into 5.5-galeramariadb-galera-5.5.62
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc46
1 files changed, 36 insertions, 10 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 12489d6d7eb..c65ae4744b9 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -248,6 +248,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.
@@ -3629,7 +3650,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");
@@ -3656,9 +3676,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.
@@ -5449,13 +5467,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));
@@ -5510,6 +5525,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),
@@ -9764,7 +9781,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*)");
@@ -9780,8 +9797,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),