diff options
author | Anel Husakovic <anel@mariadb.org> | 2021-01-20 21:59:51 +0100 |
---|---|---|
committer | Anel Husakovic <anel@mariadb.org> | 2021-01-28 19:01:32 +0100 |
commit | 85130c5a4ff4cc3854192bf7945cb10087d860a2 (patch) | |
tree | d7ddbee62447c30529272645850c87d756c5d577 /mysql-test/main | |
parent | 6d1f1b61b59310027698a92ccf533a3093f1ce04 (diff) | |
download | mariadb-git-85130c5a4ff4cc3854192bf7945cb10087d860a2.tar.gz |
MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so is needed and load it
a. The change makes `mariadb-upgrade` detect if `MYSQL_JSON` data type is needed.
b. Install the data type if it's not installed.
c. Uninstalls the data type once finished.
d. Create `.opt` and `.inc` files `have_type_mysql_json` and adapt the
tests
Reviewed by: vicentiu@mariadb.org
Diffstat (limited to 'mysql-test/main')
7 files changed, 362 insertions, 13 deletions
diff --git a/mysql-test/main/mysql_json_mysql_upgrade.result b/mysql-test/main/mysql_json_mysql_upgrade.result new file mode 100644 index 00000000000..05863bb3591 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade.result @@ -0,0 +1,198 @@ +# +# MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +# is needed and load it +# +SET NAMES utf8; +show create table mysql_json_test; +ERROR HY000: Unknown data type: 'MYSQL_JSON' +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt + +Repairing tables +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/7: Installing used storage engines... Skipped +installing plugin for MYSQL_JSON data type +Phase 3/7: Fixing views +mysql.user OK +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names +Phase 6/7: Checking and upgrading tables +Processing databases +information_schema +mtr +mtr.global_suppressions OK +mtr.test_suppressions OK +performance_schema +test +test.mysql_json_test Needs upgrade +test.mysql_json_test_big Needs upgrade + +Repairing tables +test.mysql_json_test OK +test.mysql_json_test_big OK +uninstalling plugin for 'type_mysql_json' data type +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql_json_test; +description expected actual +Raw integers as JSON 0 0 +Raw integers as JSON -127 -127 +Raw integers as JSON 128 128 +Raw integers as JSON 32767 32767 +Raw integers as JSON -32768 -32768 +Raw integers as JSON 65535 65535 +Raw integers as JSON 65536 65536 +Raw integers as JSON -2147483648 -2147483648 +Raw integers as JSON 2147483647 2147483647 +Raw integers as JSON 4294967295 4294967295 +Raw integers as JSON -9223372036854775807 -9223372036854775807 +Raw integers as JSON 9223372036854775807 9223372036854775807 +Raw integers as JSON 18446744073709551615 18446744073709551615 +Raw doubles as JSON 3.14 3.14 +Raw doubles as JSON -5678.987 -5678.987 +Raw doubles as JSON -2.2250738585072014e-308 -2.2250738585072014e-308 +Raw doubles as JSON 2.2250738585072014e-308 2.2250738585072014e-308 +Simple JSON test {"key1": "val1", "key2": "val2"} {"key1": "val1", "key2": "val2"} +Raw doubles as JSON 0.0 0.0 +Simple Array as Value {"a": [1, 2], "b": ["x", "y"]} {"a": [1, 2], "b": ["x", "y"]} +Simple Array as Base Key [1, 2, 3, 4, 5, [], "a", "b", "c"] [1, 2, 3, 4, 5, [], "a", "b", "c"] +GeoJSON {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} +GeoJSON {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} +GeoJSON {"type": "GeometryCollection", "geometries": []} {"type": "GeometryCollection", "geometries": []} +GeoJSON {"type": "Point", "coordinates": [11.1111, 12.22222]} {"type": "Point", "coordinates": [11.1111, 12.22222]} +Opaque Types: opaque_mysql_type_set "b,c" "b,c" +Opaque Types: opaque_mysql_type_enum "b" "b" +Opaque Types: opaque_mysql_type_date "2015-01-15" "2015-01-15" +Opaque Types: opaque_mysql_type_time "23:24:25.000000" "23:24:25.000000" +Opaque Types: opaque_mysql_type_datetime "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +Opaque Types: opaque_mysql_type_geom {"type": "Point", "coordinates": [1, 1]} {"type": "Point", "coordinates": [1, 1]} +Opaque Types: opaque_mysql_type_bit "base64:type16:yv4=" "base64:type16:yv4=" +Opaque Types: opaque_mysql_type_year "base64:type13:MjAxOQ==" "base64:type13:MjAxOQ==" +Opaque Types: opaque_mysql_type_blob "base64:type252:yv66vg==" "base64:type252:yv66vg==" +Opaque Types: opaque_mysql_type_longblob "base64:type251:yv66vg==" "base64:type251:yv66vg==" +Opaque Types: opaque_mysql_type_mediumblob "base64:type250:yv66vg==" "base64:type250:yv66vg==" +Opaque Types: opaque_mysql_type_tinyblob "base64:type249:yv66vg==" "base64:type249:yv66vg==" +Opaque Types: opaque_mysql_type_varchar "base64:type15:Zm9v" "base64:type15:Zm9v" +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +Opaque Types: opaque_mysql_type_varbinary "base64:type15:YWJj" "base64:type15:YWJj" +Opaque Types: opaque_mysql_type_binary "base64:type254:YWJjAAAAAAAAAA==" "base64:type254:YWJjAAAAAAAAAA==" +DateTime as Raw Value: "23:24:25.000000" "23:24:25.000000" +DateTime as Raw Value: "2015-01-15" "2015-01-15" +DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000" +UTF8 Characters: {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćč"}} {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćč"}} +UTF8 Characters: "Anel Husaković - test: đžšćč" "Anel Husaković - test: đžšćč" +UTF8 Characters: {"Name": "Anel Husaković - test: đžšćč"} {"Name": "Anel Husaković - test: đžšćč"} +UTF8 Characters: {"details": {"Name": "Anel Husaković - test: đžšćč"}, "\"Anel Husaković - test: đžšćč\"": "EMP"} {"details": {"Name": "Anel Husaković - test: đžšćč"}, "\"Anel Husaković - test: đžšćč\"": "EMP"} +Special Characters: {"{": "}"} {"{": "}"} +Special Characters: "key1 - with \" val " "key1 - with \" val " +Special Characters: {"key1 and \n\"key2\"": "val1\t val2"} {"key1 and \n\"key2\"": "val1\t val2"} +Special Characters: "'" "'" +Special Characters: "q" "q" +Special Characters: {"[": "]"} {"[": "]"} +Special Characters: {"{": "}"} {"{": "}"} +Empty JSON Object/Array: [] [] +Special Characters: "some_string" "some_string" +Special Characters: "'" "'" +Special Characters: "\"" "\"" +Special Characters: "" "" +Special Characters: "'" "'" +Special Characters: "''" "''" +Empty JSON Object/Array: {} {} +Special Characters: "f" "f" +Special Characters: "\\" "\\" +Special Characters: "\n" "\n" +Special Characters: "\f" "\f" +Special Characters: "\t" "\t" +Special Characters: "\r" "\r" +Special Characters: "\b" "\b" +Special Characters: "\\b" "\\b" +Special Characters: {"key \n key": "val \n val"} {"key \n key": "val \n val"} +Special Characters: {"key \f key": "val \f val"} {"key \f key": "val \f val"} +Special Characters: {"key \t key": "val \t val"} {"key \t key": "val \t val"} +Special Characters: {"key \r key": "val \r val"} {"key \r key": "val \r val"} +Special Characters: {"key \b key": "val \b val"} {"key \b key": "val \b val"} +Special Characters: {"key \\0 key": "val \n val"} {"key \\0 key": "val \n val"} +Special Characters: {"key \\ key": "val \\ val"} {"key \\ key": "val \\ val"} +Special Characters: {"key \" key": "val \" val"} {"key \" key": "val \" val"} +Special Characters: {"key ' key": "val ' val"} {"key ' key": "val ' val"} +Special Characters: {"key \\Z key": "val ' val"} {"key \\Z key": "val ' val"} +Special Characters: ["a \f b", "c \f d"] ["a \f b", "c \f d"] +Special Characters: ["a \t b", "c \t d"] ["a \t b", "c \t d"] +Special Characters: ["a \r b", "c \r d"] ["a \r b", "c \r d"] +Special Characters: ["a \b b", "c \b d"] ["a \b b", "c \b d"] +Special Characters: ["a \\ b", "c \\ d"] ["a \\ b", "c \\ d"] +Special Characters: ["a \" b", "c \" d"] ["a \" b", "c \" d"] +Special Characters: ["a ' b", "c ' d"] ["a ' b", "c ' d"] +Special String Cases: {"": ""} {"": ""} +Special String Cases: [""] [""] +Raw LITERALS: true true +Raw LITERALS: false false +Raw LITERALS: null null +JSON LITERALS: {"val": true} {"val": true} +JSON LITERALS: {"val": false} {"val": false} +JSON LITERALS: {"val": null} {"val": null} +Timestamp as RawValue "2019-12-26 19:56:03.000000" "2019-12-26 19:56:03.000000" +Array LITERALS: ["prefix", null, "suffix", 1] ["prefix", null, "suffix", 1] +Array LITERALS: ["prefix", false, "suffix", 1] ["prefix", false, "suffix", 1] +Array LITERALS: ["prefix", true, "suffix", 1] ["prefix", true, "suffix", 1] +show create table mysql_json_test_big; +Table Create Table +mysql_json_test_big CREATE TABLE `mysql_json_test_big` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql.plugin; +name dl +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade.test b/mysql-test/main/mysql_json_mysql_upgrade.test new file mode 100644 index 00000000000..20f8ae588b7 --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade.test @@ -0,0 +1,32 @@ +--echo # +--echo # MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +--echo # is needed and load it +--echo # + +-- source include/have_utf8.inc +-- source include/mysql_upgrade_preparation.inc + +SET NAMES utf8; + +let $MYSQLD_DATADIR= `select @@datadir`; + +--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 + +--error ER_UNKNOWN_DATA_TYPE +show create table mysql_json_test; + +--exec $MYSQL_UPGRADE --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +show create table mysql_json_test; +select * from mysql_json_test; +show create table mysql_json_test_big; +select * from mysql.plugin; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result new file mode 100644 index 00000000000..0b2e7af84eb --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.result @@ -0,0 +1,95 @@ +# +# MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +# is needed and load it +# +SET NAMES utf8; +call mtr.add_suppression("Table rebuild required"); +show create table mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +Phase 1/7: Checking and upgrading mysql database +Processing databases +mysql +mysql.column_stats OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.global_priv OK +mysql.gtid_slave_pos OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.index_stats OK +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.proxies_priv OK +mysql.roles_mapping OK +mysql.servers OK +mysql.table_stats OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt + +Repairing tables +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +Phase 2/7: Installing used storage engines... Skipped +Phase 3/7: Fixing views +mysql.user OK +Phase 4/7: Running 'mysql_fix_privilege_tables' +Phase 5/7: Fixing table and database names +Phase 6/7: Checking and upgrading tables +Processing databases +information_schema +mtr +mtr.global_suppressions OK +mtr.test_suppressions OK +performance_schema +test +test.mysql_json_test Needs upgrade +test.mysql_json_test_big Needs upgrade + +Repairing tables +test.mysql_json_test OK +test.mysql_json_test_big OK +Phase 7/7: Running 'FLUSH PRIVILEGES' +OK +show create table mysql_json_test; +Table Create Table +mysql_json_test CREATE TABLE `mysql_json_test` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +show create table mysql_json_test_big; +Table Create Table +mysql_json_test_big CREATE TABLE `mysql_json_test_big` ( + `description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +select * from mysql.plugin; +name dl +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test new file mode 100644 index 00000000000..f3e9c2e539a --- /dev/null +++ b/mysql-test/main/mysql_json_mysql_upgrade_with_plugin_loaded.test @@ -0,0 +1,35 @@ +--echo # +--echo # MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so +--echo # is needed and load it +--echo # +# Let's now load plugin first +-- source include/have_utf8.inc +-- source include/have_type_mysql_json.inc +-- source include/mysql_upgrade_preparation.inc + +SET NAMES utf8; +call mtr.add_suppression("Table rebuild required"); + +let $MYSQLD_DATADIR= `select @@datadir`; + +--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 + +# In the previous example (mysql_json_mysql_upgrade.test) +# instead of ER_TABLE_NEEDS_REBUILD we had ER_UNKNOWN_DATA_TYPE +--error ER_TABLE_NEEDS_REBUILD +show create table mysql_json_test; + +--exec $MYSQL_UPGRADE --force 2>&1 +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +show create table mysql_json_test; +show create table mysql_json_test_big; +select * from mysql.plugin; +drop table mysql_json_test; +drop table mysql_json_test_big; diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test index de1e9202985..a399b546591 100644 --- a/mysql-test/main/mysql_json_table_recreate.test +++ b/mysql-test/main/mysql_json_table_recreate.test @@ -1,8 +1,5 @@ --source include/have_utf8.inc - -if (!$TYPE_MYSQL_JSON_SO) { - skip Need MYSQL_JSON plugin; -} +--source include/have_type_mysql_json.inc --echo # --echo # The following test takes 2 tables containing a JSON column and attempts diff --git a/mysql-test/main/mysql_upgrade_mysql_json_datatype.result b/mysql-test/main/mysql_upgrade_mysql_json_datatype.result index 604ef2bc0df..25bc70c9074 100644 --- a/mysql-test/main/mysql_upgrade_mysql_json_datatype.result +++ b/mysql-test/main/mysql_upgrade_mysql_json_datatype.result @@ -3,7 +3,6 @@ call mtr.add_suppression("is marked as crashed"); call mtr.add_suppression("Checking"); SET NAMES utf8; set sql_mode=""; -install soname 'type_mysql_json'; show create table tempty; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! show create table mysql_json_test; @@ -103,4 +102,3 @@ Total_Number_of_Tests Succesful_Tests String_is_valid_JSON drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; -uninstall soname 'type_mysql_json'; diff --git a/mysql-test/main/mysql_upgrade_mysql_json_datatype.test b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test index 0363b2d0dc1..13d8ff5754a 100644 --- a/mysql-test/main/mysql_upgrade_mysql_json_datatype.test +++ b/mysql-test/main/mysql_upgrade_mysql_json_datatype.test @@ -1,10 +1,7 @@ -- source include/mysql_upgrade_preparation.inc -- source include/have_working_dns.inc -- source include/have_innodb.inc - -if (!$TYPE_MYSQL_JSON_SO) { - skip Need MYSQL_JSON plugin; -} +-- source include/have_type_mysql_json.inc call mtr.add_suppression("Table rebuild required"); call mtr.add_suppression("is marked as crashed"); @@ -28,8 +25,6 @@ SET NAMES utf8; set sql_mode=""; -install soname 'type_mysql_json'; - --error ER_TABLE_NEEDS_REBUILD show create table tempty; --error ER_TABLE_NEEDS_REBUILD @@ -63,5 +58,4 @@ drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; -uninstall soname 'type_mysql_json'; --remove_file $MYSQLD_DATADIR/mysql_upgrade_info |