Skip to content

Commit

Permalink
MDEV-22683: Ensure system tables are correctly upgraded in MariaDB 10.4
Browse files Browse the repository at this point in the history
Running mysql_upgrade should end up with the exact same system tables as fresh
installations have after running mysql_install_db. To ensure the upgrade is
correct and complete:

- Remove the redundant modification of thread_id`. On 5.5 version, the
  `general_log` table was created as `CREATE TABLE IF NOT EXISTS general_log
  (..., thread_id INTEGER NOT NULL, ...)`, and starting from 10.0+, the table is
  created as `CREATE TABLE IF NOT EXISTS general_log (..., thread_id BIGINT(21)
  UNSIGNED NOT NULL, ...)`, but mysql_upgrade is not properly upgrading the
  table. It modifies the `thread_id` twice in one query, which could leave the
  table not modified and lead to other potential error when upgrading from
  MariaDB 5.5 or older.

- Update `servers` to ensure `Host` and `User` has correct data type if
  upgrading from 10.1 or older. On versions 10.0 and 10.1, the `servers` table
  was created as `CREATE TABLE IF NOT EXISTS servers (..., Host char(64) NOT
  NULL DEFAULT , ..., Owner char(64) NOT NULL DEFAULT , ...)`, and starting
  from 10.2, the table is created as `CREATE TABLE IF NOT EXISTS servers (...,
  Host varchar(2048) NOT NULL DEFAULT , ..., Owner varchar(512) NOT NULL
  DEFAULT , ...)`.

All new code of the whole pull request, including one or several files that
are either new files or modified ones, are contributed under the BSD-new license.
I am contributing on behalf of my employer Amazon Web Services, Inc.
  • Loading branch information
lornacluo authored and grooverdan committed Mar 1, 2023
1 parent 965bdf3 commit acfb5df
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mysql-test/main/system_mysql_db_fix50030.result
Expand Up @@ -166,14 +166,14 @@ show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '',
`Host` char(64) NOT NULL DEFAULT '',
`Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/system_mysql_db_fix50117.result
Expand Up @@ -146,14 +146,14 @@ show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '',
`Host` char(64) NOT NULL DEFAULT '',
`Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Expand Down

0 comments on commit acfb5df

Please sign in to comment.