mariadb/mysql-test/suite/rpl/r/rpl_binlog_grant.result
unknown d9e9a73e8f 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.
2010-01-30 20:49:25 +08:00

54 lines
1.8 KiB
Text

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 d1;
create database d1;
use d1;
create table t (s1 int) engine=innodb;
set @@autocommit=0;
start transaction;
insert into t values (1);
grant select on t to x@y;
rollback;
show grants for x@y;
Grants for x@y
GRANT USAGE ON *.* TO 'x'@'y'
GRANT SELECT ON `d1`.`t` TO 'x'@'y'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # drop database if exists d1
master-bin.000001 # Query # # create database d1
master-bin.000001 # Query # # use `d1`; create table t (s1 int) engine=innodb
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `d1`; insert into t values (1)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `d1`; grant select on t to 'x'@'y'
start transaction;
insert into t values (2);
revoke select on t from x@y;
commit;
select * from t;
s1
1
2
show grants for x@y;
Grants for x@y
GRANT USAGE ON *.* TO 'x'@'y'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # drop database if exists d1
master-bin.000001 # Query # # create database d1
master-bin.000001 # Query # # use `d1`; create table t (s1 int) engine=innodb
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `d1`; insert into t values (1)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `d1`; grant select on t to 'x'@'y'
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `d1`; insert into t values (2)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `d1`; revoke select on t from 'x'@'y'
drop user x@y;
drop database d1;