diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2020-10-15 18:02:24 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2020-10-28 11:38:14 +0200 |
commit | f6549e95448e5cce52336361f5a59d1edcdac46a (patch) | |
tree | bd1d306e99911ed3bbddf139e8ed464bc4f3d196 /mysql-test/main/mysql_upgrade_mysql_json_datatype.test | |
parent | 85c686e2d1576b0be6daf11849167bb1c38e3603 (diff) | |
download | mariadb-git-f6549e95448e5cce52336361f5a59d1edcdac46a.tar.gz |
MDEV-18323 Convert MySQL JSON type to MariaDB TEXT in mysql_upgrade
This patch solves two key problems.
1. There is a type number clash between MySQL and MariaDB. The number
245, used for MariaDB Virtual Fields is the same as MySQL's JSON.
This leads to corrupt FRM errors if unhandled. The code properly
checks frm table version number and if it matches 5.7+ (until 10.0+)
it will assume it is dealing with a MySQL table with the JSON
datatype.
2. MySQL JSON datatype uses a proprietary format to pack JSON data. The
patch introduces a datatype plugin which parses the format and convers
it to its string representation.
The intended conversion path is to only use the JSON datatype within
ALTER TABLE <table> FORCE, to force a table recreate. This happens
during mysql_upgrade or via a direct ALTER TABLE <table> FORCE.
Diffstat (limited to 'mysql-test/main/mysql_upgrade_mysql_json_datatype.test')
-rw-r--r-- | mysql-test/main/mysql_upgrade_mysql_json_datatype.test | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/mysql-test/main/mysql_upgrade_mysql_json_datatype.test b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test new file mode 100644 index 00000000000..0b5b07f233a --- /dev/null +++ b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test @@ -0,0 +1,63 @@ +-- source include/mysql_upgrade_preparation.inc +-- source include/have_working_dns.inc +-- source include/have_innodb.inc + +call mtr.add_suppression("Table rebuild required"); +call mtr.add_suppression("is marked as crashed"); +call mtr.add_suppression("Checking"); + +let $MYSQLD_DATADIR= `select @@datadir`; +SET NAMES utf8; + +--copy_file std_data/mysql_json/tempty.frm $MYSQLD_DATADIR/test/tempty.frm +--copy_file std_data/mysql_json/tempty.MYI $MYSQLD_DATADIR/test/tempty.MYI +--copy_file std_data/mysql_json/tempty.MYD $MYSQLD_DATADIR/test/tempty.MYD + +--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm +--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI +--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD + +--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm +--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI +--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD + + +set sql_mode=""; + +--eval install soname '$TYPE_MYSQL_JSON_SO' + +--error ER_TABLE_NEEDS_REBUILD +show create table tempty; +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test; +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test_big; + +--echo # Run mysql_upgrade to fix the tables containing JSON. +--exec $MYSQL_UPGRADE --force 2>&1 + +--echo # +--echo # Now check if the table structure is correct and that the data +--echo # is still present. +--echo # + +show create table tempty; +show create table mysql_json_test; +show create table mysql_json_test_big; + +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test; + +select count(*) as 'Total_Number_of_Tests', +sum(expected = actual) as 'Succesful_Tests', +sum(JSON_VALID(actual)) as 'String_is_valid_JSON' +from mysql_json_test_big; + +drop table tempty; +drop table mysql_json_test; +drop table mysql_json_test_big; + +--eval uninstall soname '$TYPE_MYSQL_JSON_SO' +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info |