Administration

System variables

How SET, SET GLOBAL and SHOW VARIABLES behave in the SQL front-end, where the default values come from, which variables change behaviour, and what is not persistent.

MySQL clients, drivers and tools read and set server variables at connection time (SELECT @@version_comment, SET autocommit = 1, SET NAMES utf8mb4, SHOW VARIABLES LIKE 'character_set%'). The SQL front-end answers them from tables of defaults taken from MySQL and MariaDB servers.

Where the defaults come from#

raftdb-mysql holds name and default value for each variable of MySQL 9.7 and of MariaDB 11.4. The lists were generated from MySQL 9.7 and MariaDB 11.4 servers, so SHOW VARIABLES lists the names a MySQL server lists and a client that reads a variable gets a value of the right kind. The dialect picks the table (dialect = mysql | mariadb). Some values are the front-end's own: the version (8.0.36-Raft DB or 11.4.13-MariaDB-Raft DB), version_comment, and the default sql_mode of the dialect:

DialectDefault sql_mode
mysqlONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
mariadbSTRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Syntax#

SQL
SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern' | WHERE condition];
SELECT @@name, @@session.name, @@global.name;
SET [SESSION] name = value;
SET GLOBAL name = value;
SET name = DEFAULT;
SET NAMES charset;

Behaviour#

StatementWhat happens
SET name = value (session)Stored for the session. An unknown variable is error 1193 Unknown system variable, except a short list of variables that clients set and that are accepted and stored (net_write_timeout, net_read_timeout, sql_big_selects, max_execution_time, lc_messages, lc_time_names, session_track_schema, wait_timeout, interactive_timeout).
SET GLOBAL name = valueStored in the memory of the front-end process, shared by all its sessions, and read by later @@global.name and new sessions. It is lost when the process stops: nothing is written to disk. A bootstrap administrator (a user of the configuration) may do it; another account needs the SUPER privilege (error 1227 otherwise).
SET PERSIST, SET PERSIST_ONLYRefused with error 1235. Put the setting in the configuration file where one exists.
SET name = DEFAULTBack to the global value (or the default).
SET NAMES csSets character_set_client, character_set_connection and character_set_results.
SET TRANSACTION ISOLATION LEVEL ...Accepted and ignored: there is one level. @@transaction_isolation reports READ-COMMITTED (per table, see Consistency guarantees).
SET autocommit = 0 or 1Takes effect (see Transactions).

Variables that change behaviour#

Most variables are stored and reported and change nothing. The ones the code reads, so far as a search of the sources shows, are:

VariableEffect
sql_modeStrictness (STRICT_TRANS_TABLES, STRICT_ALL_TABLES, TRADITIONAL: an invalid value is an error rather than a truncation), zero dates (NO_ZERO_DATE, NO_ZERO_IN_DATE), and ONLY_FULL_GROUP_BY (a select list that mixes grouped and ungrouped columns is refused). The value is normalised: empty entries and spaces are dropped. A stored routine or trigger remembers the sql_mode it was created with. The non-strict mode is checked.
autocommitTransaction behaviour.
max_sp_recursion_depthHow deep a stored procedure may call itself (0 by default: recursion refused).
foreign_key_checksSwitches foreign-key checking.
div_precision_incrementScale of decimal division.
character_set_*, collation_*Reported; the comparison is the case-insensitive default collation whichever is set; a binary or case-sensitive COLLATE is refused.

If an application's behaviour depends on another variable, test that it changes something.

Examples#

SQL
SELECT @@version_comment, @@autocommit, @@sql_mode;
SHOW VARIABLES LIKE 'character_set%';
SET sql_mode = '';
SET GLOBAL max_sp_recursion_depth = 10;

(The first two were checked against MySQL and MariaDB.)

What raftdb-server calls "settings"#

The server's own settings (raftdb-server --print-config) are not system variables; they are set in the file, environment or command line and need a restart. See Configuration reference.

See also#