Bug #39470 CREATE VIEW gets written to binlog even on error
Submitted: 16 Sep 2008 7:24 Modified: 16 Sep 2008 8:22
Reporter: Arjen Lentz Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.0.38 OS:Any
Assigned to: CPU Architecture:Any
Tags: binlog, create view, replication

[16 Sep 2008 7:24] Arjen Lentz
Description:
A CREATE VIEW statement is written to the binlog and processed by slave(s) even if the statement failed.

How to repeat:

mysql@master> create view Holland as select * from Country;
Query OK, 0 rows affected (0.00 sec)

mysql@master> show tables;
+-----------------+
| Tables_in_world |
+-----------------+
| City            | 
| Country         | 
| CountryLanguage | 
| Holland         | 
+-----------------+
6 rows in set (0.00 sec)

mysql@master> create view Holland as select * from Country;
ERROR 1050 (42S01): Table 'Holland' already exists

mysql@slave> show slave status\G
[...]
                 Last_Errno: 0
                 Last_Error: Query caused different errors on master and slave. Error on master: 'Table '%-.64s' already exists' (1050), Error on slave: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' (1064). Default database: 'world'. Query: 'CREATE ALGORITHM=UNDEFINED DEFINER=``@`` SQL SECURITY INVOKER VIEW `Holland` AS '
[...]

Suggested fix:
Do not write unsuccessful CREATE VIEW statements to the binlog.
[16 Sep 2008 8:22] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior with version 5.0.67, although bug is repeatable with earlier versions. Please consider to upgrade.