Bug #96773 Request to add "db" field into slowlog when log_slow_extra = ON
Submitted: 6 Sep 2019 1:43 Modified: 6 Sep 2019 6:26
Reporter: Tsubasa Tanaka (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S4 (Feature request)
Version:8.0.17 OS:CentOS (7.6)
Assigned to: CPU Architecture:x86

[6 Sep 2019 1:43] Tsubasa Tanaka
Description:
This is feature request.

MySQL 8.0.17 and earlier only print "db" (means thd->db()) when "db" is changed.
So we have to search previous "USE" statement to recognize "db".

Please add "db" field into slowlog.

How to repeat:
- Current implementation (8.0.17)

# Time: 2019-09-06T10:33:36.860714+09:00
# User@Host: root[root] @ localhost []  Id:    12
# Query_time: 0.002199  Lock_time: 0.001684 Rows_sent: 2  Rows_examined: 12 Thread_id: 12 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 86 Read_first: 1 Read_last: 0 Read_key: 6 Read_next: 3 Read_prev: 0 Read_rnd: 2 Read_rnd_next: 3 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 2 Sort_scan_count: 1 Created_tmp_disk_tables: 0 Created_tmp_tables: 1 Start: 2019-09-06T10:33:36.858515+09:00 End: 2019-09-06T10:33:36.860714+09:00
SET timestamp=1567733616;
show tables;

---

- What we hope (Last field of 3rd line)

# Time: 2019-09-06T10:33:36.860714+09:00
# User@Host: root[root] @ localhost []  Id:    12
# Query_time: 0.002199  Lock_time: 0.001684 Rows_sent: 2  Rows_examined: 12 Thread_id: 12 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 86 Read_first: 1 Read_last: 0 Read_key: 6 Read_next: 3 Read_prev: 0 Read_rnd: 2 Read_rnd_next: 3 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 2 Sort_scan_count: 1 Created_tmp_disk_tables: 0 Created_tmp_tables: 1 Start: 2019-09-06T10:33:36.858515+09:00 End: 2019-09-06T10:33:36.860714+09:00 Db: d1
SET timestamp=1567733616;
show tables;

Suggested fix:
I put a patch later.
[6 Sep 2019 1:44] Tsubasa Tanaka
Patch to add "Db" filed

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug96773.patch (application/octet-stream, text), 279 bytes.

[6 Sep 2019 6:26] MySQL Verification Team
Hello tanaka-San,

Thank you for the reasonable feature request and contribution.

regards,
Umesh