~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/r/log_tables.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

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