1** Setup **
2
3SET @old_log_output=          @@global.log_output;
4SET @old_general_log=         @@global.general_log;
5SET @old_general_log_file=    @@global.general_log_file;
6SET GLOBAL general_log_file = '.../log/proxy_general.log';
7SET GLOBAL log_output =       'FILE,TABLE';
8SET GLOBAL general_log=       'ON';
9SET @default_mysql_native_password_proxy_users = @@global.mysql_native_password_proxy_users;
10SET @default_check_proxy_users = @@global.check_proxy_users;
11'#----- 2.1.12.1 Test of general log entries. -------------------#'
12SET Global mysql_native_password_proxy_users=OFF;
13** Creating new base user **
14CREATE USER proxy_base@localhost;
15GRANT ALTER ON *.* TO proxy_base@localhost;
16** Creating new proxy user **
17CREATE USER proxy_native@localhost IDENTIFIED WITH mysql_native_password;
18GRANT CREATE ON *.* TO proxy_native@localhost;
19GRANT PROXY ON proxy_base@localhost TO proxy_native@localhost;
20SET Global mysql_native_password_proxy_users=ON;
21** Connecting as proxy_native with proxy mapping disabled (native mapping on) **
22SELECT CURRENT_USER(), USER(), @@session.proxy_user;
23CURRENT_USER()	USER()	@@session.proxy_user
24proxy_native@localhost	proxy_native@localhost	NULL
25SHOW GRANTS;
26Grants for proxy_native@localhost
27GRANT CREATE ON *.* TO 'proxy_native'@'localhost'
28GRANT PROXY ON 'proxy_base'@'localhost' TO 'proxy_native'@'localhost'
29** Connection default **
30** Disconnecting connections **
31SET Global check_proxy_users=ON;
32** Connecting as proxy_native with proxy mapping enabled **
33SELECT CURRENT_USER(), USER(), @@session.proxy_user;
34CURRENT_USER()	USER()	@@session.proxy_user
35proxy_base@localhost	proxy_native@localhost	'proxy_native'@'localhost'
36SHOW GRANTS;
37Grants for proxy_base@localhost
38GRANT ALTER ON *.* TO 'proxy_base'@'localhost'
39** Disconnecting connections **
40SET GLOBAL general_log=       'OFF';
41CREATE TABLE test_log (argument TEXT);
42LOAD DATA LOCAL INFILE '.../log/proxy_general.log'
43     INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
44SELECT count(argument) FROM test_log
45WHERE argument LIKE '%proxy_native@localhost on test%';
46count(argument)
471
48SELECT count(argument) FROM test_log
49WHERE argument LIKE '%proxy_native@localhost as proxy_base on test%';
50count(argument)
511
52DROP TABLE test_log;
53DROP USER proxy_base@localhost;
54DROP USER proxy_native@localhost;
55SET @@global.mysql_native_password_proxy_users = @default_mysql_native_password_proxy_users;
56SET @@global.check_proxy_users = @default_check_proxy_users;
57SET GLOBAL general_log_file=  @old_general_log_file;
58SET GLOBAL general_log=       @old_general_log;
59SET GLOBAL log_output=        @old_log_output;
60