1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
include/save_binlog_position.inc
# -----------------------------------------------------------------------
# Begin : Tests for RENAME USER
CREATE USER userX, userY, userZ;
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userX
userY
userZ
include/save_binlog_position.inc
# Modify multiple users
RENAME USER userX TO userA, userY TO userB, userZ TO userC;
# Must show userA, userB, userC
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userA
userB
userC
# This event sequence pattern MUST be present in binlog: !Q(RENAME USER.*userX.TO.*userA.*,.*userY.*TO.*userB.*,.*userZ.*TO.*userC.*)
include/assert_binlog_events.inc
include/save_binlog_position.inc
# Try renaming a non-existent user
RENAME USER userA TO userX, user_ne1 TO user_ne2, userC TO userZ;
ERROR HY000: Operation RENAME USER failed for 'user_ne1'@'%'
# Must show userA, userB, userC
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userA
userB
userC
# This event sequence pattern MUST NOT be present in binlog: !Q(RENAME USER.*userA.*TO.*userX.*,.*user_ne1.*TO.*user_ne2.*,.*userC.*TO.*userZ.*)
include/assert_binlog_events.inc
# Insert an entry in mysql.user table but do not execute FLUSH PRIVILEGES
CREATE TABLE mysql.tmp_user LIKE mysql.user;
INSERT INTO mysql.tmp_user SELECT * FROM mysql.user WHERE user LIKE 'userC';
UPDATE mysql.tmp_user SET user='userZ' WHERE user LIKE 'userC';
INSERT INTO mysql.user SELECT * FROM mysql.tmp_user;
DROP TABLE mysql.tmp_user;
include/save_binlog_position.inc
# Though userX is not present in cache, RENAME should check in mysql.user
# table for the presence of an entry which may create problem while
# renaming users.
RENAME USER userA TO userX, userB TO userY, userC TO userZ;
ERROR HY000: Operation RENAME USER failed for 'userC'@'%'
# Must show userA, userB, userC and userZ
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userA
userB
userC
userZ
# This event sequence pattern MUST NOT be present in binlog: !Q(RENAME USER.*userA.*TO.*userX.*,.*userB.*TO.*userY.*,.*userC.*TO.*userZ.*)
include/assert_binlog_events.inc
FLUSH PRIVILEGES;
include/save_binlog_position.inc
# Try renaming two different user and use same user as target
RENAME USER userA TO userX, userB TO userX;
ERROR HY000: Operation RENAME USER failed for 'userB'@'%'
# Must show userA, userB, userC
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userA
userB
userC
userZ
# This event sequence pattern MUST NOT be present in binlog: !Q(RENAME USER.*userA.*TO.*userX.*,.*userB.*TO.*userX.*)
include/assert_binlog_events.inc
# This should succeed
RENAME USER userA TO userX, userB TO userA, userZ TO userB, userC TO userZ;
# Must show userA, userB, userX and userZ
SELECT user, authentication_string FROM mysql.user WHERE user like 'user%';
user authentication_string
userA
userB
userX
userZ
# This event sequence pattern MUST be present in binlog: !Q(RENAME USER.*userA.*TO.*userX.*,.*userB.*TO.*userA.*,.*userZ.*TO.*userB.*,.*userC.*TO.*userZ.*)
include/assert_binlog_events.inc
include/save_binlog_position.inc
DROP USER userA, userB, userX, userZ;
include/save_binlog_position.inc
## Malformed table should be handled gracefully
RENAME TABLE mysql.user TO mysql.user_bak;
CREATE TABLE mysql.user(dummy INT) ENGINE=MyISAM;
Warnings:
Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.user]
FLUSH PRIVILEGES;
Warnings:
Warning 1805 Column count of mysql.user is wrong. Expected 51, found 1. The table is probably corrupted
SHOW WARNINGS;
Level Code Message
Warning 1805 Column count of mysql.user is wrong. Expected 51, found 1. The table is probably corrupted
DROP TABLE mysql.user;
RENAME TABLE mysql.user_bak TO mysql.user;
FLUSH PRIVILEGES;
#
# Bug #32068470: TO_HOST AND TO_USER NOT SET
# Self-renaming isuses
# Regular user
CREATE USER a;
GRANT CREATE USER ON *.* TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
RENAME USER a TO b;
SELECT user(), current_user();
user() current_user()
a@localhost b@%
DROP USER b;
CREATE USER a;
GRANT CREATE USER ON *.* TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
RENAME USER a TO b, b TO c;
SELECT user(), current_user();
user() current_user()
a@localhost c@%
DROP USER c;
CREATE USER a;
GRANT CREATE USER ON *.* TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
RENAME USER a TO b, b TO c, c TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
DROP USER a;
CREATE USER a;
GRANT CREATE USER ON *.* TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
RENAME USER a TO a@1;
SELECT user(), current_user();
user() current_user()
a@localhost a@1
DROP USER a@1;
CREATE USER a;
GRANT CREATE USER ON *.* TO a;
SELECT user(), current_user();
user() current_user()
a@localhost a@%
RENAME USER a TO b@1;
SELECT user(), current_user();
user() current_user()
a@localhost b@1
DROP USER b@1;
# Proxy user
CREATE USER a IDENTIFIED with 'mysql_native_password', b;
GRANT CREATE USER ON *.* TO b;
GRANT PROXY ON b TO a;
SET @@global.check_proxy_users = ON;
SET @@global.mysql_native_password_proxy_users = ON;
SELECT user(), current_user(), @@proxy_user;
user() current_user() @@proxy_user
a@localhost b@% 'a'@'%'
RENAME USER a TO c;
SELECT user(), current_user(), @@proxy_user;
user() current_user() @@proxy_user
a@localhost b@% 'c'@'%'
DROP USER b, c;
SET @@global.check_proxy_users = OFF;
SET @@global.mysql_native_password_proxy_users = OFF;
# Anonymous user
CREATE USER ''@'localhost';
GRANT CREATE USER ON *.* TO ''@'localhost';
SELECT user(), current_user();
user() current_user()
CONNECTED_USER @localhost
RENAME USER ''@'localhost' TO a;
SELECT user(), current_user();
user() current_user()
CONNECTED_USER a@%
DROP USER a;
# End : Tests for RENAME USER
# -----------------------------------------------------------------------
|