From 0932c3a27e1ca5b6d164723468a2fd6086be8878 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 30 Sep 2024 19:22:30 +0200 Subject: [PATCH] MDEV-35044 ALTER on a table with vector index attempts to bypass unsupported locking limitation, server crashes in THD::free_tmp_table_share open secondary tables early enough for the cleanup on error to see them and remove their underlying files --- mysql-test/main/vector2_notembedded.result | 7 +++++++ mysql-test/main/vector2_notembedded.test | 9 +++++++++ sql/sql_table.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 mysql-test/main/vector2_notembedded.result create mode 100644 mysql-test/main/vector2_notembedded.test diff --git a/mysql-test/main/vector2_notembedded.result b/mysql-test/main/vector2_notembedded.result new file mode 100644 index 00000000000..99359057ce2 --- /dev/null +++ b/mysql-test/main/vector2_notembedded.result @@ -0,0 +1,7 @@ +# +# MDEV-35044 ALTER on a table with vector index attempts to bypass unsupported locking limitation, server crashes in THD::free_tmp_table_share +# +create table t (a int primary key, v blob not null, vector index(v)); +alter table t modify a int auto_increment, lock=none; +ERROR 0A000: LOCK=NONE is not supported. Reason: CHANGE COLUMN ... AUTO_INCREMENT. Try LOCK=SHARED +drop table t; diff --git a/mysql-test/main/vector2_notembedded.test b/mysql-test/main/vector2_notembedded.test new file mode 100644 index 00000000000..41e6327efae --- /dev/null +++ b/mysql-test/main/vector2_notembedded.test @@ -0,0 +1,9 @@ +--source include/not_embedded.inc + +--echo # +--echo # MDEV-35044 ALTER on a table with vector index attempts to bypass unsupported locking limitation, server crashes in THD::free_tmp_table_share +--echo # +create table t (a int primary key, v blob not null, vector index(v)); +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +alter table t modify a int auto_increment, lock=none; +drop table t; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2b373203301..4616064cbea 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11575,7 +11575,7 @@ alter_copy: new_table= thd->create_and_open_tmp_table(&frm, alter_ctx.get_tmp_path(), alter_ctx.new_db, alter_ctx.new_name, true); - if (!new_table) + if (!new_table || new_table->open_hlindexes_for_write()) goto err_new_table_cleanup; if (table->s->tmp_table != NO_TMP_TABLE)