All pages
Powered by GitBook
1 of 1

Loading...

SQL Error Log Plugin

The SQL_ERROR_LOG plugin collects errors sent to clients in a log file defined by sql_error_log_filename, so that they can later be analyzed. The log file can be rotated if sql_error_log_rotate is set.

Errors are logged as they happen and an error will be logged even if it was handled by a condition handler and was never technically sent to the client.

From warnings can also be logged if sql_error_log_warnings is enabled.

Comments are also logged, which can make the log easier to search. But this is only possible if the client does not strip the comments away. For example, the mariadb command-line client only leaves comments when started with the --comments option.

Installing the Plugin

Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.

The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or . For example:

The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an . For example:

Uninstalling the Plugin

You can uninstall the plugin dynamically by executing or . For example:

If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.

Logging

The log format until is:

Starting from , the format is:

Starting from , , , , , , and , when the variable is enabled, the log also contains thread id and database name. If there is no database, NULL will be displayed.

Each separated by a space or : as above

Option
Description
Version

Example of Logs

With enabled (database test and thread id 4):

Example Usage

Versions

Version
Status
Introduced

System Variables and Options

This page is licensed: CC BY-SA / Gnu FDL

Type

ERROR or WARNING

10.11.6

Error_code

OS error, MariaDB storage engine code (120-199) or MariaDB internal error code (1000-)

5.5.22

Query

Query text

5.5.22

sql_error_log_rotations
  • sql_error_log_size_limit

  • sql_error_log_size_warnings

  • sql_error_log_with_db_and_thread_info

  • Time

    Time (YYYY-MM-DD hh-mm-ss)

    5.5.22

    Thread Id

    Thread Id of current thread

    10.6.17

    User

    privilege_user [login_user_name] @ hostname [ip]

    5.5.22

    Database name

    Name of the currently selected database

    10.6.17

    1.1

    Stable

    , , , ,

    1.0

    Stable

    1.0

    Gamma

    1.0

    Alpha

    INSTALL SONAME
    INSTALL PLUGIN
    --plugin-load
    --plugin-load-add
    mariadbd
    option group
    option file
    UNINSTALL SONAME
    UNINSTALL PLUGIN
    --plugin-load
    --plugin-load-add
    option group
    option file
    MariaDB 10.11
    sql_error_log_with_db_and_thread_info
    sql_error_log_with_db_and_thread_info
    sql_error_log
    sql_error_log_filename
    sql_error_log_rate
    sql_error_log_rotate
    INSTALL SONAME 'sql_errlog';
    [mariadb]
    ...
    plugin_load_add = sql_errlog
    UNINSTALL SONAME 'sql_errlog';
    Time User Error_code: Error_message : Query
    Time User Type Error_code: Error_message : Query
    Time Thread_id User Database_name Type Error_code: Error_message : Query
    2023-10-31 15:54:37 root[root] @ localhost [] ERROR 1146: Table 'test.t_doesnt_exist' doesn't exist : select * from t_doesnt_exist
    2023-10-31 15:54:37 root[root] @ localhost [] ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'syntax_error_query' at line 1 : syntax_error_query
    2023-10-31 15:54:37 root[root] @ localhost [] ERROR 1146: Table 'test.temptab' doesn't exist : SELECT `c` FROM `temptab`
    2023-11-01 11:31:15 [monty] @ storm [192.168.0.12] ERROR 1051: Unknown table 'test.t1' : drop table t1
    2023-10-31 15:54:37 4 root[root] @ localhost [] `test` ERROR 1146: Table 'test.t_doesnt_exist' doesn't exist : select * from t_doesnt_exist
    install plugin SQL_ERROR_LOG soname 'sql_errlog';
    Query OK, 0 rows affected (0.00 sec)
    
    USE test;
    
    SET sql_mode='STRICT_ALL_TABLES,NO_ENGINE_SUBSTITUTION';
    Query OK, 0 rows affected (0.00 sec)
    
    CREATE TABLE foo2 (id INT) ENGINE=WHOOPSIE;
    ERROR 1286 (42000): Unknown storage engine 'WHOOPSIE'
    \! cat data/sql_errors.log
    2013-03-19  9:38:40 msandbox[msandbox] @ localhost [] ERROR 1286: Unknown storage engine 'WHOOPSIE' : CREATE TABLE foo2 (id int) ENGINE=WHOOPSIE
    MariaDB 10.11.5
    MariaDB 10.10
    MariaDB 10.6.17
    MariaDB 10.11.7
    MariaDB 11.0.5
    MariaDB 11.1.4
    MariaDB 11.2.3
    MariaDB 11.3.2
    MariaDB 11.4.1
    MariaDB 10.6.17
    MariaDB 10.11.7
    MariaDB 11.0.5
    MariaDB 11.1.4
    MariaDB 11.2.3
    MariaDB 10.1.13
    MariaDB 10.0.10
    MariaDB 5.5.22