diff --git a/mysql-test/suite/rpl/r/failed_create_view-6409.result b/mysql-test/suite/rpl/r/failed_create_view-6409.result new file mode 100644 index 00000000000..6b04f2960d1 --- /dev/null +++ b/mysql-test/suite/rpl/r/failed_create_view-6409.result @@ -0,0 +1,15 @@ +create table v1 (a int); +include/master-slave.inc +[connection master] +create table t1 (a int); +create view v1 as select * from t1; +ERROR 42S01: Table 'v1' already exists +show tables; +Tables_in_test +t1 +v1 +show tables; +Tables_in_test +t1 +drop table if exists t1, v1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/failed_create_view-6409.test b/mysql-test/suite/rpl/t/failed_create_view-6409.test new file mode 100644 index 00000000000..5d96e6f8a93 --- /dev/null +++ b/mysql-test/suite/rpl/t/failed_create_view-6409.test @@ -0,0 +1,24 @@ +# +# MDEV-6409 CREATE VIEW replication problem if error occurs in mysql_register_view +# + +# +# +# verify that failed CREATE VIEW is not replicated + +create table v1 (a int); + +source include/master-slave.inc; + +connection master; +create table t1 (a int); +--error ER_TABLE_EXISTS_ERROR +create view v1 as select * from t1; +show tables; +sync_slave_with_master; +show tables; + +connection master; +drop table if exists t1, v1; + +--source include/rpl_end.inc diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 7be370b8e63..25bada09fba 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -39,8 +39,7 @@ const LEX_STRING view_type= { C_STRING_WITH_LEN("VIEW") }; -static int mysql_register_view(THD *thd, TABLE_LIST *view, - enum_view_create_mode mode); +static int mysql_register_view(THD *, TABLE_LIST *, enum_view_create_mode); /* Make a unique name for an anonymous view column @@ -670,7 +669,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, res= mysql_register_view(thd, view, mode); - if (mysql_bin_log.is_open()) + if (!res && mysql_bin_log.is_open()) { String buff; const LEX_STRING command[3]=