mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 19:41:47 +01:00
f392eddabc
Original revision: ------------------------------------------------------------ revision-id: li-bing.song@sun.com-20100130124925-o6sfex42b6noyc6x parent: joro@sun.com-20100129145427-0n79l9hnk0q43ajk committer: <Li-Bing.Song@sun.com> branch nick: mysql-5.1-bugteam timestamp: Sat 2010-01-30 20:49:25 +0800 message: Bug #48321 CURRENT_USER() incorrectly replicated for DROP/RENAME USER; REVOKE/GRANT; ALTER EVENT. The following statements support the CURRENT_USER() where a user is needed. DROP USER RENAME USER CURRENT_USER() ... GRANT ... TO CURRENT_USER() REVOKE ... FROM CURRENT_USER() ALTER DEFINER = CURRENT_USER() EVENT but, When these statements are binlogged, CURRENT_USER() just is binlogged as 'CURRENT_USER()', it is not expanded to the real user name. When slave executes the log event, 'CURRENT_USER()' is expand to the user of slave SQL thread, but SQL thread's user name always NULL. This breaks the replication. After this patch, All above statements are rewritten when they are binlogged. The CURRENT_USER() is expanded to the real user's name and host. ------------------------------------------------------------
107 lines
3.3 KiB
Text
107 lines
3.3 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');
|
|
|
|
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');
|
|
|
|
--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;
|