WackoWiki: SQL Modes Revisited

https://wackowiki.org/doc     Version: 96 (18.10.2024 03:34)

SQL Modes Revisited



The SQL mode settings of MariaDB and MySQL are no longer compatible.

1. Why it requirers SQL modes?


Mode MariaDB MySQL Notes
Server
Session Lax
Session Strict


Server SQL mode

Session SQL mode

Shared hosting

Strict mode

InnoDB

2. WackoWiki settings

constants

const SQL_MODE_LAX = [
	'mariadb'	=> 'NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER',
	'mysql'		=> 'NO_ENGINE_SUBSTITUTION'
];
const SQL_MODE_STRICT	= [
	'mariadb'	=> 'TRADITIONAL,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY',
	'mysql'		=> 'TRADITIONAL,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY'
];	


primary config

If a user transfers his database to another vendor, he must change the db_vendor setting, for example from 'mariadb' to 'mysql' in his config file by hand or during an upgrade in the installer.

Default settings

2.1. Lax or strict


Currently the sql_mode mode is set in the default config file and can only be changed by hand in the config file. Default is set to 0 (server).

This wiki runs in strict mode.

2.2. Installer

With WackoWiki 6.1.26 the installer provides an option in the database settings to select the database vendor, MariaDB or MySQL, before a database connection is established.

This enabels the engine to select specific SQL mode parameters for the selected database vendor.

Another possibility is to disable the SQL mode with debug off and auto-set the db_vendor.

The user no longer has to modify the SQL mode parameters in the constants.php file for MySQL. In an upgrade it will take the necessary values fom the primary config.

2.2.1. Naming / wording and translations

'DbVendor'	=> 'Database vendor',
'DbVendorDesc'	=> 'The database vendor you use.',

'DbSqlMode'	=> 'SQL mode',
'DbSqlModeDesc'	=> 'The SQL mode you want use.',	


3. MySQL derivates

Do we get a valid, reliable and distinct identifier for all the different MySQL derivates?

In regard to the SQL mode Percona server can be treated as MySQL.

4. Patches

  1. adds db_vendor to primary config[link2]
  2. renames sql_mode_strict to sql_mode[link3]
  3. installer auto-detects db_vendor[link4]

5. ToDo


Somehow I'm not quite happy with the current solution.

5.1. Unsolved

5.2. Questions

5.3. Suggestions

6. References