mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
BUG#45574 CREATE IF NOT EXISTS is not binlogged if the object exists
There is an inconsistency with DROP DATABASE|TABLE|EVENT IF EXISTS and CREATE DATABASE|TABLE|EVENT IF NOT EXISTS. DROP IF EXISTS statements are binlogged even if either the DB, TABLE or EVENT does not exist. In contrast, Only the CREATE EVENT IF NOT EXISTS is binlogged when the EVENT exists. This patch fixes the following cases for all the replication formats: CREATE DATABASE IF NOT EXISTS. CREATE TABLE IF NOT EXISTS, CREATE TABLE IF NOT EXISTS ... LIKE, CREAET TABLE IF NOT EXISTS ... SELECT. sql/sql_insert.cc: Part of the code was moved from the create_table_from_items to select_create::prepare. When replication is row based, CREATE TABLE IF NOT EXISTS.. SELECT is binlogged if the table exists.
This commit is contained in:
33
mysql-test/suite/rpl/r/rpl_create_if_not_exists.result
Normal file
33
mysql-test/suite/rpl/r/rpl_create_if_not_exists.result
Normal file
@ -0,0 +1,33 @@
|
||||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
||||
CREATE DATABASE IF NOT EXISTS mysqltest;
|
||||
USE mysqltest;
|
||||
CREATE TABLE IF NOT EXISTS t(c1 int);
|
||||
CREATE TABLE IF NOT EXISTS t1 LIKE t;
|
||||
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
|
||||
CREATE EVENT IF NOT EXISTS e
|
||||
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
|
||||
DO SELECT now();
|
||||
DROP DATABASE mysqltest;
|
||||
CREATE DATABASE IF NOT EXISTS mysqltest;
|
||||
USE mysqltest;
|
||||
CREATE TABLE IF NOT EXISTS t(c1 int);
|
||||
CREATE TABLE IF NOT EXISTS t1 LIKE t;
|
||||
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
|
||||
CREATE EVENT IF NOT EXISTS e
|
||||
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
|
||||
DO SELECT now();
|
||||
SHOW TABLES in mysqltest;
|
||||
Tables_in_mysqltest
|
||||
t
|
||||
t1
|
||||
t2
|
||||
SHOW EVENTS in mysqltest;
|
||||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||||
mysqltest e @ SYSTEM ONE TIME # NULL NULL NULL NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
DROP DATABASE IF EXISTS mysqltest;
|
Reference in New Issue
Block a user