Debian Codegraph @

mysql-test/suite/rpl/r/rpl_current_user.result

raw
1 include/rpl_init.inc [topology=1->2->3]
2 include/rpl_connect.inc [creating master]
3 include/rpl_connect.inc [creating slave]
4 connection master;
5 CREATE TABLE t1(c1 char(100));
6 CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%';
7 CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%';
8 CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%';
9 CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1';
10 CREATE PROCEDURE p1() SELECT 1;
11 # bug48321_1-01234 has the max length(16) of user.
12 CREATE USER 'bug48321_1-01234'@'localhost';
13 GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION;
14
15 # Test the max lengths of user and host names
16 # the user name is too long
17 GRANT CREATE USER ON *.* TO '012345678901234567890123456789012345678901234567890123456789012345678901234567890'@'fakehost';
18 ERROR HY000: String '0123456789012345678901234567890123456789012345678901234567890123456...' is too long for user name (should be no longer than 80)
19 # the host name is too long
20 GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890';
21 ERROR HY000: String '0123456789012345678901234567890123456789012345678901234567890' is too long for host name (should be no longer than 60)
22
23 # User 'bug48321_1-01234' connects to master by conn1
24 connect conn1, 127.0.0.1, 'bug48321_1-01234'@'localhost',,;
25 connection conn1;
26 # Verify 'REVOKE ALL' statement
27 REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER();
28 include/rpl_sync.inc
29 include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
30
31 # Verify 'GRANT ... ON TABLE ...' statement
32 GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER();
33 include/rpl_sync.inc
34 include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
35
36 # Verify 'GRANT ... ON PROCEDURE...' statement
37 GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER();
38 include/rpl_sync.inc
39 include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
40
41 # Verify 'GRANT ... ON *.* ...' statement
42 GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION;
43 include/rpl_sync.inc
44 include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
45
46 # Verify 'REVOKE ... ON TABLE ...' statement
47 REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER();
48 include/rpl_sync.inc
49 include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
50
51 # Verify 'REVOKE ... ON PROCEDURE...' statement
52 REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER();
53 include/rpl_sync.inc
54 include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
55
56 # Verify 'REVOKE ... ON *.* ...' statement
57 REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER();
58 include/rpl_sync.inc
59 include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
60
61 # Verify 'GRANT ...' statement in the procedure
62 CREATE PROCEDURE my_grant()
63 GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER();
64 call my_grant;
65 include/rpl_sync.inc
66 include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
67
68 # Verify 'REVOKE ... ON TABLE ...' statement in the procedure
69 CREATE PROCEDURE my_revoke()
70 REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER();
71 call my_revoke;
72 include/rpl_sync.inc
73 include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
74
75 # Verify 'RENAME USER ...' statement
76 RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost';
77 include/rpl_sync.inc
78 include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
79 disconnect conn1;
80
81 # Verify 'DROP USER ...' statement
82 connection master;
83 GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost';
84 connect conn1, 127.0.0.1, 'bug48321_2'@'localhost',,;
85 connection conn1;
86 DROP USER CURRENT_USER();
87 include/rpl_sync.inc
88 include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
89
90 # Verify 'ALTER EVENT...' statement
91 connection master;
92 CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1;
93 Warnings:
94 Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
95 # Explicitly assign CURRENT_USER() to definer
96 ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE;
97 include/rpl_sync.inc
98 include/diff_tables.inc [server_1:v_event, server_2:v_event, server_3:v_event]
99
100 # Session user will be set as definer, if the statement does not assign
101 # a definer
102 ALTER EVENT e1 ENABLE;
103 include/rpl_sync.inc
104 include/diff_tables.inc [server_1:v_event, server_2:v_event, server_3:v_event]
105
106 # Verify that this patch does not affect the calling of CURRENT_USER()
107 # in the other statements
108 connection master;
109 INSERT INTO t1 VALUES(CURRENT_USER()), ('1234');
110 Warnings:
111 Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave
112 SELECT * FROM t1;
113 c1
114 root@localhost
115 1234
116 connection slave;
117 SELECT * FROM t1;
118 c1
119 @
120 1234
121 connection server_3;
122 SELECT * FROM t1;
123 c1
124 @
125 1234
126 connection master;
127 UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234';
128 Warnings:
129 Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave
130 SELECT * FROM t1;
131 c1
132 root@localhost
133 root@localhost
134 connection slave;
135 SELECT * FROM t1;
136 c1
137 @
138 @
139 connection server_3;
140 SELECT * FROM t1;
141 c1
142 @
143 @
144 connection master;
145 DELETE FROM t1 WHERE c1=CURRENT_USER();
146 Warnings:
147 Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave
148 SELECT * FROM t1;
149 c1
150 connection slave;
151 SELECT * FROM t1;
152 c1
153 connection server_3;
154 SELECT * FROM t1;
155 c1
156 connection master;
157 CREATE TABLE t2(c1 char(100));
158 CREATE FUNCTION my_user() RETURNS VARCHAR(64)
159 SQL SECURITY INVOKER
160 BEGIN
161 INSERT INTO t2 VALUES(CURRENT_USER());
162 RETURN CURRENT_USER();
163 END |
164 INSERT INTO t1 VALUES(my_user());
165 Warnings:
166 Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave
167 SELECT * FROM t1;
168 c1
169 root@localhost
170 SELECT * FROM t2;
171 c1
172 root@localhost
173 connection slave;
174 SELECT * FROM t1;
175 c1
176 @
177 SELECT * FROM t2;
178 c1
179 @
180 connection server_3;
181 SELECT * FROM t1;
182 c1
183 @
184 SELECT * FROM t2;
185 c1
186 @
187
188 # END
189 connection master;
190 DROP TABLE t1, t2;
191 DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event;
192 DROP PROCEDURE p1;
193 DROP PROCEDURE my_grant;
194 DROP PROCEDURE my_revoke;
195 DROP FUNCTION my_user;
196 DROP EVENT e1;
197 include/rpl_end.inc