All pages
Powered by GitBook
1 of 1

Loading...

User Variables Plugin

The User Variables plugin adds the USER_VARIABLES table to the Information Schema, allowing users to inspect defined user variables and their values.

The user_variables plugin creates the USER_VARIABLES table in the INFORMATION_SCHEMA database. This table contains information about user-defined variables.

Viewing

User-defined variables can be viewed by either querying the USER_VARIABLES, or by running SHOW USER_VARIABLES.

Flushing User-Defined Variables

User-defined variables are reset and the Information Schema table emptied with the statement.

Examples

Installing the Plugin

In current versions, the user_variables plugin is statically linked into the server by default, so it does not need to be installed.

If it is not installed, however, here 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 :

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 :

Uninstalling the Plugin

You can uninstall the plugin dynamically by executing or :

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.

Options

user_variables

  • Description: Controls how the server should treat the plugin when the server starts up.

    • Valid values are:

      • OFF - Disables the plugin without removing it from the table.

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

ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
  • FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.

  • FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.

  • See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.

  • Command line: --user-variables=value

  • Data Type: enumerated

  • Default Value: ON

  • Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT

  • FLUSH USER_VARIABLES
    INSTALL SONAME
    INSTALL PLUGIN
    --plugin-load
    --plugin-load-add
    mysqld
    option group
    option file
    UNINSTALL SONAME
    UNINSTALL PLUGIN
    --plugin-load
    --plugin-load-add
    option group
    option file
    mysql.plugins
    SET @v1 = 0;
    SET @v2 = 'abc';
    SET @v3 = CAST(123 AS CHAR(5));
    
    SHOW USER_VARIABLES;
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | v3            | 123   |
    | v2            | abc   |
    | v1            | 0     |
    +---------------+-------+
    
    SELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;
    +---------------+----------------+---------------+--------------------+
    | VARIABLE_NAME | VARIABLE_VALUE | VARIABLE_TYPE | CHARACTER_SET_NAME |
    +---------------+----------------+---------------+--------------------+
    | v1            | 0              | INT           | latin1             |
    | v2            | abc            | VARCHAR       | utf8               |
    | v3            | 123            | VARCHAR       | utf8               |
    +---------------+----------------+---------------+--------------------+
    
    FLUSH USER_VARIABLES;
    
    SELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;
    Empty set (0.000 sec)
    INSTALL SONAME 'user_variables';
    [mariadb]
    ...
    plugin_load_add = user_variables
    UNINSTALL SONAME 'user_variables';