Skip to content

Commit 98f1623

Browse files
committed
MDEV-37022 Assertion when adding FK to MyISAM/Aria table with a vector index
adding FK to a table may implicitly add an index, thus sort_keys() must be called to put the vector index last
1 parent a4f17dc commit 98f1623

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

mysql-test/main/vector2.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,20 @@ create table t1 (v vector (1) not null,vector index (v));
468468
insert into t1 values (0xf0a08080);
469469
insert into t1 values (0xfa000000);
470470
drop table t1;
471+
#
472+
# MDEV-37022 Assertion when adding FK to MyISAM/Aria table with a vector index
473+
#
474+
create table t1 (v vector(1) not null,vector (v));
475+
alter table t1 add x int references t1(x),add y int constraint c references t1(y);
476+
show create table t1;
477+
Table Create Table
478+
t1 CREATE TABLE `t1` (
479+
`v` vector(1) NOT NULL,
480+
`x` int(11) DEFAULT NULL,
481+
`y` int(11) DEFAULT NULL,
482+
KEY `x` (`x`),
483+
KEY `c` (`y`),
484+
VECTOR KEY `v` (`v`)
485+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
486+
drop table t1;
471487
# End of 11.8 tests

mysql-test/main/vector2.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,12 @@ insert into t1 values (0xf0a08080);
347347
insert into t1 values (0xfa000000);
348348
drop table t1;
349349

350+
--echo #
351+
--echo # MDEV-37022 Assertion when adding FK to MyISAM/Aria table with a vector index
352+
--echo #
353+
create table t1 (v vector(1) not null,vector (v));
354+
alter table t1 add x int references t1(x),add y int constraint c references t1(y);
355+
show create table t1;
356+
drop table t1;
357+
350358
--echo # End of 11.8 tests

sql/sql_table.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11471,7 +11471,8 @@ do_continue:;
1147111471

1147211472
tmp_disable_binlog(thd);
1147311473
create_info->options|=HA_CREATE_TMP_ALTER;
11474-
if (!(alter_info->flags & ALTER_ADD_INDEX) && !alter_ctx.modified_primary_key)
11474+
if (!(alter_info->flags & (ALTER_ADD_INDEX|ALTER_ADD_FOREIGN_KEY)) &&
11475+
!alter_ctx.modified_primary_key)
1147511476
create_info->options|= HA_SKIP_KEY_SORT;
1147611477
else
1147711478
alter_info->flags|= ALTER_INDEX_ORDER;

0 commit comments

Comments
 (0)