Internals

MySQL and MariaDB dialects

How one front-end program answers as MySQL 8 or MariaDB 11, what the dialect setting changes, and how differences are found against MySQL and MariaDB.

One raftdb-mysql process speaks one dialect, chosen by the dialect setting (mysql, the default, or mariadb; decision D79). A MariaDB endpoint is another process on another port, the way a MariaDB server is another server. The setting is process-wide and fixed once, before the first client connects.

What the dialect decides#

dialect.rs holds what depends on it:

ItemMySQLMariaDB
Version string8.0.36-Raft DB11.4.13-MariaDB-Raft DB (no 5.5.5- prefix)
Default authentication plugincaching_sha2_passwordmysql_native_password
Default sql_modeincludes ONLY_FULL_GROUP_BYhas no ONLY_FULL_GROUP_BY
Default collationutf8mb4_0900_ai_ciutf8mb4_uca1400_ai_ci
Marker table of the front-end's databases__rdb_mysql__rdb_mariadb

Each front-end lists only the databases it made (D60). The handshake also differs: a client recognises MariaDB when the word mariadb is in the version string or the server does not set the first capability bit (CLIENT_MYSQL), so the MariaDB handshake clears that bit and sends MariaDB's own capabilities in the last four of the ten filler bytes. None of MariaDB's extended capabilities (bulk execution, progress reporting, cached metadata) are offered.

What is dialect-specific in behaviour#

  • Error wording (mariadb.rs): the answer is rewritten on its way out by one table of rules. For example MariaDB says Unknown column 'x' in 'SELECT' or 'ON' where MySQL says field list or on clause, The value '1' is already present for key 'PRIMARY' without the table, and the errors of a value that is not valid for its column (1366, 1292) with SQLSTATE 22007 and the column named with its database and table.
  • SHOW CREATE TABLE and SHOW INDEX: MariaDB writes int(11), numeric defaults as numbers and current_timestamp(), and its SHOW INDEX ends with Ignored where MySQL has Visible and Expression.
  • Statements and functions: MariaDB-only sequences, RETURNING, EXECUTE IMMEDIATE, OFFSET ... FETCH FIRST, VALUES (...) as a statement, UUID, INET4 and INET6 types (D81 to D85); MySQL-only -> and ->> and MEMBER OF (D84).
  • JSON: MySQL refuses a text that is not JSON (error 3141), MariaDB answers NULL; JSON_VALUE differs as the servers do.
  • WITH ROLLUP: MariaDB refuses it with ORDER BY (error 1221); MySQL allows it and answers an empty input with the totals row.
  • System variables: every variable of MySQL and MariaDB, with its default, is in sysvars_mysql.rs (513 variables, MySQL 9.7) and sysvars_mariadb.rs (554 variables, MariaDB 11.4), generated from MySQL and MariaDB servers. Character sets and collations come from real lists: 41 and 286 rows for MySQL 9.7, 40 and 550 for MariaDB 11.4 (D86).

How differences are found#

The reference is a temporary MariaDB server: a script is run on Raft DB as MariaDB and on a real MariaDB 11.4.13 and prints how the answers differ. A second harness extracts the statements of the examples in the MariaDB documentation and runs them one by one on MySQL and on Raft DB. The real MariaDB Connector/J 3.5.6 and the real MariaDB command-line client connect and run scripts.

What still differs and cannot be made the same#

Per D86: the server's identity (VERSION(), @@version_comment, the system schemas mysql, performance_schema and sys), the account names used to log in, the process-dependent name of MySQL's temporary table in a foreign-key error, InnoDB's estimated index cardinality, and the position of one syntax error. Open items named there: SHOW OPEN TABLES, lower_case_table_names, and the system schemas as real databases.

See The MySQL/MariaDB front-end and Decisions D40-D88 in short.