mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
788c28aceb
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.
127 lines
3.1 KiB
Text
127 lines
3.1 KiB
Text
--let $count=1
|
|
connection master;
|
|
|
|
if (`SELECT '$diff_table' = ''`)
|
|
{
|
|
let $diff_table= mysql.user;
|
|
}
|
|
|
|
--echo
|
|
--echo
|
|
--echo
|
|
--echo TEST STATEMENT: '$statement'
|
|
--echo --------------------------------------------------------------------------
|
|
|
|
if (`SELECT '$diff_columns' = ''`)
|
|
{
|
|
eval CREATE VIEW test.bug48321_v1 AS SELECT user FROM $diff_table
|
|
WHERE user LIKE 'bug48321%';
|
|
}
|
|
|
|
if (`SELECT '$diff_columns' <> ''`)
|
|
{
|
|
eval CREATE VIEW test.bug48321_v1 AS SELECT user, $diff_columns
|
|
FROM $diff_table WHERE user LIKE 'bug48321%';
|
|
}
|
|
|
|
while (`SELECT $count < 6`)
|
|
{
|
|
--echo
|
|
--echo TEST STATEMENT: '$statement'
|
|
--echo CASE $count:
|
|
--echo -------
|
|
|
|
let $user2= 'bug48321_2'@'localhost';
|
|
let $user3= 'bug48321_3'@'localhost';
|
|
|
|
let $user1= CURRENT_USER();
|
|
if (`SELECT '$action'='RENAME'`)
|
|
{
|
|
let $user1= $user1 TO 'bug48321_4'@'localhost';
|
|
let $user2= $user2 TO 'bug48321_5'@'localhost';
|
|
let $user3= $user3 TO 'bug48321_6'@'localhost';
|
|
}
|
|
|
|
if (`SELECT '$action'='GRANT'`)
|
|
{
|
|
let $user1= $user1 IDENTIFIED BY 'user1';
|
|
let $user3= $user3 IDENTIFIED BY '';
|
|
}
|
|
|
|
if (`SELECT $count=1`)
|
|
{
|
|
--echo # Only CURRENT_USER() in the user list of the test statement.
|
|
let $users_list= $user1;
|
|
}
|
|
|
|
if (`SELECT $count=2`)
|
|
{
|
|
--echo # Two users are in the test statement, CURRENT_USER is the first one.
|
|
let $users_list= $user1, $user2;
|
|
}
|
|
|
|
if (`SELECT $count=3`)
|
|
{
|
|
--echo # Two users are in the test statement, CURRENT_USER is the last one.
|
|
let $users_list= $user2, $user1;
|
|
}
|
|
|
|
if (`SELECT $count=4`)
|
|
{
|
|
--echo # Three users are in the test statement, CURRENT_USER is the second one.
|
|
let $users_list= $user2, $user1, $user3;
|
|
}
|
|
|
|
if (`SELECT $count=5`)
|
|
{
|
|
--echo # CURRENT_USER is not in the test statement.
|
|
let $users_list= $user2, $user3;
|
|
}
|
|
|
|
--echo users_list= $users_list
|
|
--echo
|
|
--echo # Connect to master with user1, so user1 always is the current user,
|
|
--echo # when test statement is runing.
|
|
eval GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1'@'localhost'
|
|
WITH GRANT OPTION;
|
|
eval CREATE USER 'bug48321_2'@'localhost', 'bug48321_3'@'localhost'
|
|
IDENTIFIED BY 'user3';
|
|
|
|
if (`SELECT '$action'='REVOKE'`)
|
|
{
|
|
--echo
|
|
--echo # Grant some privileges to users at first when testing
|
|
--echo # 'REVOKE ...' statement.
|
|
eval GRANT ALL PRIVILEGES ON *.* TO 'bug48321_2'@'localhost',
|
|
'bug48321_3'@'localhost' WITH GRANT OPTION;
|
|
eval GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO 'bug48321_1'@'localhost',
|
|
'bug48321_2'@'localhost', 'bug48321_3'@'localhost';
|
|
}
|
|
|
|
connect (conn1, 127.0.0.1, 'bug48321_1'@'localhost',,);
|
|
connection conn1;
|
|
--echo
|
|
let $temp= `SELECT "$statement"`;
|
|
eval $temp;
|
|
--echo
|
|
|
|
disconnect conn1;
|
|
|
|
connection master;
|
|
sync_slave_with_master;
|
|
|
|
connection master;
|
|
let $diff_table_1= master:test.bug48321_v1;
|
|
let $diff_table_2= slave:test.bug48321_v1;
|
|
source include/diff_tables.inc;
|
|
--echo
|
|
|
|
--echo # Delete all bug48321% users
|
|
connection master;
|
|
DELETE FROM mysql.user WHERE user LIKE 'bug48321%';
|
|
DELETE FROM mysql.procs_priv WHERE user LIKE 'bug48321%';
|
|
FLUSH PRIVILEGES;
|
|
|
|
inc $count;
|
|
}
|
|
DROP VIEW test.bug48321_v1;
|