Bug #79868 5.7's General log misses tab-character between timestamp and thread_id
Description:
5.6's general log has a tab-character between timestamp and thread_id in general_log_file, but 5.7's general log doesn't have it.
So, timestamp and thread_id are mixed as one-string when thread_id grows like this.
```
2016-01-07T15:32:58.296987+09:0015526 Query set autocommit=1
```
How to repeat:
On 5.6.28,
```
$ bin/mysqld --no-defaults --general-log
$ bin/mysql
$ cat data/hostname.log
bin/mysqld, Version: 5.6.28-log (Source distribution). started with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
160107 15:47:01 1 Connect root@localhost on
1 Query select @@version_comment limit 1
$ od -c data/hostname.log
0000000 b i n / m y s q l d , V e r s
0000020 i o n : 5 . 6 . 2 8 - l o g
0000040 ( S o u r c e d i s t r i b u
0000060 t i o n ) . s t a r t e d w
0000100 i t h : \n T c p p o r t : 0
0000120 U n i x s o c k e t : (
0000140 n u l l ) \n T i m e
0000160 I d C o
0000200 m m a n d A r g u m e n
0000220 t \n 1 6 0 1 0 7 1 5 : 4 7 : 0
0000240 1 \t 1 C o n n e c t \t
0000260 r o o t @ l o c a l h o s t o
0000300 n \n \t \t 1 Q u e r y
0000320 \t s e l e c t @ @ v e r s i o
0000340 n _ c o m m e n t l i m i t
0000360 1 \n
0000362
```
There's tab-characcter between timestamp "160107 15:47:01" and thread_id "1".
Corresponding source code, https://github.com/mysql/mysql-server/blob/5.6/sql/log.cc#L1831 , there's tab-character.
At 5.7.10,
```
$ bin/mysqld --no-defaults --general-log
$ bin/mysql
$ cat data/hostname.log
bin/mysqld, Version: 5.7.10-log (Source distribution). started with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
2016-01-07T06:46:08.375273Z 2 Connect root@localhost on using Socket
2016-01-07T06:46:08.375529Z 2 Query select @@version_comment limit 1
$ od -c data/hostname.log
0000000 b i n / m y s q l d , V e r s
0000020 i o n : 5 . 7 . 1 0 - l o g
0000040 ( S o u r c e d i s t r i b u
0000060 t i o n ) . s t a r t e d w
0000100 i t h : \n T c p p o r t : 0
0000120 U n i x s o c k e t : (
0000140 n u l l ) \n T i m e
0000160 I d C o
0000200 m m a n d A r g u m e n
0000220 t \n 2 0 1 6 - 0 1 - 0 7 T 0 6 :
0000240 4 6 : 0 8 . 3 7 5 2 7 3 Z
0000260 2 C o n n e c t \t r o o t @
0000300 l o c a l h o s t o n u s
0000320 i n g S o c k e t \n 2 0 1 6 -
0000340 0 1 - 0 7 T 0 6 : 4 6 : 0 8 . 3
0000360 7 5 5 2 9 Z 2 Q u e r
0000400 y \t s e l e c t @ @ v e r s i
0000420 o n _ c o m m e n t l i m i t
0000440 1 \n
0000443
```
There're only some space-character between "2016-01-07T06:46:08.375273Z" and "2".
Corresponding source code, https://github.com/mysql/mysql-server/blob/5.7/sql/log.cc#L681-L687 , there's no tab-character.
Suggested fix:
Add tab-character between them like 5.6's general log.
See attached patch.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.044 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: 5.6's general log has a tab-character between timestamp and thread_id in general_log_file, but 5.7's general log doesn't have it. So, timestamp and thread_id are mixed as one-string when thread_id grows like this. ``` 2016-01-07T15:32:58.296987+09:0015526 Query set autocommit=1 ``` How to repeat: On 5.6.28, ``` $ bin/mysqld --no-defaults --general-log $ bin/mysql $ cat data/hostname.log bin/mysqld, Version: 5.6.28-log (Source distribution). started with: Tcp port: 0 Unix socket: (null) Time Id Command Argument 160107 15:47:01 1 Connect root@localhost on 1 Query select @@version_comment limit 1 $ od -c data/hostname.log 0000000 b i n / m y s q l d , V e r s 0000020 i o n : 5 . 6 . 2 8 - l o g 0000040 ( S o u r c e d i s t r i b u 0000060 t i o n ) . s t a r t e d w 0000100 i t h : \n T c p p o r t : 0 0000120 U n i x s o c k e t : ( 0000140 n u l l ) \n T i m e 0000160 I d C o 0000200 m m a n d A r g u m e n 0000220 t \n 1 6 0 1 0 7 1 5 : 4 7 : 0 0000240 1 \t 1 C o n n e c t \t 0000260 r o o t @ l o c a l h o s t o 0000300 n \n \t \t 1 Q u e r y 0000320 \t s e l e c t @ @ v e r s i o 0000340 n _ c o m m e n t l i m i t 0000360 1 \n 0000362 ``` There's tab-characcter between timestamp "160107 15:47:01" and thread_id "1". Corresponding source code, https://github.com/mysql/mysql-server/blob/5.6/sql/log.cc#L1831 , there's tab-character. At 5.7.10, ``` $ bin/mysqld --no-defaults --general-log $ bin/mysql $ cat data/hostname.log bin/mysqld, Version: 5.7.10-log (Source distribution). started with: Tcp port: 0 Unix socket: (null) Time Id Command Argument 2016-01-07T06:46:08.375273Z 2 Connect root@localhost on using Socket 2016-01-07T06:46:08.375529Z 2 Query select @@version_comment limit 1 $ od -c data/hostname.log 0000000 b i n / m y s q l d , V e r s 0000020 i o n : 5 . 7 . 1 0 - l o g 0000040 ( S o u r c e d i s t r i b u 0000060 t i o n ) . s t a r t e d w 0000100 i t h : \n T c p p o r t : 0 0000120 U n i x s o c k e t : ( 0000140 n u l l ) \n T i m e 0000160 I d C o 0000200 m m a n d A r g u m e n 0000220 t \n 2 0 1 6 - 0 1 - 0 7 T 0 6 : 0000240 4 6 : 0 8 . 3 7 5 2 7 3 Z 0000260 2 C o n n e c t \t r o o t @ 0000300 l o c a l h o s t o n u s 0000320 i n g S o c k e t \n 2 0 1 6 - 0000340 0 1 - 0 7 T 0 6 : 4 6 : 0 8 . 3 0000360 7 5 5 2 9 Z 2 Q u e r 0000400 y \t s e l e c t @ @ v e r s i 0000420 o n _ c o m m e n t l i m i t 0000440 1 \n 0000443 ``` There're only some space-character between "2016-01-07T06:46:08.375273Z" and "2". Corresponding source code, https://github.com/mysql/mysql-server/blob/5.7/sql/log.cc#L681-L687 , there's no tab-character. Suggested fix: Add tab-character between them like 5.6's general log. See attached patch.