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:
| Item | MySQL | MariaDB |
|---|---|---|
| Version string | 8.0.36-Raft DB | 11.4.13-MariaDB-Raft DB (no 5.5.5- prefix) |
| Default authentication plugin | caching_sha2_password | mysql_native_password |
Default sql_mode | includes ONLY_FULL_GROUP_BY | has no ONLY_FULL_GROUP_BY |
| Default collation | utf8mb4_0900_ai_ci | utf8mb4_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 saysUnknown column 'x' in 'SELECT'or'ON'where MySQL saysfield listoron 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 TABLEandSHOW INDEX: MariaDB writesint(11), numeric defaults as numbers andcurrent_timestamp(), and itsSHOW INDEXends withIgnoredwhere MySQL hasVisibleandExpression.- Statements and functions: MariaDB-only sequences,
RETURNING,EXECUTE IMMEDIATE,OFFSET ... FETCH FIRST,VALUES (...)as a statement,UUID,INET4andINET6types (D81 to D85); MySQL-only->and->>andMEMBER OF(D84). - JSON: MySQL refuses a text that is not JSON (error 3141), MariaDB answers
NULL;JSON_VALUEdiffers as the servers do. WITH ROLLUP: MariaDB refuses it withORDER 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) andsysvars_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.