revision-id: d9ccaadf1382e257412234916b1cb17cc94c79f8 (mariadb-10.4.5-154-gd9ccaadf138) parent(s): c776ed4d6ecf9a0393a8eb53cd6660ff3eb63758 author: Sachin committer: Sachin timestamp: 2019-08-08 21:20:05 +0530 message: MDEV-18791 Wrong error upon creating Aria table with long index on BLOB If we have long unique key for aria engine return a too long key error --- mysql-test/main/long_unique_bugs.result | 2 ++ mysql-test/main/long_unique_bugs.test | 6 ++++++ storage/maria/ha_maria.cc | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 4e831bcff92..c0921e6cceb 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -271,3 +271,5 @@ drop table t1; CREATE TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM; INSERT DELAYED t1 () VALUES (); DROP TABLE t1; +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; +ERROR 42000: Specified key was too long; max key length is 1000 bytes diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index b9b10b3d6cd..c998f8660da 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -342,3 +342,9 @@ CREATE TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM; INSERT DELAYED t1 () VALUES (); # Cleanup DROP TABLE t1; + +# +# MDEV-18791 Wrong error upon creating Aria table with long index on BLOB +# +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 3edd642462f..ffeeab9e8c7 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -554,6 +554,11 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, if (!table_arg->field[field->field_index]->stored_in_db()) { my_free(*recinfo_out); + if (table_arg->s->long_unique_table) + { + my_error(ER_TOO_LONG_KEY, MYF(0), table_arg->file->max_key_length()); + DBUG_RETURN(HA_ERR_INDEX_COL_TOO_LONG); + } my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0)); DBUG_RETURN(HA_ERR_UNSUPPORTED); }