It already has the database field, it is called db in the log table and Schema in the log file (I'm not sure which of them you are talking about).
Naturally, it is populated with the current default database name, if any; but it's the only important one, because if you don't have a current database or you are using tables from different ones, table names will be fully qualified anyway.
MariaDB [(none)]> create database test;
|
Query OK, 1 row affected (0.000 sec)
|
|
MariaDB [(none)]> use test;
|
Database changed
|
MariaDB [test]> set long_query_time=0.1;
|
Query OK, 0 rows affected (0.000 sec)
|
|
MariaDB [test]> create table t1 as select sleep(0.5);
|
Query OK, 1 row affected (0.805 sec)
|
Records: 1 Duplicates: 0 Warnings: 0
|
log table
|
start_time: 2020-01-13 15:43:02.474999
|
user_host: root[root] @ localhost [::1]
|
query_time: 00:00:00.804504
|
lock_time: 00:00:00.204743
|
rows_sent: 0
|
rows_examined: 0
|
db: test
|
last_insert_id: 0
|
insert_id: 0
|
server_id: 1
|
sql_text: create table t1 as select sleep(0.5)
|
thread_id: 41
|
rows_affected: 1
|
log file
|
# Time: 200113 15:43:02
|
# User@Host: root[root] @ localhost [::1]
|
# Thread_id: 41 Schema: test QC_hit: No
|
# Query_time: 0.804504 Lock_time: 0.204743 Rows_sent: 0 Rows_examined: 0
|
# Rows_affected: 1 Bytes_sent: 50
|
use test;
|
SET timestamp=1578922982;
|
create table t1 as select sleep(0.5);
|
It already has the database field, it is called db in the log table and Schema in the log file (I'm not sure which of them you are talking about).
Naturally, it is populated with the current default database name, if any; but it's the only important one, because if you don't have a current database or you are using tables from different ones, table names will be fully qualified anyway.
Query OK, 1 row affected (0.000 sec)
Query OK, 1 row affected (0.805 sec)
Records: 1 Duplicates: 0 Warnings: 0
log table
start_time: 2020-01-13 15:43:02.474999
user_host: root[root] @ localhost [::1]
query_time: 00:00:00.804504
lock_time: 00:00:00.204743
rows_sent: 0
rows_examined: 0
db: test
last_insert_id: 0
insert_id: 0
server_id: 1
sql_text: create table t1 as select sleep(0.5)
thread_id: 41
rows_affected: 1
log file
# Time: 200113 15:43:02
# User@Host: root[root] @ localhost [::1]
# Thread_id: 41 Schema: test QC_hit: No
# Query_time: 0.804504 Lock_time: 0.204743 Rows_sent: 0 Rows_examined: 0
# Rows_affected: 1 Bytes_sent: 50
use test;
SET timestamp=1578922982;
create table t1 as select sleep(0.5);