mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
4775601012
The log event of 'CREATE EVENT' was being binlogged with garbage at the end of the query if 'CREATE EVENT' is followed by another SQL statement and they were executed as one command. for example: DELIMITER |; CREATE EVENT e1 ON EVERY DAY DO SELECT 1; SELECT 'a'; DELIMITER ;| When binlogging 'CREATE EVENT', we always create a new statement with definer and write it into the log event. The new statement is made from cpp_buf(preprocessed buffer). which is not a c string(end with '\0'), but it is copied as a c string. In this patch, cpp_buf is copied with its length.
113 lines
3.4 KiB
Text
113 lines
3.4 KiB
Text
##################################################################
|
|
# Author: Giuseppe #
|
|
# Date: 2006-12-20 #
|
|
# Purpose: To test that event effects are replicated #
|
|
# in both row based and statement based format #
|
|
##################################################################
|
|
|
|
--source include/not_embedded.inc
|
|
--source include/master-slave.inc
|
|
|
|
SET @old_event_scheduler = @@global.event_scheduler;
|
|
set global event_scheduler=1;
|
|
|
|
let $engine_type= MyISAM;
|
|
|
|
set binlog_format=row;
|
|
|
|
# Embedded server doesn't support binlogging
|
|
--source include/rpl_events.inc
|
|
|
|
set binlog_format=statement;
|
|
|
|
# Embedded server doesn't support binlogging
|
|
--source include/rpl_events.inc
|
|
|
|
#
|
|
# Bug #28953 Using events in a replication let the slave crash.
|
|
#
|
|
|
|
connection master;
|
|
|
|
CREATE TABLE t28953 (a INT);
|
|
|
|
DELIMITER |;
|
|
CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR
|
|
DO BEGIN
|
|
select * from t28953;
|
|
END;|
|
|
DELIMITER ;|
|
|
|
|
ALTER EVENT event1 RENAME TO event2;
|
|
|
|
sync_slave_with_master;
|
|
|
|
connection master;
|
|
|
|
DROP EVENT event2;
|
|
|
|
#
|
|
# BUG#44331
|
|
# This test verifies if the definer is consistent between master and slave,
|
|
# when the event is created without the DEFINER clause set explicitly or the
|
|
# DEFINER is set to CURRENT_USER
|
|
#
|
|
CREATE TABLE test.t1(details CHAR(30));
|
|
|
|
CREATE EVENT /*!50000 event44331_1 */
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP
|
|
ON COMPLETION PRESERVE DISABLE
|
|
DO INSERT INTO test.t1 VALUES('event event44331_1 fired - no definer');
|
|
|
|
CREATE DEFINER=CURRENT_USER /*!50000 EVENT event44331_2 */
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP
|
|
ON COMPLETION PRESERVE DISABLE
|
|
DO INSERT INTO test.t1 VALUES('event event44331_2 fired - DEFINER=CURRENT_USER');
|
|
|
|
CREATE DEFINER=CURRENT_USER() EVENT event44331_3
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP
|
|
ON COMPLETION PRESERVE DISABLE
|
|
DO INSERT INTO test.t1 VALUES('event event44331_3 fired - DEFINER=CURRENT_USER() function');
|
|
|
|
DELIMITER |;
|
|
CREATE /*!50000 DEFINER='user44331' */ EVENT event44331_4
|
|
ON SCHEDULE AT CURRENT_TIMESTAMP
|
|
ON COMPLETION PRESERVE DISABLE
|
|
DO INSERT INTO test.t1 VALUES('event event44331_4 fired - DEFINER=user1');
|
|
# Test for bug#50095 Multi-statement including CREATE EVENT causes rotten
|
|
# binlog entry
|
|
SELECT 'ABC';
|
|
SELECT '123'|
|
|
DELIMITER ;|
|
|
|
|
--echo #on master
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_1';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_2';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_3';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_4';
|
|
|
|
sync_slave_with_master;
|
|
connection slave;
|
|
--echo #on slave
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_1';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_2';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_3';
|
|
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
|
|
where EVENT_NAME='event44331_4';
|
|
|
|
connection master;
|
|
SET @@global.event_scheduler= @old_event_scheduler;
|
|
DROP TABLE t28953;
|
|
DROP TABLE t1;
|
|
DROP EVENT event44331_1;
|
|
DROP EVENT event44331_2;
|
|
DROP EVENT event44331_3;
|
|
DROP EVENT event44331_4;
|
|
sync_slave_with_master;
|