Skip to content

Commit 0bd01f4

Browse files
committed
MDEV-35039 Number of indexes inside InnoDB differs from that defined in MariaDB after altering table with vector key
don't show table->s->total_keys to engine in inplace alter
1 parent 8253650 commit 0bd01f4

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

mysql-test/main/vector_innodb.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@ select pk,hex(v) from t;
103103
pk hex(v)
104104
1 B047263C9F87233FCFD27E3EAE493E3F0329F43E
105105
drop table t;
106+
#
107+
# MDEV-35039 Number of indexes inside InnoDB differs from that defined in MariaDB after altering table with vector key
108+
#
109+
create table t (v blob not null, vector index (v)) row_format=compressed engine=innodb;
110+
alter table t add f int;
111+
insert into t values (x'00000000',1);
112+
show create table t;
113+
Table Create Table
114+
t CREATE TABLE `t` (
115+
`v` blob NOT NULL,
116+
`f` int(11) DEFAULT NULL,
117+
VECTOR KEY `v` (`v`)
118+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ROW_FORMAT=COMPRESSED
119+
drop table t;

mysql-test/main/vector_innodb.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,12 @@ create table t (pk int primary key, v varbinary(1024) not null, vector key(v)) e
8787
insert into t values (1, x'B047263C9F87233fcfd27e3eae493e3f0329f43e');
8888
select pk,hex(v) from t;
8989
drop table t;
90+
91+
--echo #
92+
--echo # MDEV-35039 Number of indexes inside InnoDB differs from that defined in MariaDB after altering table with vector key
93+
--echo #
94+
create table t (v blob not null, vector index (v)) row_format=compressed engine=innodb;
95+
alter table t add f int;
96+
insert into t values (x'00000000',1);
97+
show create table t;
98+
drop table t;

sql/sql_table.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7319,10 +7319,17 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table,
73197319
Adding/dropping any indexes in a table that already has high-level indexes
73207320
may shift high-level indexes numbers. And thus require high-level indexes
73217321
rename, which algorithm=inplace (storage engines) shouldn't do.
7322+
7323+
If we aren't adding/dropping indexes, ha_alter_info->key_count is
7324+
table->s->total_keys, but must be table->s->keys to not confuse the engine.
73227325
*/
7323-
if (table->s->hlindexes() &&
7324-
(ha_alter_info->index_drop_count || ha_alter_info->index_add_count))
7325-
ha_alter_info->inplace_supported= HA_ALTER_INPLACE_NOT_SUPPORTED;
7326+
if (table->s->hlindexes())
7327+
{
7328+
if (ha_alter_info->index_drop_count || ha_alter_info->index_add_count)
7329+
ha_alter_info->inplace_supported= HA_ALTER_INPLACE_NOT_SUPPORTED;
7330+
else
7331+
ha_alter_info->key_count= table->s->keys;
7332+
}
73267333

73277334
DBUG_PRINT("exit", ("handler_flags: %llu", ha_alter_info->handler_flags));
73287335
DBUG_RETURN(false);

0 commit comments

Comments
 (0)