summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/mysql_json_table_recreate.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/main/mysql_json_table_recreate.test')
-rw-r--r--mysql-test/main/mysql_json_table_recreate.test73
1 files changed, 73 insertions, 0 deletions
diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test
index a399b546..a6f1d319 100644
--- a/mysql-test/main/mysql_json_table_recreate.test
+++ b/mysql-test/main/mysql_json_table_recreate.test
@@ -52,6 +52,13 @@ show create table mysql_json_test;
select * from mysql_json_test;
--error ER_TABLE_NEEDS_REBUILD
+CREATE TABLE t2 AS SELECT * FROM mysql_json_test;
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE TABLE t2 (a mysql_json /*new column*/) AS SELECT * FROM mysql_json_test;
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE TABLE t2 (actual mysql_json /*existing column*/) AS SELECT * FROM mysql_json_test;
+
+--error ER_TABLE_NEEDS_REBUILD
LOCK TABLES mysql_json_test WRITE;
alter table mysql_json_test force;
@@ -88,3 +95,69 @@ from mysql_json_test_big;
drop table tempty;
drop table mysql_json_test;
drop table mysql_json_test_big;
+
+--echo #
+--echo # MDEV-32790: Output result in show create table
+--echo # for mysql_json type should be longtext
+--echo #
+
+create table t1(j json);
+show create table t1;
+drop table t1;
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+create table t1(j mysql_json);
+# `json` type should not have character set and collation other than utf8mb4_bin
+--error ER_PARSE_ERROR
+create table `testjson` (
+ `t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
+
+# By removing character set from `json` field query should work and
+# expand to `longtext` with characterset
+create table `testjson` (
+ `t` json /* JSON from MySQL 5.7*/ COLLATE utf8mb4_bin NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
+show create table testjson;
+drop table testjson;
+
+# `longtext` that is alias can have character set
+create table `testjson` (
+ `t` longtext /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
+show create table testjson;
+drop table testjson;
+
+--echo #
+--echo # MDEV-32235: mysql_json cannot be used on newly created table
+--echo #
+
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE TABLE t(j mysql_json);
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE TABLE IF NOT EXISTS t(j mysql_json);
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE OR REPLACE TABLE t(j mysql_json);
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE TEMPORARY TABLE t(j mysql_json);
+
+CREATE TABLE t1 (a TEXT);
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+ALTER TABLE t1 MODIFY a mysql_json;
+DROP TABLE t1;
+
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE FUNCTION f1() RETURNS mysql_json RETURN NULL;
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE FUNCTION f1(a mysql_json) RETURNS INT RETURN 0;
+DELIMITER $$;
+--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE a mysql_json;
+END;
+$$
+DELIMITER ;$$
+
+--echo #
+--echo # End of 10.5 tests
+--echo #