GIF89a; Mini Shell

Mini Shell

Direktori : /usr/share/mysql-test/suite/rpl_ndb/t/
Upload File :
Current File : //usr/share/mysql-test/suite/rpl_ndb/t/rpl_ndb_dist_priv.test

-- source include/have_ndb.inc
-- source include/master-slave.inc
-- source include/have_binlog_format_mixed_or_row.inc
-- source include/have_multi_ndb.inc

--source suite/ndb/t/have_ndb_dist_priv.inc

let $load_sql_file = $NDB_DIST_PRIV_SQL;

connection server1;
--disable_query_log
--disable_result_log
--exec $MYSQL < $load_sql_file
call mysql.mysql_cluster_backup_privileges();
 --enable_result_log
 --enable_query_log

connection server2;
--disable_query_log
--disable_result_log
let $MYSQL2 = $EXE_MYSQL --defaults-file=$MYSQLTEST_VARDIR/my.cnf;
let $MYSQL2 = $MYSQL2 --defaults-group-suffix=.2.1;
--exec $MYSQL2 < $load_sql_file
call mysql.mysql_cluster_backup_privileges();
 --enable_result_log
 --enable_query_log

connection server1;
call mysql.mysql_cluster_move_privileges();
select mysql.mysql_cluster_privileges_are_distributed();

CREATE TABLE t1 (pk INT PRIMARY KEY, a INT) engine = ndb;

# Save the current binlog position to use as start when
# showing CREATE/DROP USER and GRANTs are written as statements
# in binlog
connection server1;
let $binlog_start_server1= query_get_value(SHOW MASTER STATUS, Position, 1);
connection server2;
let $binlog_start_server2= query_get_value(SHOW MASTER STATUS, Position, 1);
connection server1;

CREATE USER 'user'@'localhost' IDENTIFIED by 'mypass';
GRANT UPDATE ON t1 TO 'user'@'localhost';
SET PASSWORD FOR 'user'@'localhost'= PASSWORD('newpass');
RENAME USER 'user'@'localhost' TO 'newuser'@'localhost';
GRANT SELECT ON test.* TO 'newuser'@'localhost' IDENTIFIED by 'mypass2';
CREATE USER 'user2'@'localhost' IDENTIFIED by 'mypass';
GRANT SELECT ON test.t1 TO 'user2'@'localhost';
select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;
grant ALL PRIVILEGES on test.* to user@localhost with GRANT OPTION;
select User,Table_priv from mysql.tables_priv ORDER BY User;
GRANT SELECT ON test.t1 TO 'user'@'localhost';
select User,Table_priv from mysql.tables_priv ORDER BY User;

connection server2;
FLUSH PRIVILEGES;
select User,Table_priv from mysql.tables_priv ORDER BY User;
REVOKE SELECT ON test.t1 FROM 'user'@'localhost';
select User,Table_priv from mysql.tables_priv ORDER BY User;
CREATE USER 'user3'@'localhost' IDENTIFIED by 'mypass';
select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;

connection master;
sync_slave_with_master;

select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;

connection server2;
FLUSH PRIVILEGES;
REVOKE UPDATE ON t1 FROM 'newuser'@'localhost';
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user2'@'localhost';
select User,Table_priv from mysql.tables_priv ORDER BY User;
GRANT SELECT (a) ON test.t1 TO 'user'@'localhost';
select User, Table_name, Column_name from mysql.columns_priv ORDER BY User;

connection server1;
FLUSH PRIVILEGES;
select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;
select User, Table_name, Column_name from mysql.columns_priv ORDER BY User;

connection master;
sync_slave_with_master;

select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;
select User, Table_name, Column_name from mysql.columns_priv ORDER BY User;

connection server2;
DROP USER 'newuser'@'localhost';

# Show that all the above CREATE/DROP USER and GRANT's
# have been written as statements to binlog
# on both server1 and server2
connection server1;
echo == Showing binlog server1 ==;
let $binlog_start= $binlog_start_server1;
--source include/show_binlog_events.inc
connection server2;
echo == Showing binlog server2 ==;
let $binlog_start= $binlog_start_server2;
--source include/show_binlog_events.inc

connection server1;
select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;

connection master;
sync_slave_with_master;

select distinct User,Password from mysql.user order by User;
select User,Table_priv from mysql.tables_priv ORDER BY User;

#
# Testing that failed DDL transaction does not write into binlog
#
connection server1;
BEGIN;
UPDATE mysql.user SET Password = ''
WHERE User = 'user2';

connection server2;
--error ER_PASSWORD_NO_MATCH
SET PASSWORD FOR 'user2'@'localhost' = PASSWORD('newpass');
SHOW WARNINGS;
echo == Showing binlog server2 ==;
let $binlog_start= $binlog_start_server2;
--source include/show_binlog_events.inc


connection server1;
ROLLBACK;


--echo === making backup of new users ===

connection server1;
call mysql.mysql_cluster_backup_privileges();

--echo ==== clean up ====
connection server1;
DROP USER 'user2'@'localhost';
DROP USER 'user3'@'localhost';

DROP TABLE t1;

sync_slave_with_master;

STOP SLAVE;

# Restore local privileges
connection server1;
call mysql.mysql_cluster_backup_privileges();
connection server2;
call mysql.mysql_cluster_backup_privileges();
connection slave;
call mysql.mysql_cluster_backup_privileges();
connection server1;
call mysql.mysql_cluster_restore_local_privileges();
connection server2;
call mysql.mysql_cluster_restore_local_privileges();
connection slave;
call mysql.mysql_cluster_restore_local_privileges();


--disable_query_log
--disable_result_log

connection server1;

# Drop the local backup tables
drop table mysql.user_backup;
drop table mysql.db_backup;
drop table mysql.tables_priv_backup;
drop table mysql.columns_priv_backup;
drop table mysql.procs_priv_backup;
drop table mysql.host_backup;

# Drop the distributed backup tables
drop table mysql.ndb_user_backup;
drop table mysql.ndb_db_backup;
drop table mysql.ndb_tables_priv_backup;
drop table mysql.ndb_columns_priv_backup;
drop table mysql.ndb_procs_priv_backup;
drop table mysql.ndb_host_backup;

# Drop the function and sprocs
drop function mysql.mysql_cluster_privileges_are_distributed;
drop procedure mysql.mysql_cluster_backup_privileges;
drop procedure mysql.mysql_cluster_move_grant_tables;
drop procedure mysql.mysql_cluster_restore_local_privileges;
drop procedure mysql.mysql_cluster_restore_privileges;
drop procedure mysql.mysql_cluster_restore_privileges_from_local;
drop procedure mysql.mysql_cluster_move_privileges;

connection server2;

# Drop the local backup tables
drop table mysql.user_backup;
drop table mysql.db_backup;
drop table mysql.tables_priv_backup;
drop table mysql.columns_priv_backup;
drop table mysql.procs_priv_backup;
drop table mysql.host_backup;

# The distributed backup tables should already have been dropped
--error ER_NO_SUCH_TABLE
select * from mysql.ndb_user_backup;

# Drop the function and sprocs
drop function mysql.mysql_cluster_privileges_are_distributed;
drop procedure mysql.mysql_cluster_backup_privileges;
drop procedure mysql.mysql_cluster_move_grant_tables;
drop procedure mysql.mysql_cluster_restore_local_privileges;
drop procedure mysql.mysql_cluster_restore_privileges;
drop procedure mysql.mysql_cluster_restore_privileges_from_local;
drop procedure mysql.mysql_cluster_move_privileges;

connection slave;

# Drop the local backup tables
drop table mysql.user_backup;
drop table mysql.db_backup;
drop table mysql.tables_priv_backup;
drop table mysql.columns_priv_backup;
drop table mysql.procs_priv_backup;
drop table mysql.host_backup;

# Drop the distributed backup tables(slave is stopped they
# should still be there)
drop table mysql.ndb_user_backup;
drop table mysql.ndb_db_backup;
drop table mysql.ndb_tables_priv_backup;
drop table mysql.ndb_columns_priv_backup;
drop table mysql.ndb_procs_priv_backup;
drop table mysql.ndb_host_backup;

# Drop the function and sprocs
drop function mysql.mysql_cluster_privileges_are_distributed;
drop procedure mysql.mysql_cluster_backup_privileges;
drop procedure mysql.mysql_cluster_move_grant_tables;
drop procedure mysql.mysql_cluster_restore_local_privileges;
drop procedure mysql.mysql_cluster_restore_privileges;
drop procedure mysql.mysql_cluster_restore_privileges_from_local;
drop procedure mysql.mysql_cluster_move_privileges;

# Force restart since other tests depend on the _exact_
# order of rows in for example mysql.user
--source include/force_restart.inc

--enable_query_log
--enable_result_log

./BlackJoker Mini Shell 1.0