Debian Codegraph @

mysql-test/suite/test_service_sql_api/t/test_session_general_log.test

raw
1
2 # X plugin might add rows to general_log
3 source include/xplugin_wait_for_interfaces.inc;
4
5 --echo # Setting general_log to initial state empty
6 TRUNCATE TABLE mysql.general_log;
7
8 SET @old_log_output = @@global.log_output;
9 SET @old_general_log = @@global.general_log;
10 SET @old_general_log_file = @@global.general_log_file;
11
12 --echo ##########################################
13 --echo # Start plugin with general log
14 --echo ##########################################
15 --replace_result $MYSQLTEST_VARDIR ...
16 eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/test_session_general.log';
17 SET GLOBAL log_output = 'FILE,TABLE';
18 SET GLOBAL general_log = 'ON';
19
20 --echo ##########################################
21 --echo # Run plugin
22 --echo ##########################################
23 --replace_result $TEST_SESSION_IN_THD TEST_SESSION_IN_THD
24 eval INSTALL PLUGIN test_session_in_thd SONAME '$TEST_SESSION_IN_THD';
25 # --sleep 5
26 SELECT plugin_name FROM information_schema.plugins WHERE plugin_name LIKE 'test_session_in_thd';
27
28 --echo ##########################################
29 --echo # Stop plugin
30 --echo ##########################################
31 UNINSTALL PLUGIN test_session_in_thd;
32 let $wait_condition=SELECT count(*)=0 FROM information_schema.plugins WHERE plugin_name LIKE 'test_session_in_thd';
33 --source include/wait_condition.inc
34
35
36 --echo ##########################################
37 --echo # Plugin log
38 --echo ##########################################
39 let $MYSQLD_DATADIR= `select @@datadir`;
40 cat_file $MYSQLD_DATADIR/test_session_in_thd.log;
41 remove_file $MYSQLD_DATADIR/test_session_in_thd.log;
42
43 SET GLOBAL general_log = 'OFF';
44
45 --echo ##########################################
46 --echo # Check general log file
47 --echo ##########################################
48 CREATE TABLE t1 (c1 TEXT, c2 TEXT);
49 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
50 --disable_warnings
51 eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/test_session_general.log' INTO TABLE t1;
52 --enable_warnings
53
54 SELECT count(*) FROM t1 WHERE c2 LIKE '%Connect%';
55 SELECT count(*) FROM t1 WHERE c2 LIKE '%Quit%';
56 SELECT count(*) >= 36 FROM mysql.general_log WHERE command_type IN ('Connect','Quit') AND user_host NOT LIKE '%mysql.session%';
57
58 --echo ##########################################
59 --echo # Cleanup
60 --echo ##########################################
61
62 --echo # Dropping the created table
63 DROP TABLE t1;
64
65 --echo # Removing general_log content
66 TRUNCATE TABLE mysql.general_log;
67
68 --echo # Deleting log file created
69 --remove_file $MYSQLTEST_VARDIR/log/test_session_general.log
70
71 SET GLOBAL log_output = @old_log_output;
72 SET GLOBAL general_log = @old_general_log;
73 SET GLOBAL general_log_file = @old_general_log_file;
74