Skip to content

Commit 61321b6

Browse files
author
Tatjana Azundris Nuernberg
committed
Bug#14236124: WRONG CONNECTION ID (THREAD ID) IN THE GENERAL AND SLOW QUER
Optional add-on to previous patch which corrected logging to file) wherein we change width of thread-ID field in slow and general log tables from INT to BIGINT (4 to 8 bytes), for correct logging of very large thread-IDs. Thread-IDs can get very large; patch adjusts general-logging and slow query logging to reflect that and log those IDs correctly. Backport to 5.6.
1 parent 5226c9a commit 61321b6

25 files changed

Lines changed: 71 additions & 63 deletions

mysql-test/r/create.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ create table t1 like information_schema.processlist;
18891889
show create table t1;
18901890
Table Create Table
18911891
t1 CREATE TABLE `t1` (
1892-
`ID` bigint(4) NOT NULL DEFAULT '0',
1892+
`ID` bigint(21) unsigned NOT NULL DEFAULT '0',
18931893
`USER` varchar(16) NOT NULL DEFAULT '',
18941894
`HOST` varchar(64) NOT NULL DEFAULT '',
18951895
`DB` varchar(64) DEFAULT NULL,
@@ -1903,7 +1903,7 @@ create temporary table t1 like information_schema.processlist;
19031903
show create table t1;
19041904
Table Create Table
19051905
t1 CREATE TEMPORARY TABLE `t1` (
1906-
`ID` bigint(4) NOT NULL DEFAULT '0',
1906+
`ID` bigint(21) unsigned NOT NULL DEFAULT '0',
19071907
`USER` varchar(16) NOT NULL DEFAULT '',
19081908
`HOST` varchar(64) NOT NULL DEFAULT '',
19091909
`DB` varchar(64) DEFAULT NULL,

mysql-test/r/ctype_binary.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ create table t1 as select concat(connection_id()) as c1;
746746
show create table t1;
747747
Table Create Table
748748
t1 CREATE TABLE `t1` (
749-
`c1` varbinary(10) NOT NULL DEFAULT ''
749+
`c1` varbinary(21) NOT NULL DEFAULT ''
750750
) ENGINE=MyISAM DEFAULT CHARSET=latin1
751751
drop table t1;
752752
select hex(concat(inet_aton('127.1.1.1')));

mysql-test/r/ctype_cp1251.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ create table t1 as select concat(connection_id()) as c1;
11381138
show create table t1;
11391139
Table Create Table
11401140
t1 CREATE TABLE `t1` (
1141-
`c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT ''
1141+
`c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT ''
11421142
) ENGINE=MyISAM DEFAULT CHARSET=latin1
11431143
drop table t1;
11441144
select hex(concat(inet_aton('127.1.1.1')));

mysql-test/r/ctype_latin1.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ create table t1 as select concat(connection_id()) as c1;
11651165
show create table t1;
11661166
Table Create Table
11671167
t1 CREATE TABLE `t1` (
1168-
`c1` varchar(10) NOT NULL DEFAULT ''
1168+
`c1` varchar(21) NOT NULL DEFAULT ''
11691169
) ENGINE=MyISAM DEFAULT CHARSET=latin1
11701170
drop table t1;
11711171
select hex(concat(inet_aton('127.1.1.1')));

mysql-test/r/ctype_ucs.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,7 @@ create table t1 as select concat(connection_id()) as c1;
20832083
show create table t1;
20842084
Table Create Table
20852085
t1 CREATE TABLE `t1` (
2086-
`c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
2086+
`c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT ''
20872087
) ENGINE=MyISAM DEFAULT CHARSET=latin1
20882088
drop table t1;
20892089
select hex(concat(inet_aton('127.1.1.1')));

mysql-test/r/ctype_utf8.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2992,7 +2992,7 @@ create table t1 as select concat(connection_id()) as c1;
29922992
show create table t1;
29932993
Table Create Table
29942994
t1 CREATE TABLE `t1` (
2995-
`c1` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT ''
2995+
`c1` varchar(21) CHARACTER SET utf8 NOT NULL DEFAULT ''
29962996
) ENGINE=MyISAM DEFAULT CHARSET=latin1
29972997
drop table t1;
29982998
select hex(concat(inet_aton('127.1.1.1')));

mysql-test/r/log_tables.result

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Table Create Table
5555
general_log CREATE TABLE `general_log` (
5656
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5757
`user_host` mediumtext NOT NULL,
58-
`thread_id` int(11) NOT NULL,
58+
`thread_id` bigint(21) unsigned NOT NULL,
5959
`server_id` int(10) unsigned NOT NULL,
6060
`command_type` varchar(64) NOT NULL,
6161
`argument` mediumtext NOT NULL
@@ -64,7 +64,7 @@ show fields from mysql.general_log;
6464
Field Type Null Key Default Extra
6565
event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
6666
user_host mediumtext NO NULL
67-
thread_id int(11) NO NULL
67+
thread_id bigint(21) unsigned NO NULL
6868
server_id int(10) unsigned NO NULL
6969
command_type varchar(64) NO NULL
7070
argument mediumtext NO NULL
@@ -82,7 +82,7 @@ slow_log CREATE TABLE `slow_log` (
8282
`insert_id` int(11) NOT NULL,
8383
`server_id` int(10) unsigned NOT NULL,
8484
`sql_text` mediumtext NOT NULL,
85-
`thread_id` int(11) NOT NULL
85+
`thread_id` bigint(21) unsigned NOT NULL
8686
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
8787
show fields from mysql.slow_log;
8888
Field Type Null Key Default Extra
@@ -97,7 +97,7 @@ last_insert_id int(11) NO NULL
9797
insert_id int(11) NO NULL
9898
server_id int(10) unsigned NO NULL
9999
sql_text mediumtext NO NULL
100-
thread_id int(11) NO NULL
100+
thread_id bigint(21) unsigned NO NULL
101101
flush logs;
102102
flush tables;
103103
SET GLOBAL GENERAL_LOG=ON;
@@ -168,7 +168,7 @@ Table Create Table
168168
general_log CREATE TABLE `general_log` (
169169
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
170170
`user_host` mediumtext NOT NULL,
171-
`thread_id` int(11) NOT NULL,
171+
`thread_id` bigint(21) unsigned NOT NULL,
172172
`server_id` int(10) unsigned NOT NULL,
173173
`command_type` varchar(64) NOT NULL,
174174
`argument` mediumtext NOT NULL
@@ -187,7 +187,7 @@ slow_log CREATE TABLE `slow_log` (
187187
`insert_id` int(11) NOT NULL,
188188
`server_id` int(10) unsigned NOT NULL,
189189
`sql_text` mediumtext NOT NULL,
190-
`thread_id` int(11) NOT NULL
190+
`thread_id` bigint(21) unsigned NOT NULL
191191
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
192192
alter table mysql.general_log engine=myisam;
193193
alter table mysql.slow_log engine=myisam;
@@ -196,7 +196,7 @@ Table Create Table
196196
general_log CREATE TABLE `general_log` (
197197
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
198198
`user_host` mediumtext NOT NULL,
199-
`thread_id` int(11) NOT NULL,
199+
`thread_id` bigint(21) unsigned NOT NULL,
200200
`server_id` int(10) unsigned NOT NULL,
201201
`command_type` varchar(64) NOT NULL,
202202
`argument` mediumtext NOT NULL
@@ -215,7 +215,7 @@ slow_log CREATE TABLE `slow_log` (
215215
`insert_id` int(11) NOT NULL,
216216
`server_id` int(10) unsigned NOT NULL,
217217
`sql_text` mediumtext NOT NULL,
218-
`thread_id` int(11) NOT NULL
218+
`thread_id` bigint(21) unsigned NOT NULL
219219
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Slow log'
220220
set global general_log='ON';
221221
set global slow_query_log='ON';
@@ -267,7 +267,7 @@ CREATE TABLE `general_log` (
267267
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
268268
ON UPDATE CURRENT_TIMESTAMP,
269269
`user_host` mediumtext NOT NULL,
270-
`thread_id` int(11) NOT NULL,
270+
`thread_id` bigint(21) unsigned NOT NULL,
271271
`server_id` int(10) unsigned NOT NULL,
272272
`command_type` varchar(64) NOT NULL,
273273
`argument` mediumtext NOT NULL
@@ -285,7 +285,7 @@ ON UPDATE CURRENT_TIMESTAMP,
285285
`insert_id` int(11) NOT NULL,
286286
`server_id` int(10) unsigned NOT NULL,
287287
`sql_text` mediumtext NOT NULL,
288-
`thread_id` int(11) NOT NULL
288+
`thread_id` bigint(21) unsigned NOT NULL
289289
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
290290
set global general_log='ON';
291291
set global slow_query_log='ON';
@@ -469,12 +469,12 @@ CREATE TABLE `db_17876.slow_log_data` (
469469
`insert_id` int(11) default NULL,
470470
`server_id` int(11) default NULL,
471471
`sql_text` mediumtext,
472-
`thread_id` int(11) default NULL
472+
`thread_id` bigint(21) unsigned not NULL
473473
);
474474
CREATE TABLE `db_17876.general_log_data` (
475475
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
476476
`user_host` mediumtext,
477-
`thread_id` int(11) DEFAULT NULL,
477+
`thread_id` bigint(21) unsigned not NULL,
478478
`server_id` int(11) DEFAULT NULL,
479479
`command_type` varchar(64) DEFAULT NULL,
480480
`argument` mediumtext
@@ -483,7 +483,8 @@ CREATE procedure `db_17876.archiveSlowLog`()
483483
BEGIN
484484
DECLARE start_time, query_time, lock_time CHAR(20);
485485
DECLARE user_host MEDIUMTEXT;
486-
DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id, thread_id INT;
486+
DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
487+
DECLARE thread_id BIGINT UNSIGNED;
487488
DECLARE dbname MEDIUMTEXT;
488489
DECLARE sql_text BLOB;
489490
DECLARE done INT DEFAULT 0;
@@ -516,7 +517,8 @@ CREATE procedure `db_17876.archiveGeneralLog`()
516517
BEGIN
517518
DECLARE event_time CHAR(20);
518519
DECLARE user_host, argument MEDIUMTEXT;
519-
DECLARE thread_id, server_id INT;
520+
DECLARE thread_id BIGINT UNSIGNED;
521+
DECLARE server_id INT;
520522
DECLARE sql_text BLOB;
521523
DECLARE done INT DEFAULT 0;
522524
DECLARE command_type VARCHAR(64);

mysql-test/r/mysqldump.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5376,7 +5376,7 @@ Table Create Table
53765376
general_log CREATE TABLE `general_log` (
53775377
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
53785378
`user_host` mediumtext NOT NULL,
5379-
`thread_id` int(11) NOT NULL,
5379+
`thread_id` bigint(21) unsigned NOT NULL,
53805380
`server_id` int(10) unsigned NOT NULL,
53815381
`command_type` varchar(64) NOT NULL,
53825382
`argument` mediumtext NOT NULL
@@ -5395,7 +5395,7 @@ slow_log CREATE TABLE `slow_log` (
53955395
`insert_id` int(11) NOT NULL,
53965396
`server_id` int(10) unsigned NOT NULL,
53975397
`sql_text` mediumtext NOT NULL,
5398-
`thread_id` int(11) NOT NULL
5398+
`thread_id` bigint(21) unsigned NOT NULL
53995399
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
54005400
SET @@global.log_output= @old_log_output_state;
54015401
SET @@global.slow_query_log= @old_slow_query_log_state;

mysql-test/r/system_mysql_db.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Table Create Table
224224
general_log CREATE TABLE `general_log` (
225225
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
226226
`user_host` mediumtext NOT NULL,
227-
`thread_id` int(11) NOT NULL,
227+
`thread_id` bigint(21) unsigned NOT NULL,
228228
`server_id` int(10) unsigned NOT NULL,
229229
`command_type` varchar(64) NOT NULL,
230230
`argument` mediumtext NOT NULL
@@ -243,7 +243,7 @@ slow_log CREATE TABLE `slow_log` (
243243
`insert_id` int(11) NOT NULL,
244244
`server_id` int(10) unsigned NOT NULL,
245245
`sql_text` mediumtext NOT NULL,
246-
`thread_id` int(11) NOT NULL
246+
`thread_id` bigint(21) unsigned NOT NULL
247247
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
248248
show tables;
249249
Tables_in_test

mysql-test/suite/funcs_1/r/is_columns_is.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL
185185
def information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
186186
def information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
187187
def information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
188-
def information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
188+
def information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
189189
def information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
190190
def information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
191191
def information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select
@@ -578,7 +578,7 @@ NULL information_schema PARTITIONS CHECKSUM bigint NULL NULL NULL NULL bigint(21
578578
1.0000 information_schema PLUGINS PLUGIN_DESCRIPTION longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
579579
3.0000 information_schema PLUGINS PLUGIN_LICENSE varchar 80 240 utf8 utf8_general_ci varchar(80)
580580
3.0000 information_schema PLUGINS LOAD_OPTION varchar 64 192 utf8 utf8_general_ci varchar(64)
581-
NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4)
581+
NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(21) unsigned
582582
3.0000 information_schema PROCESSLIST USER varchar 16 48 utf8 utf8_general_ci varchar(16)
583583
3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64)
584584
3.0000 information_schema PROCESSLIST DB varchar 64 192 utf8 utf8_general_ci varchar(64)

0 commit comments

Comments
 (0)