diff --git a/mysql-test/main/vector.result b/mysql-test/main/vector.result index 7ef6b884ea2..5cabd1d9a87 100644 --- a/mysql-test/main/vector.result +++ b/mysql-test/main/vector.result @@ -250,3 +250,16 @@ insert t1 (v) values (x'12345678'); ERROR 22007: Incorrect vector value: '...' for column `test`.`t1`.`v` at row 1 drop table t1; db.opt +# Check if CREATE TABLE ... LIKE inherits VECTOR index +create table t1 (id int auto_increment primary key, v blob not null, vector index (v)); +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `v` blob NOT NULL, + PRIMARY KEY (`id`), + VECTOR KEY `v` (`v`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +drop table t1, t2; +db.opt diff --git a/mysql-test/main/vector.test b/mysql-test/main/vector.test index 95d1a477184..235d806ff82 100644 --- a/mysql-test/main/vector.test +++ b/mysql-test/main/vector.test @@ -74,3 +74,11 @@ insert t1 (v) values (x'12345678'); drop table t1; let $datadir=`select @@datadir`; list_files $datadir/test; + +--echo # Check if CREATE TABLE ... LIKE inherits VECTOR index +create table t1 (id int auto_increment primary key, v blob not null, vector index (v)); +create table t2 like t1; +replace_result InnoDB MyISAM; +show create table t2; +drop table t1, t2; +list_files $datadir/test; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a32b799cd71..f5344257f71 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8734,7 +8734,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, Collect all keys which isn't in drop list. Add only those for which some fields exists. */ - for (uint i=0 ; i < table->s->keys ; i++,key_info++) + for (uint i= 0; i < table->s->total_keys; i++, key_info++) { bool long_hash_key= false; if (key_info->flags & HA_INVISIBLE_KEY)