From d1f351bcb6e684f53d1b8d8035a36a362d556db8 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Sat, 19 Jan 2013 06:01:46 +0530 Subject: [PATCH] Bug#11752707-SLAVE CRASHES IF RBR HAS AS DESTINATION A VIEW RATHER THAN A TABLE Problem: In RBR, If a table is converted into a view at slave, (i.e., "drop table 'object1'" & "create view 'object1'"), then any DML operations on the table at master are causing crash at slave. Analysis: Slave prepares tables to be opened for DML list when it receives Table_map_log_event(s). And the same list will be sent to open_table function. Open_table logic assumes that if the list contains a view object, it also contains "select_lex" object of that view. In the above special case, the table object does not contain 'select_lex' as it is base table at master. Since it is a view at slave, open_table logic goes to 'mysql_make_view()' function which assumes that 'select_lex' exists for the object. Fix: While preparing 'tables to be opened' list, we should make sure that table required type is 'base table'. If it is not base table while opening the object, mysql_make_view will throw an error similar to 'object is not a base table' --- sql/log_event.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/log_event.cc b/sql/log_event.cc index 63770e340b0..542b5e2dc60 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8573,6 +8573,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) table_list->next_global= table_list->next_local= 0; table_list->table_id= DBUG_EVALUATE_IF("inject_tblmap_same_id_maps_diff_table", 0, m_table_id); table_list->updating= 1; + table_list->required_type= FRMTYPE_TABLE; strmov(table_list->db, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len)); strmov(table_list->table_name, m_tblnam); DBUG_PRINT("debug", ("table: %s is mapped to %u", table_list->table_name, table_list->table_id));