MDEV-36005 Server crashes when checking/updating a table having vector key after enabling innodb_force_primary_key

if creating a hlindex table failed, it should not unlock
main table's plugin
This commit is contained in:
Sergei Golubchik 2025-02-02 20:13:57 +01:00
parent e928bf1c0e
commit 5b8c087e84
3 changed files with 45 additions and 0 deletions

View file

@ -252,4 +252,29 @@ d
0.00000
0.00000
drop table t;
#
# MDEV-36005 Server crashes when checking/updating a table having vector key after enabling innodb_force_primary_key
#
create table t (v vector (3) not null,vector index (v)) engine=innodb;
set global innodb_force_primary_key=1;
check table t extended;
Table Op Msg_type Msg_text
test.t check Error This table type requires a primary key
test.t check Error Engine InnoDB failed to discover table `test`.`t` with 'CREATE TABLE i ( layer tinyint not null, tref varbinary(6), vec blob not null, neighbors blob not null, unique (tref), key (layer)) '
test.t check status Operation failed
check table t extended;
Table Op Msg_type Msg_text
test.t check Error This table type requires a primary key
test.t check Error Engine InnoDB failed to discover table `test`.`t` with 'CREATE TABLE i ( layer tinyint not null, tref varbinary(6), vec blob not null, neighbors blob not null, unique (tref), key (layer)) '
test.t check status Operation failed
set global innodb_force_primary_key=0;
drop table t;
create table t (v vector (1) not null,vector index (v)) engine=innodb;
set global innodb_force_primary_key=1;
insert into t values (0x31313131);
ERROR HY000: Engine InnoDB failed to discover table `test`.`t` with 'CREATE TABLE i ( layer tinyint not null, tref varbinary(6), vec blob not null, neighbors blob not null, unique (tref), key (layer)) '
insert into t values (0x32323232);
ERROR HY000: Engine InnoDB failed to discover table `test`.`t` with 'CREATE TABLE i ( layer tinyint not null, tref varbinary(6), vec blob not null, neighbors blob not null, unique (tref), key (layer)) '
set global innodb_force_primary_key=0;
drop table t;
# End of 11.7 tests

View file

@ -254,4 +254,22 @@ insert into t values (1,0x31313131),(2,0x32323232); # optional, fails either way
select distinct vec_distance_euclidean(v, 0x30303030) as d from t order by pk;
drop table t;
--echo #
--echo # MDEV-36005 Server crashes when checking/updating a table having vector key after enabling innodb_force_primary_key
--echo #
create table t (v vector (3) not null,vector index (v)) engine=innodb;
set global innodb_force_primary_key=1;
check table t extended;
check table t extended;
set global innodb_force_primary_key=0;
drop table t;
create table t (v vector (1) not null,vector index (v)) engine=innodb;
set global innodb_force_primary_key=1;
--error ER_SQL_DISCOVER_ERROR
insert into t values (0x31313131);
--error ER_SQL_DISCOVER_ERROR
insert into t values (0x32323232);
set global innodb_force_primary_key=0;
drop table t;
--echo # End of 11.7 tests

View file

@ -9827,6 +9827,8 @@ int TABLE::hlindex_open(uint nr)
if (share->init_from_sql_statement_string(in_use, false,
sql.str, sql.length))
{
if (share->db_plugin == s->db_plugin)
share->db_plugin= NULL;
free_table_share(share);
return 1;
}