summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnel Husakovic <anel@mariadb.org>2019-04-24 03:21:08 -0700
committerAnel Husakovic <anel@mariadb.org>2019-04-30 02:29:55 -0700
commitd0ace9f6804e165547ea8917d8fd9d215c6fdb29 (patch)
treeacf0f54dbbc6418417a924e857d8d9210650286c
parentfdfe45c3b315991a29b813f4053b1fd904b0b23c (diff)
downloadmariadb-git-bb-10.3-anel-MDEV18323.tar.gz
Enable reading Mysql json type only for alter forcebb-10.3-anel-MDEV18323
- Used ALTER_RECREATE flag from lex - Added test case - Problem: changed .frm file with alter force HOW and WHY ?
-rw-r--r--mysql-test/main/mysql_json_2.test43
-rw-r--r--sql/table.cc4
2 files changed, 45 insertions, 2 deletions
diff --git a/mysql-test/main/mysql_json_2.test b/mysql-test/main/mysql_json_2.test
new file mode 100644
index 00000000000..e2d8395c13c
--- /dev/null
+++ b/mysql-test/main/mysql_json_2.test
@@ -0,0 +1,43 @@
+--echo #
+--echo # MDEV-18323: Convert MySQL JSON type to MariaDB TEXT in mysql_upgrade
+--echo # Test 2 (field treated as a blob):
+--echo # Can read .frm file from mysql table containg the json data,
+--echo # but is not well structured
+--echo #
+
+let $datadir=`select @@datadir`;
+
+#drop table if exists mysql_json;
+
+# Make sure you have placed `json.[frm/myd/myi]` files in `source/mysql-test/std_data/`
+--copy_file std_data/json.frm $datadir/test/mysql_json.frm
+--copy_file std_data/json.MYI $datadir/test/mysql_json.MYI
+--copy_file std_data/json.MYD $datadir/test/mysql_json.MYD
+
+--error ER_TABLE_NEEDS_REBUILD
+select * from test.mysql_json;
+--error ER_TABLE_NEEDS_REBUILD
+alter table test.mysql_json;
+alter table test.mysql_json force;
+select * from test.mysql_json;
+
+# We cannot read now
+#--error ER_TABLE_NEEDS_REBUILD
+#select * from test.mysql_json;
+
+# Create other table to test other data types
+--copy_file std_data/t1.frm $datadir/test/t1.frm
+--copy_file std_data/t1.MYI $datadir/test/t1.MYI
+--copy_file std_data/t1.MYD $datadir/test/t1.MYD
+
+# We cannot read now
+#--error ER_TABLE_NEEDS_REBUILD
+#select * from test.t1;
+
+--echo # Extend `Alter table <table_name> force ` @todo
+#alter table test.t1 force;
+# Now should be able to read data as mariadb table
+#select * from test.t1;
+
+drop table mysql_json;
+drop table t1;
diff --git a/sql/table.cc b/sql/table.cc
index 74eae05c097..00b949b4d67 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1864,9 +1864,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
share->mysql_version < 100000 &&
strpos[13] == (uchar) MYSQL_TYPE_VIRTUAL)
{
- if(!(thd->open_options & HA_OPEN_FOR_ALTER))
+ if(!(thd->lex->alter_info.flags == ALTER_RECREATE))
{
- // Raise an error
+ // Raise an error for every operation expect `alter table <table_name> force`
mysql_table_to_upgrade=1;
goto err;
}