1SET @old_general_log_state = @@global.general_log;
2SET @old_log_output=       @@global.log_output;
3SET @old_slow_query_log=   @@global.slow_query_log;
4SET @old_general_log=      @@global.general_log;
5SET @old_long_query_time=  @@session.long_query_time;
6use mysql;
7SET @saved_long_query_time = @@long_query_time;
8SET @saved_log_output = @@log_output;
9SET @saved_general_log = @@GLOBAL.general_log;
10SET @saved_slow_query_log = @@GLOBAL.slow_query_log;
11SELECT @saved_long_query_time, @saved_log_output, @saved_general_log, @saved_slow_query_log;
12@saved_long_query_time	@saved_log_output	@saved_general_log	@saved_slow_query_log
1310	FILE,TABLE	1	1
14truncate table general_log;
15select * from general_log;
16event_time	user_host	thread_id	server_id	command_type	argument
17TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
18truncate table slow_log;
19select * from slow_log;
20start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
21truncate table general_log;
22select * from general_log where argument like '%general_log%';
23event_time	user_host	thread_id	server_id	command_type	argument
24TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log where argument like '%general_log%'
25create table join_test (verbose_comment varchar (80), command_type varchar(64));
26insert into join_test values ("User performed a usual SQL query", "Query");
27insert into join_test values ("New DB connection was registered", "Connect");
28insert into join_test values ("Get the table info", "Field List");
29select verbose_comment, user_host, argument
30from  mysql.general_log join join_test
31on (mysql.general_log.command_type = join_test.command_type);
32verbose_comment	user_host	argument
33User performed a usual SQL query	USER_HOST	select * from general_log where argument like '%general_log%'
34User performed a usual SQL query	USER_HOST	create table join_test (verbose_comment varchar (80), command_type varchar(64))
35User performed a usual SQL query	USER_HOST	insert into join_test values ("User performed a usual SQL query", "Query")
36User performed a usual SQL query	USER_HOST	insert into join_test values ("New DB connection was registered", "Connect")
37User performed a usual SQL query	USER_HOST	insert into join_test values ("Get the table info", "Field List")
38User performed a usual SQL query	USER_HOST	select verbose_comment, user_host, argument
39from  mysql.general_log join join_test
40on (mysql.general_log.command_type = join_test.command_type)
41drop table join_test;
42flush logs;
43lock tables mysql.general_log WRITE;
44ERROR HY000: You can't use locks with log tables.
45lock tables mysql.slow_log WRITE;
46ERROR HY000: You can't use locks with log tables.
47lock tables mysql.general_log READ;
48ERROR HY000: You can't use locks with log tables.
49lock tables mysql.slow_log READ;
50ERROR HY000: You can't use locks with log tables.
51lock tables mysql.slow_log READ LOCAL, mysql.general_log READ LOCAL;
52ERROR HY000: You can't use locks with log tables.
53show create table mysql.general_log;
54Table	Create Table
55general_log	CREATE TABLE `general_log` (
56  `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
57  `user_host` mediumtext NOT NULL,
58  `thread_id` bigint(21) unsigned NOT NULL,
59  `server_id` int(10) unsigned NOT NULL,
60  `command_type` varchar(64) NOT NULL,
61  `argument` mediumblob NOT NULL
62) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
63show fields from mysql.general_log;
64Field	Type	Null	Key	Default	Extra
65event_time	timestamp(6)	NO		CURRENT_TIMESTAMP(6)	on update CURRENT_TIMESTAMP(6)
66user_host	mediumtext	NO		NULL
67thread_id	bigint(21) unsigned	NO		NULL
68server_id	int(10) unsigned	NO		NULL
69command_type	varchar(64)	NO		NULL
70argument	mediumblob	NO		NULL
71show create table mysql.slow_log;
72Table	Create Table
73slow_log	CREATE TABLE `slow_log` (
74  `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
75  `user_host` mediumtext NOT NULL,
76  `query_time` time(6) NOT NULL,
77  `lock_time` time(6) NOT NULL,
78  `rows_sent` int(11) NOT NULL,
79  `rows_examined` int(11) NOT NULL,
80  `db` varchar(512) NOT NULL,
81  `last_insert_id` int(11) NOT NULL,
82  `insert_id` int(11) NOT NULL,
83  `server_id` int(10) unsigned NOT NULL,
84  `sql_text` mediumblob NOT NULL,
85  `thread_id` bigint(21) unsigned NOT NULL
86) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
87show fields from mysql.slow_log;
88Field	Type	Null	Key	Default	Extra
89start_time	timestamp(6)	NO		CURRENT_TIMESTAMP(6)	on update CURRENT_TIMESTAMP(6)
90user_host	mediumtext	NO		NULL
91query_time	time(6)	NO		NULL
92lock_time	time(6)	NO		NULL
93rows_sent	int(11)	NO		NULL
94rows_examined	int(11)	NO		NULL
95db	varchar(512)	NO		NULL
96last_insert_id	int(11)	NO		NULL
97insert_id	int(11)	NO		NULL
98server_id	int(10) unsigned	NO		NULL
99sql_text	mediumblob	NO		NULL
100thread_id	bigint(21) unsigned	NO		NULL
101flush logs;
102flush tables;
103SET GLOBAL GENERAL_LOG=ON;
104SET GLOBAL SLOW_QUERY_LOG=ON;
105show open tables;
106Database	Table	In_use	Name_locked
107mysql	general_log	0	0
108flush logs;
109show open tables;
110Database	Table	In_use	Name_locked
111mysql	general_log	0	0
112flush tables;
113show open tables;
114Database	Table	In_use	Name_locked
115mysql	general_log	0	0
116SET GLOBAL GENERAL_LOG=OFF;
117SET GLOBAL SLOW_QUERY_LOG=OFF;
118flush tables;
119show open tables;
120Database	Table	In_use	Name_locked
121SET GLOBAL GENERAL_LOG=ON;
122SET GLOBAL SLOW_QUERY_LOG=ON;
123truncate table mysql.general_log;
124set names binary;
125select _koi8r'����' as test;
126test
127����
128select * from mysql.general_log;
129event_time	user_host	thread_id	server_id	command_type	argument
130TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names binary
131TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select _koi8r'����' as test
132TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
133set names utf8;
134truncate table mysql.general_log;
135set names utf8;
136create table bug16905 (s char(15) character set utf8 default 'пусто');
137insert into bug16905 values ('новое');
138select * from mysql.general_log;
139event_time	user_host	thread_id	server_id	command_type	argument
140TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names utf8
141TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table bug16905 (s char(15) character set utf8 default 'пусто')
142TIMESTAMP	USER_HOST	THREAD_ID	1	Query	insert into bug16905 values ('новое')
143TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
144drop table bug16905;
145truncate table mysql.slow_log;
146set session long_query_time=1;
147select sleep(2);
148sleep(2)
1490
150select * from mysql.slow_log where sql_text="select sleep(2)";
151start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
152TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00.000000	1	0	mysql	0	0	1	QUERY	THREAD_ID
153set @@session.long_query_time = @saved_long_query_time;
154alter table mysql.general_log engine=myisam;
155ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
156alter table mysql.slow_log engine=myisam;
157ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
158drop table mysql.general_log;
159ERROR HY000: You cannot 'DROP' a log table if logging is enabled
160drop table mysql.slow_log;
161ERROR HY000: You cannot 'DROP' a log table if logging is enabled
162set global general_log='OFF';
163alter table mysql.slow_log engine=myisam;
164ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
165set global slow_query_log='OFF';
166show create table mysql.general_log;
167Table	Create Table
168general_log	CREATE TABLE `general_log` (
169  `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
170  `user_host` mediumtext NOT NULL,
171  `thread_id` bigint(21) unsigned NOT NULL,
172  `server_id` int(10) unsigned NOT NULL,
173  `command_type` varchar(64) NOT NULL,
174  `argument` mediumblob NOT NULL
175) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
176show create table mysql.slow_log;
177Table	Create Table
178slow_log	CREATE TABLE `slow_log` (
179  `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
180  `user_host` mediumtext NOT NULL,
181  `query_time` time(6) NOT NULL,
182  `lock_time` time(6) NOT NULL,
183  `rows_sent` int(11) NOT NULL,
184  `rows_examined` int(11) NOT NULL,
185  `db` varchar(512) NOT NULL,
186  `last_insert_id` int(11) NOT NULL,
187  `insert_id` int(11) NOT NULL,
188  `server_id` int(10) unsigned NOT NULL,
189  `sql_text` mediumblob NOT NULL,
190  `thread_id` bigint(21) unsigned NOT NULL
191) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
192alter table mysql.general_log engine=myisam;
193alter table mysql.slow_log engine=myisam;
194show create table mysql.general_log;
195Table	Create Table
196general_log	CREATE TABLE `general_log` (
197  `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
198  `user_host` mediumtext NOT NULL,
199  `thread_id` bigint(21) unsigned NOT NULL,
200  `server_id` int(10) unsigned NOT NULL,
201  `command_type` varchar(64) NOT NULL,
202  `argument` mediumblob NOT NULL
203) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='General log'
204show create table mysql.slow_log;
205Table	Create Table
206slow_log	CREATE TABLE `slow_log` (
207  `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
208  `user_host` mediumtext NOT NULL,
209  `query_time` time(6) NOT NULL,
210  `lock_time` time(6) NOT NULL,
211  `rows_sent` int(11) NOT NULL,
212  `rows_examined` int(11) NOT NULL,
213  `db` varchar(512) NOT NULL,
214  `last_insert_id` int(11) NOT NULL,
215  `insert_id` int(11) NOT NULL,
216  `server_id` int(10) unsigned NOT NULL,
217  `sql_text` mediumblob NOT NULL,
218  `thread_id` bigint(21) unsigned NOT NULL
219) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Slow log'
220set global general_log='ON';
221set global slow_query_log='ON';
222select * from mysql.general_log;
223event_time	user_host	thread_id	server_id	command_type	argument
224TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set names utf8
225TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table bug16905 (s char(15) character set utf8 default 'пусто')
226TIMESTAMP	USER_HOST	THREAD_ID	1	Query	insert into bug16905 values ('новое')
227TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
228TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table bug16905
229TIMESTAMP	USER_HOST	THREAD_ID	1	Query	truncate table mysql.slow_log
230TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set session long_query_time=1
231TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select sleep(2)
232TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.slow_log where sql_text="select sleep(2)"
233TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set @@session.long_query_time = @saved_long_query_time
234TIMESTAMP	USER_HOST	THREAD_ID	1	Query	alter table mysql.general_log engine=myisam
235TIMESTAMP	USER_HOST	THREAD_ID	1	Query	alter table mysql.slow_log engine=myisam
236TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table mysql.general_log
237TIMESTAMP	USER_HOST	THREAD_ID	1	Query	drop table mysql.slow_log
238TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set global general_log='OFF'
239TIMESTAMP	USER_HOST	THREAD_ID	1	Query	set global slow_query_log='ON'
240TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from mysql.general_log
241flush logs;
242lock tables mysql.general_log WRITE;
243ERROR HY000: You can't use locks with log tables.
244lock tables mysql.slow_log WRITE;
245ERROR HY000: You can't use locks with log tables.
246lock tables mysql.general_log READ;
247ERROR HY000: You can't use locks with log tables.
248lock tables mysql.slow_log READ;
249ERROR HY000: You can't use locks with log tables.
250set global general_log='OFF';
251set global slow_query_log='OFF';
252set @save_storage_engine= @@session.default_storage_engine;
253set default_storage_engine= MEMORY;
254alter table mysql.slow_log engine=NonExistentEngine;
255ERROR 42000: Unknown storage engine 'NonExistentEngine'
256alter table mysql.slow_log engine=memory;
257ERROR HY000: This storage engine cannot be used for log tables"
258set default_storage_engine= @save_storage_engine;
259drop table mysql.slow_log;
260drop table mysql.general_log;
261drop table mysql.general_log;
262ERROR 42S02: Unknown table 'mysql.general_log'
263drop table mysql.slow_log;
264ERROR 42S02: Unknown table 'mysql.slow_log'
265use mysql;
266CREATE TABLE `general_log` (
267`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
268ON UPDATE CURRENT_TIMESTAMP(6),
269`user_host` mediumtext NOT NULL,
270`thread_id` bigint(21) unsigned NOT NULL,
271`server_id` int(10) unsigned NOT NULL,
272`command_type` varchar(64) NOT NULL,
273`argument` mediumblob NOT NULL
274) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
275CREATE TABLE `slow_log` (
276`start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
277ON UPDATE CURRENT_TIMESTAMP(6),
278`user_host` mediumtext NOT NULL,
279`query_time` time(6) NOT NULL,
280`lock_time` time(6) NOT NULL,
281`rows_sent` int(11) NOT NULL,
282`rows_examined` int(11) NOT NULL,
283`db` varchar(512) NOT NULL,
284`last_insert_id` int(11) NOT NULL,
285`insert_id` int(11) NOT NULL,
286`server_id` int(10) unsigned NOT NULL,
287`sql_text` mediumblob NOT NULL,
288`thread_id` bigint(21) unsigned NOT NULL
289) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
290set global general_log='ON';
291set global slow_query_log='ON';
292use test;
293flush tables with read lock;
294unlock tables;
295use mysql;
296lock tables general_log read local, help_category read local;
297ERROR HY000: You can't use locks with log tables.
298unlock tables;
299SET SESSION long_query_time = 1000;
300drop table if exists mysql.renamed_general_log;
301drop table if exists mysql.renamed_slow_log;
302drop table if exists mysql.general_log_new;
303drop table if exists mysql.slow_log_new;
304use mysql;
305RENAME TABLE general_log TO renamed_general_log;
306ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log'
307RENAME TABLE slow_log TO renamed_slow_log;
308ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log'
309truncate table general_log;
310select * from general_log;
311event_time	user_host	thread_id	server_id	command_type	argument
312TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
313truncate table slow_log;
314select * from slow_log;
315start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
316create table general_log_new like general_log;
317rename table general_log TO renamed_general_log, general_log_new TO general_log;
318create table slow_log_new like slow_log;
319rename table slow_log TO renamed_slow_log, slow_log_new TO slow_log;
320rename table general_log TO general_log_new, renamed_general_log TO general_log, slow_log to renamed_slow_log;
321ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log'
322select * from general_log;
323event_time	user_host	thread_id	server_id	command_type	argument
324TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table slow_log_new like slow_log
325TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table slow_log TO renamed_slow_log, slow_log_new TO slow_log
326TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table general_log TO general_log_new, renamed_general_log TO general_log, slow_log to renamed_slow_log
327TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
328select * from renamed_general_log;
329event_time	user_host	thread_id	server_id	command_type	argument
330TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
331TIMESTAMP	USER_HOST	THREAD_ID	1	Query	truncate table slow_log
332TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from slow_log
333TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table general_log_new like general_log
334TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table general_log TO renamed_general_log, general_log_new TO general_log
335select * from slow_log;
336start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
337select * from renamed_slow_log;
338start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
339set global general_log='OFF';
340RENAME TABLE general_log TO general_log2;
341set global slow_query_log='OFF';
342RENAME TABLE slow_log TO slow_log2;
343set global general_log='ON';
344ERROR 42S02: Table 'mysql.general_log' doesn't exist
345set global slow_query_log='ON';
346ERROR 42S02: Table 'mysql.slow_log' doesn't exist
347RENAME TABLE general_log2 TO general_log;
348RENAME TABLE slow_log2 TO slow_log;
349SET SESSION long_query_time = @saved_long_query_time;
350set global general_log='ON';
351set global slow_query_log='ON';
352flush logs;
353flush logs;
354drop table renamed_general_log, renamed_slow_log;
355use test;
356use mysql;
357repair table general_log;
358Table	Op	Msg_type	Msg_text
359mysql.general_log	repair	status	OK
360repair table slow_log;
361Table	Op	Msg_type	Msg_text
362mysql.slow_log	repair	status	OK
363create table general_log_new like general_log;
364create table slow_log_new like slow_log;
365show tables like "%log%";
366Tables_in_mysql (%log%)
367general_log
368general_log_new
369ndb_binlog_index
370slave_relay_log_info
371slow_log
372slow_log_new
373drop table slow_log_new, general_log_new;
374use test;
375drop procedure if exists proc25422_truncate_slow;
376drop procedure if exists proc25422_truncate_general;
377drop procedure if exists proc25422_alter_slow;
378drop procedure if exists proc25422_alter_general;
379use test//
380create procedure proc25422_truncate_slow (loops int)
381begin
382declare v1 int default 0;
383declare continue handler for sqlexception /* errors from truncate */
384begin end;
385while v1 < loops do
386truncate mysql.slow_log;
387set v1 = v1 + 1;
388end while;
389end//
390create procedure proc25422_truncate_general (loops int)
391begin
392declare v1 int default 0;
393declare continue handler for sqlexception /* errors from truncate */
394begin end;
395while v1 < loops do
396truncate mysql.general_log;
397set v1 = v1 + 1;
398end while;
399end//
400create procedure proc25422_alter_slow (loops int)
401begin
402declare v1 int default 0;
403declare ER_BAD_LOG_STATEMENT condition for 1575;
404declare continue handler for ER_BAD_LOG_STATEMENT begin end;
405while v1 < loops do
406set @old_log_state = @@global.slow_query_log;
407set global slow_query_log = 'OFF';
408alter table mysql.slow_log engine = CSV;
409set global slow_query_log = @old_log_state;
410set v1 = v1 + 1;
411end while;
412end//
413create procedure proc25422_alter_general (loops int)
414begin
415declare v1 int default 0;
416declare ER_BAD_LOG_STATEMENT condition for 1575;
417declare continue handler for ER_BAD_LOG_STATEMENT begin end;
418while v1 < loops do
419set @old_log_state = @@global.general_log;
420set global general_log = 'OFF';
421alter table mysql.general_log engine = CSV;
422set global general_log = @old_log_state;
423set v1 = v1 + 1;
424end while;
425end//
426set @iterations=100;
427"Serial test (proc25422_truncate_slow)"
428call proc25422_truncate_slow(@iterations);
429"Serial test (proc25422_truncate_general)"
430call proc25422_truncate_general(@iterations);
431"Serial test (proc25422_alter_slow)"
432call proc25422_alter_slow(@iterations);
433"Serial test (proc25422_alter_general)"
434call proc25422_alter_general(@iterations);
435"Parallel test"
436call proc25422_truncate_slow(@iterations);
437call proc25422_truncate_slow(@iterations);
438call proc25422_truncate_general(@iterations);
439call proc25422_truncate_general(@iterations);
440call proc25422_alter_slow(@iterations);
441call proc25422_alter_slow(@iterations);
442call proc25422_alter_general(@iterations);
443call proc25422_alter_general(@iterations);
444drop procedure proc25422_truncate_slow;
445drop procedure proc25422_truncate_general;
446drop procedure proc25422_alter_slow;
447drop procedure proc25422_alter_general;
448FLUSH TABLE mysql.general_log;
449show warnings;
450Level	Code	Message
451FLUSH TABLE mysql.slow_log;
452show warnings;
453Level	Code	Message
454SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
455Warnings:
456Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
457DROP TABLE IF EXISTS `db_17876.slow_log_data`;
458DROP TABLE IF EXISTS `db_17876.general_log_data`;
459DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`;
460DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`;
461DROP DATABASE IF EXISTS `db_17876`;
462CREATE DATABASE db_17876;
463CREATE TABLE `db_17876.slow_log_data` (
464`start_time` timestamp  default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
465`user_host` mediumtext ,
466`query_time` time ,
467`lock_time` time ,
468`rows_sent` int(11) ,
469`rows_examined` int(11) ,
470`db` varchar(512) default NULL,
471`last_insert_id` int(11) default NULL,
472`insert_id` int(11) default NULL,
473`server_id` int(11) default NULL,
474`sql_text` mediumblob,
475`thread_id` bigint(21) unsigned not NULL
476);
477CREATE TABLE `db_17876.general_log_data` (
478`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
479`user_host` mediumtext,
480`thread_id` bigint(21) unsigned not NULL,
481`server_id` int(11) DEFAULT NULL,
482`command_type` varchar(64) DEFAULT NULL,
483`argument` mediumblob
484);
485CREATE procedure `db_17876.archiveSlowLog`()
486BEGIN
487DECLARE start_time, query_time, lock_time CHAR(20);
488DECLARE user_host MEDIUMTEXT;
489DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
490DECLARE thread_id BIGINT UNSIGNED;
491DECLARE dbname MEDIUMTEXT;
492DECLARE sql_text BLOB;
493DECLARE done INT DEFAULT 0;
494DECLARE ER_SP_FETCH_NO_DATA CONDITION for 1329;
495DECLARE cur1 CURSOR FOR SELECT * FROM mysql.slow_log;
496OPEN cur1;
497REPEAT
498BEGIN
499BEGIN
500DECLARE CONTINUE HANDLER FOR ER_SP_FETCH_NO_DATA SET done = 1;
501FETCH cur1 INTO
502start_time, user_host, query_time, lock_time,
503rows_set, rows_examined, dbname, last_insert_id,
504insert_id, server_id, sql_text, thread_id;
505END;
506IF NOT done THEN
507BEGIN
508INSERT INTO
509`db_17876.slow_log_data`
510            VALUES(start_time, user_host, query_time, lock_time, rows_set, rows_examined,
511dbname, last_insert_id,  insert_id, server_id, sql_text, thread_id);
512END;
513END IF;
514END;
515UNTIL done END REPEAT;
516CLOSE cur1;
517TRUNCATE mysql.slow_log;
518END //
519CREATE procedure `db_17876.archiveGeneralLog`()
520BEGIN
521DECLARE event_time CHAR(20);
522DECLARE user_host MEDIUMTEXT;
523DECLARE argument MEDIUMBLOB;
524DECLARE thread_id BIGINT UNSIGNED;
525DECLARE server_id INT;
526DECLARE sql_text BLOB;
527DECLARE done INT DEFAULT 0;
528DECLARE command_type VARCHAR(64);
529DECLARE ER_SP_FETCH_NO_DATA CONDITION for 1329;
530DECLARE cur1 CURSOR FOR SELECT * FROM mysql.general_log;
531OPEN cur1;
532REPEAT
533BEGIN
534BEGIN
535DECLARE CONTINUE HANDLER FOR ER_SP_FETCH_NO_DATA SET done = 1;
536FETCH cur1 INTO
537event_time, user_host, thread_id, server_id,
538command_type, argument;
539END;
540IF NOT done THEN
541BEGIN
542INSERT INTO
543`db_17876.general_log_data`
544            VALUES(event_time, user_host, thread_id, server_id,
545command_type, argument);
546END;
547END IF;
548END;
549UNTIL done END REPEAT;
550CLOSE cur1;
551TRUNCATE mysql.general_log;
552END //
553SET GLOBAL general_log = ON;
554SET GLOBAL slow_query_log = ON;
555select "put something into general_log";
556put something into general_log
557put something into general_log
558select "... and something more ...";
559... and something more ...
560... and something more ...
561call `db_17876.archiveSlowLog`();
562call `db_17876.archiveGeneralLog`();
563SET GLOBAL general_log = OFF;
564SET GLOBAL slow_query_log = OFF;
565call `db_17876.archiveSlowLog`();
566call `db_17876.archiveGeneralLog`();
567DROP TABLE `db_17876.slow_log_data`;
568DROP TABLE `db_17876.general_log_data`;
569DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`;
570DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`;
571DROP DATABASE IF EXISTS `db_17876`;
572SET GLOBAL general_log = @old_general_log;
573SET GLOBAL slow_query_log = @old_slow_query_log;
574SET sql_mode = default;
575select CONNECTION_ID() into @thread_id;
576truncate table mysql.general_log;
577set global general_log = on;
578set @lparam = "000 001 002 003 004 005 006 007 008 009"
579              "010 011 012 013 014 015 016 017 018 019"
580              "020 021 022 023 024 025 026 027 028 029"
581              "030 031 032 033 034 035 036 037 038 039"
582              "040 041 042 043 044 045 046 047 048 049"
583              "050 051 052 053 054 055 056 057 058 059"
584              "060 061 062 063 064 065 066 067 068 069"
585              "070 071 072 073 074 075 076 077 078 079"
586              "080 081 082 083 084 085 086 087 088 089"
587              "090 091 092 093 094 095 096 097 098 099"
588              "100 101 102 103 104 105 106 107 108 109"
589              "110 111 112 113 114 115 116 117 118 119"
590              "120 121 122 123 124 125 126 127 128 129"
591              "130 131 132 133 134 135 136 137 138 139"
592              "140 141 142 143 144 145 146 147 148 149"
593              "150 151 152 153 154 155 156 157 158 159"
594              "160 161 162 163 164 165 166 167 168 169"
595              "170 171 172 173 174 175 176 177 178 179"
596              "180 181 182 183 184 185 186 187 188 189"
597              "190 191 192 193 194 195 196 197 198 199"
598              "200 201 202 203 204 205 206 207 208 209"
599              "210 211 212 213 214 215 216 217 218 219"
600              "220 221 222 223 224 225 226 227 228 229"
601              "230 231 232 233 234 235 236 237 238 239"
602              "240 241 242 243 244 245 246 247 248 249"
603              "250 251 252 253 254 255 256 257 258 259"
604              "260 261 262 263 264 265 266 267 268 269"
605              "270 271 272 273 274 275 276 277 278 279"
606              "280 281 282 283 284 285 286 287 288 289"
607              "290 291 292 293 294 295 296 297 298 299"
608              "300 301 302 303 304 305 306 307 308 309"
609              "310 311 312 313 314 315 316 317 318 319"
610              "320 321 322 323 324 325 326 327 328 329"
611              "330 331 332 333 334 335 336 337 338 339"
612              "340 341 342 343 344 345 346 347 348 349"
613              "350 351 352 353 354 355 356 357 358 359"
614              "360 361 362 363 364 365 366 367 368 369"
615              "370 371 372 373 374 375 376 377 378 379"
616              "380 381 382 383 384 385 386 387 388 389"
617              "390 391 392 393 394 395 396 397 398 399"
618              "400 401 402 403 404 405 406 407 408 409"
619              "410 411 412 413 414 415 416 417 418 419"
620              "420 421 422 423 424 425 426 427 428 429"
621              "430 431 432 433 434 435 436 437 438 439"
622              "440 441 442 443 444 445 446 447 448 449"
623              "450 451 452 453 454 455 456 457 458 459"
624              "460 461 462 463 464 465 466 467 468 469"
625              "470 471 472 473 474 475 476 477 478 479"
626              "480 481 482 483 484 485 486 487 488 489"
627              "490 491 492 493 494 495 496 497 498 499"
628              "500 501 502 503 504 505 506 507 508 509"
629              "510 511 512 513 514 515 516 517 518 519"
630              "520 521 522 523 524 525 526 527 528 529"
631              "530 531 532 533 534 535 536 537 538 539"
632              "540 541 542 543 544 545 546 547 548 549"
633              "550 551 552 553 554 555 556 557 558 559"
634              "560 561 562 563 564 565 566 567 568 569"
635              "570 571 572 573 574 575 576 577 578 579"
636              "580 581 582 583 584 585 586 587 588 589"
637              "590 591 592 593 594 595 596 597 598 599"
638              "600 601 602 603 604 605 606 607 608 609"
639              "610 611 612 613 614 615 616 617 618 619"
640              "620 621 622 623 624 625 626 627 628 629"
641              "630 631 632 633 634 635 636 637 638 639"
642              "640 641 642 643 644 645 646 647 648 649"
643              "650 651 652 653 654 655 656 657 658 659"
644              "660 661 662 663 664 665 666 667 668 669"
645              "670 671 672 673 674 675 676 677 678 679"
646              "680 681 682 683 684 685 686 687 688 689"
647              "690 691 692 693 694 695 696 697 698 699"
648              "700 701 702 703 704 705 706 707 708 709"
649              "710 711 712 713 714 715 716 717 718 719"
650              "720 721 722 723 724 725 726 727 728 729"
651              "730 731 732 733 734 735 736 737 738 739"
652              "740 741 742 743 744 745 746 747 748 749"
653              "750 751 752 753 754 755 756 757 758 759"
654              "760 761 762 763 764 765 766 767 768 769"
655              "770 771 772 773 774 775 776 777 778 779"
656              "780 781 782 783 784 785 786 787 788 789"
657              "790 791 792 793 794 795 796 797 798 799"
658              "800 801 802 803 804 805 806 807 808 809"
659              "810 811 812 813 814 815 816 817 818 819"
660              "820 821 822 823 824 825 826 827 828 829"
661              "830 831 832 833 834 835 836 837 838 839"
662              "840 841 842 843 844 845 846 847 848 849"
663              "850 851 852 853 854 855 856 857 858 859"
664              "860 861 862 863 864 865 866 867 868 869"
665              "870 871 872 873 874 875 876 877 878 879"
666              "880 881 882 883 884 885 886 887 888 889"
667              "890 891 892 893 894 895 896 897 898 899"
668              "900 901 902 903 904 905 906 907 908 909"
669              "910 911 912 913 914 915 916 917 918 919"
670              "920 921 922 923 924 925 926 927 928 929"
671              "930 931 932 933 934 935 936 937 938 939"
672              "940 941 942 943 944 945 946 947 948 949"
673              "950 951 952 953 954 955 956 957 958 959"
674              "960 961 962 963 964 965 966 967 968 969"
675              "970 971 972 973 974 975 976 977 978 979"
676              "980 981 982 983 984 985 986 987 988 989"
677              "990 991 992 993 994 995 996 997 998 999";
678prepare long_query from "select ? as long_query";
679execute long_query using @lparam;
680set global general_log = off;
681select command_type, argument from mysql.general_log where thread_id = @thread_id;
682command_type	argument
683Query	set global general_log = on
684Query	set @lparam = "000 001 002 003 004 005 006 007 008 009"
685              "010 011 012 013 014 015 016 017 018 019"
686              "020 021 022 023 024 025 026 027 028 029"
687              "030 031 032 033 034 035 036 037 038 039"
688              "040 041 042 043 044 045 046 047 048 049"
689              "050 051 052 053 054 055 056 057 058 059"
690              "060 061 062 063 064 065 066 067 068 069"
691              "070 071 072 073 074 075 076 077 078 079"
692              "080 081 082 083 084 085 086 087 088 089"
693              "090 091 092 093 094 095 096 097 098 099"
694              "100 101 102 103 104 105 106 107 108 109"
695              "110 111 112 113 114 115 116 117 118 119"
696              "120 121 122 123 124 125 126 127 128 129"
697              "130 131 132 133 134 135 136 137 138 139"
698              "140 141 142 143 144 145 146 147 148 149"
699              "150 151 152 153 154 155 156 157 158 159"
700              "160 161 162 163 164 165 166 167 168 169"
701              "170 171 172 173 174 175 176 177 178 179"
702              "180 181 182 183 184 185 186 187 188 189"
703              "190 191 192 193 194 195 196 197 198 199"
704              "200 201 202 203 204 205 206 207 208 209"
705              "210 211 212 213 214 215 216 217 218 219"
706              "220 221 222 223 224 225 226 227 228 229"
707              "230 231 232 233 234 235 236 237 238 239"
708              "240 241 242 243 244 245 246 247 248 249"
709              "250 251 252 253 254 255 256 257 258 259"
710              "260 261 262 263 264 265 266 267 268 269"
711              "270 271 272 273 274 275 276 277 278 279"
712              "280 281 282 283 284 285 286 287 288 289"
713              "290 291 292 293 294 295 296 297 298 299"
714              "300 301 302 303 304 305 306 307 308 309"
715              "310 311 312 313 314 315 316 317 318 319"
716              "320 321 322 323 324 325 326 327 328 329"
717              "330 331 332 333 334 335 336 337 338 339"
718              "340 341 342 343 344 345 346 347 348 349"
719              "350 351 352 353 354 355 356 357 358 359"
720              "360 361 362 363 364 365 366 367 368 369"
721              "370 371 372 373 374 375 376 377 378 379"
722              "380 381 382 383 384 385 386 387 388 389"
723              "390 391 392 393 394 395 396 397 398 399"
724              "400 401 402 403 404 405 406 407 408 409"
725              "410 411 412 413 414 415 416 417 418 419"
726              "420 421 422 423 424 425 426 427 428 429"
727              "430 431 432 433 434 435 436 437 438 439"
728              "440 441 442 443 444 445 446 447 448 449"
729              "450 451 452 453 454 455 456 457 458 459"
730              "460 461 462 463 464 465 466 467 468 469"
731              "470 471 472 473 474 475 476 477 478 479"
732              "480 481 482 483 484 485 486 487 488 489"
733              "490 491 492 493 494 495 496 497 498 499"
734              "500 501 502 503 504 505 506 507 508 509"
735              "510 511 512 513 514 515 516 517 518 519"
736              "520 521 522 523 524 525 526 527 528 529"
737              "530 531 532 533 534 535 536 537 538 539"
738              "540 541 542 543 544 545 546 547 548 549"
739              "550 551 552 553 554 555 556 557 558 559"
740              "560 561 562 563 564 565 566 567 568 569"
741              "570 571 572 573 574 575 576 577 578 579"
742              "580 581 582 583 584 585 586 587 588 589"
743              "590 591 592 593 594 595 596 597 598 599"
744              "600 601 602 603 604 605 606 607 608 609"
745              "610 611 612 613 614 615 616 617 618 619"
746              "620 621 622 623 624 625 626 627 628 629"
747              "630 631 632 633 634 635 636 637 638 639"
748              "640 641 642 643 644 645 646 647 648 649"
749              "650 651 652 653 654 655 656 657 658 659"
750              "660 661 662 663 664 665 666 667 668 669"
751              "670 671 672 673 674 675 676 677 678 679"
752              "680 681 682 683 684 685 686 687 688 689"
753              "690 691 692 693 694 695 696 697 698 699"
754              "700 701 702 703 704 705 706 707 708 709"
755              "710 711 712 713 714 715 716 717 718 719"
756              "720 721 722 723 724 725 726 727 728 729"
757              "730 731 732 733 734 735 736 737 738 739"
758              "740 741 742 743 744 745 746 747 748 749"
759              "750 751 752 753 754 755 756 757 758 759"
760              "760 761 762 763 764 765 766 767 768 769"
761              "770 771 772 773 774 775 776 777 778 779"
762              "780 781 782 783 784 785 786 787 788 789"
763              "790 791 792 793 794 795 796 797 798 799"
764              "800 801 802 803 804 805 806 807 808 809"
765              "810 811 812 813 814 815 816 817 818 819"
766              "820 821 822 823 824 825 826 827 828 829"
767              "830 831 832 833 834 835 836 837 838 839"
768              "840 841 842 843 844 845 846 847 848 849"
769              "850 851 852 853 854 855 856 857 858 859"
770              "860 861 862 863 864 865 866 867 868 869"
771              "870 871 872 873 874 875 876 877 878 879"
772              "880 881 882 883 884 885 886 887 888 889"
773              "890 891 892 893 894 895 896 897 898 899"
774              "900 901 902 903 904 905 906 907 908 909"
775              "910 911 912 913 914 915 916 917 918 919"
776              "920 921 922 923 924 925 926 927 928 929"
777              "930 931 932 933 934 935 936 937 938 939"
778              "940 941 942 943 944 945 946 947 948 949"
779              "950 951 952 953 954 955 956 957 958 959"
780              "960 961 962 963 964 965 966 967 968 969"
781              "970 971 972 973 974 975 976 977 978 979"
782              "980 981 982 983 984 985 986 987 988 989"
783              "990 991 992 993 994 995 996 997 998 999"
784Query	PREPARE long_query FROM ...
785Prepare	select ? as long_query
786Query	execute long_query using @lparam
787Execute	select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 018 019020 021 022 023 024 025 026 027 028 029030 031 032 033 034 035 036 037 038 039040 041 042 043 044 045 046 047 048 049050 051 052 053 054 055 056 057 058 059060 061 062 063 064 065 066 067 068 069070 071 072 073 074 075 076 077 078 079080 081 082 083 084 085 086 087 088 089090 091 092 093 094 095 096 097 098 099100 101 102 103 104 105 106 107 108 109110 111 112 113 114 115 116 117 118 119120 121 122 123 124 125 126 127 128 129130 131 132 133 134 135 136 137 138 139140 141 142 143 144 145 146 147 148 149150 151 152 153 154 155 156 157 158 159160 161 162 163 164 165 166 167 168 169170 171 172 173 174 175 176 177 178 179180 181 182 183 184 185 186 187 188 189190 191 192 193 194 195 196 197 198 199200 201 202 203 204 205 206 207 208 209210 211 212 213 214 215 216 217 218 219220 221 222 223 224 225 226 227 228 229230 231 232 233 234 235 236 237 238 239240 241 242 243 244 245 246 247 248 249250 251 252 253 254 255 256 257 258 259260 261 262 263 264 265 266 267 268 269270 271 272 273 274 275 276 277 278 279280 281 282 283 284 285 286 287 288 289290 291 292 293 294 295 296 297 298 299300 301 302 303 304 305 306 307 308 309310 311 312 313 314 315 316 317 318 319320 321 322 323 324 325 326 327 328 329330 331 332 333 334 335 336 337 338 339340 341 342 343 344 345 346 347 348 349350 351 352 353 354 355 356 357 358 359360 361 362 363 364 365 366 367 368 369370 371 372 373 374 375 376 377 378 379380 381 382 383 384 385 386 387 388 389390 391 392 393 394 395 396 397 398 399400 401 402 403 404 405 406 407 408 409410 411 412 413 414 415 416 417 418 419420 421 422 423 424 425 426 427 428 429430 431 432 433 434 435 436 437 438 439440 441 442 443 444 445 446 447 448 449450 451 452 453 454 455 456 457 458 459460 461 462 463 464 465 466 467 468 469470 471 472 473 474 475 476 477 478 479480 481 482 483 484 485 486 487 488 489490 491 492 493 494 495 496 497 498 499500 501 502 503 504 505 506 507 508 509510 511 512 513 514 515 516 517 518 519520 521 522 523 524 525 526 527 528 529530 531 532 533 534 535 536 537 538 539540 541 542 543 544 545 546 547 548 549550 551 552 553 554 555 556 557 558 559560 561 562 563 564 565 566 567 568 569570 571 572 573 574 575 576 577 578 579580 581 582 583 584 585 586 587 588 589590 591 592 593 594 595 596 597 598 599600 601 602 603 604 605 606 607 608 609610 611 612 613 614 615 616 617 618 619620 621 622 623 624 625 626 627 628 629630 631 632 633 634 635 636 637 638 639640 641 642 643 644 645 646 647 648 649650 651 652 653 654 655 656 657 658 659660 661 662 663 664 665 666 667 668 669670 671 672 673 674 675 676 677 678 679680 681 682 683 684 685 686 687 688 689690 691 692 693 694 695 696 697 698 699700 701 702 703 704 705 706 707 708 709710 711 712 713 714 715 716 717 718 719720 721 722 723 724 725 726 727 728 729730 731 732 733 734 735 736 737 738 739740 741 742 743 744 745 746 747 748 749750 751 752 753 754 755 756 757 758 759760 761 762 763 764 765 766 767 768 769770 771 772 773 774 775 776 777 778 779780 781 782 783 784 785 786 787 788 789790 791 792 793 794 795 796 797 798 799800 801 802 803 804 805 806 807 808 809810 811 812 813 814 815 816 817 818 819820 821 822 823 824 825 826 827 828 829830 831 832 833 834 835 836 837 838 839840 841 842 843 844 845 846 847 848 849850 851 852 853 854 855 856 857 858 859860 861 862 863 864 865 866 867 868 869870 871 872 873 874 875 876 877 878 879880 881 882 883 884 885 886 887 888 889890 891 892 893 894 895 896 897 898 899900 901 902 903 904 905 906 907 908 909910 911 912 913 914 915 916 917 918 919920 921 922 923 924 925 926 927 928 929930 931 932 933 934 935 936 937 938 939940 941 942 943 944 945 946 947 948 949950 951 952 953 954 955 956 957 958 959960 961 962 963 964 965 966 967 968 969970 971 972 973 974 975 976 977 978 979980 981 982 983 984 985 986 987 988 989990 991 992 993 994 995 996 997 998 999' as long_query
788Query	set global general_log = off
789deallocate prepare long_query;
790set global general_log = @old_general_log;
791DROP TABLE IF EXISTS log_count;
792DROP TABLE IF EXISTS slow_log_copy;
793DROP TABLE IF EXISTS general_log_copy;
794CREATE TABLE log_count (count BIGINT(21));
795SET GLOBAL general_log = ON;
796SET GLOBAL slow_query_log = ON;
797CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log;
798INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log;
799INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log));
800DROP TABLE slow_log_copy;
801CREATE TABLE general_log_copy SELECT * FROM mysql.general_log;
802INSERT INTO general_log_copy SELECT * FROM mysql.general_log;
803INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log));
804DROP TABLE general_log_copy;
805SET GLOBAL general_log = OFF;
806SET GLOBAL slow_query_log = OFF;
807CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log;
808INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log;
809INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log));
810DROP TABLE slow_log_copy;
811CREATE TABLE general_log_copy SELECT * FROM mysql.general_log;
812INSERT INTO general_log_copy SELECT * FROM mysql.general_log;
813INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log));
814DROP TABLE general_log_copy;
815SET GLOBAL general_log = @saved_general_log;
816SET GLOBAL slow_query_log = @saved_slow_query_log;
817DROP TABLE log_count;
818SET SESSION long_query_time = 0;
819SET GLOBAL slow_query_log = ON;
820FLUSH LOGS;
821TRUNCATE TABLE mysql.slow_log;
822CREATE TABLE t1 (f1 SERIAL,f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2));
823INSERT INTO t1 VALUES (1,1,1);
824INSERT INTO t1 VALUES (2,2,2);
825INSERT INTO t1 VALUES (3,3,3);
826INSERT INTO t1 VALUES (4,4,4);
827SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4;
828Bug#31700 - SCAN	f1	f2	f3	SLEEP(1.1)
829Bug#31700 - SCAN	4	4	4	0
830Warnings:
831Warning	1681	'SQL_NO_CACHE' is deprecated and will be removed in a future release.
832SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3;
833Bug#31700 - KEY	f1	f2	f3	SLEEP(1.1)
834Bug#31700 - KEY	3	3	3	0
835Warnings:
836Warning	1681	'SQL_NO_CACHE' is deprecated and will be removed in a future release.
837SELECT SQL_NO_CACHE 'Bug#31700 - PK',  f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2;
838Bug#31700 - PK	f1	f2	f3	SLEEP(1.1)
839Bug#31700 - PK	2	2	2	0
840Warnings:
841Warning	1681	'SQL_NO_CACHE' is deprecated and will be removed in a future release.
842SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time;
843start_time	rows_examined	rows_sent	sql_text
844TIMESTAMP	4	1	SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4
845TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3
846TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#31700 - PK',  f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2
847DROP TABLE t1;
848TRUNCATE TABLE mysql.slow_log;
849use mysql;
850drop table if exists renamed_general_log;
851drop table if exists renamed_slow_log;
852RENAME TABLE general_log TO renamed_general_log;
853ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log'
854RENAME TABLE slow_log TO renamed_slow_log;
855ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log'
856use test;
857flush tables with read lock;
858unlock tables;
859#
860# WL#6613: Refactor logging code - split logging and binlogging code
861#
862SET GLOBAL log_output= 'TABLE';
863SELECT @@general_log;
864@@general_log
8651
866ALTER TABLE mysql.general_log DISCARD TABLESPACE;
867ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
868SET @@session.long_query_time= @old_long_query_time;
869SET @@global.log_output=       @old_log_output;
870SET @@global.slow_query_log=   @old_slow_query_log;
871SET @@global.general_log=      @old_general_log;
872