Current Path : /home/usr.opt/mysql57/mysql-test/suite/ndb_rpl/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/ndb_rpl/t/ndb_rpl_dist_priv.test |
# The include statement below is a temp one for tests that are yet to #be ported to run with InnoDB, #but needs to be kept for tests that would need MyISAM in future. --source include/force_myisam_default.inc -- 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'= '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,Authentication_string from mysql.user order by User; select User,Table_priv from mysql.tables_priv ORDER BY User; CREATE USER 'user'@'localhost'; 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,Authentication_string 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,Authentication_string 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,Authentication_string 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,Authentication_string 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,Authentication_string 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,Authentication_string 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 Authentication_string = '' WHERE User = 'user2'; connection server2; # The SET PASSWORD query should fail when it tries to update the same row # as the first connection. --error ER_LOCK_WAIT_TIMEOUT SET PASSWORD FOR 'user2'@'localhost' = '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 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 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; # 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 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 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