diff --git a/mysql-test/main/vector_innodb.result b/mysql-test/main/vector_innodb.result index a1a2637a95f..e2f729e7070 100644 --- a/mysql-test/main/vector_innodb.result +++ b/mysql-test/main/vector_innodb.result @@ -171,3 +171,18 @@ insert into t values (1,x'00000000'),(2,x'00000000'); lock table t write; delete from t; drop table t; +# +# MDEV-35061 XA PREPARE "not supported by the engine" from storage engine mhnsw, memory leak +# +connect con1,localhost,root; +create table t (a int, v blob not null, vector(v)) engine=innodb; +xa start 'x'; +insert into t values (1,x'00000000'); +xa end 'x'; +xa prepare 'x'; +ERROR HY000: Got error 138 "Unsupported extension used for table" from storage engine mhnsw +disconnect con1; +connection default; +xa recover; +formatID gtrid_length bqual_length data +DROP TABLE t; diff --git a/mysql-test/main/vector_innodb.test b/mysql-test/main/vector_innodb.test index 075d1331d4e..c65fc77ee2e 100644 --- a/mysql-test/main/vector_innodb.test +++ b/mysql-test/main/vector_innodb.test @@ -159,3 +159,19 @@ insert into t values (1,x'00000000'),(2,x'00000000'); lock table t write; delete from t; drop table t; + +--echo # +--echo # MDEV-35061 XA PREPARE "not supported by the engine" from storage engine mhnsw, memory leak +--echo # +connect con1,localhost,root; +create table t (a int, v blob not null, vector(v)) engine=innodb; +xa start 'x'; +insert into t values (1,x'00000000'); +xa end 'x'; +--error ER_GET_ERRNO +xa prepare 'x'; +disconnect con1; +connection default; +#xa commit 'x'; +xa recover; +DROP TABLE t; diff --git a/sql/handler.cc b/sql/handler.cc index 2c5e3904e9c..5c9cb8e4aa7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1508,9 +1508,7 @@ static int prepare_or_error(transaction_participant *ht, THD *thd, bool all) int err= ht->prepare(thd, all); status_var_increment(thd->status_var.ha_prepare_count); if (err) - { - my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); - } + my_error(ER_GET_ERRNO, MYF(0), err, hton_name(ht)->str); #ifdef WITH_WSREP if (run_wsrep_hooks && !err && ht->flags & HTON_WSREP_REPLICATION && wsrep_after_prepare(thd, all)) diff --git a/sql/log.h b/sql/log.h index 1863fd33d11..2f3b6508f58 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1476,7 +1476,7 @@ end: static inline TC_LOG *get_tc_log_implementation() { - if (total_ha_2pc <= 1) + if (total_ha_2pc <= 2) // online_alter_tp and MHNSW_Trx::tp return &tc_log_dummy; if (opt_bin_log) return &mysql_bin_log; diff --git a/sql/vector_mhnsw.cc b/sql/vector_mhnsw.cc index ae3d2eaf84e..98f064685a4 100644 --- a/sql/vector_mhnsw.cc +++ b/sql/vector_mhnsw.cc @@ -520,6 +520,7 @@ public: static int do_commit(THD *thd, bool); static int do_savepoint_rollback(THD *thd, void *); static int do_rollback(THD *thd, bool); + static int do_prepare(THD *thd, bool); }; struct transaction_participant MHNSW_Trx::tp= @@ -531,7 +532,7 @@ struct transaction_participant MHNSW_Trx::tp= [](THD *thd){ return true; }, /*savepoint_rollback_can_release_mdl*/ nullptr, /*savepoint_release*/ MHNSW_Trx::do_commit, MHNSW_Trx::do_rollback, - nullptr, /* prepare */ + MHNSW_Trx::do_prepare, /* prepare */ nullptr, /* recover */ nullptr, nullptr, /* commit/rollback_by_xid */ nullptr, nullptr, /* recover_rollback_by_xid/recovery_done */ @@ -606,6 +607,13 @@ int MHNSW_Trx::do_commit(THD *thd, bool) return 0; } +int MHNSW_Trx::do_prepare(THD *thd, bool) +{ + /* Explicit XA is not supported yet */ + return thd->transaction->xid_state.is_explicit_XA() + ? HA_ERR_UNSUPPORTED : 0; +} + MHNSW_Trx *MHNSW_Trx::get_from_thd(TABLE *table, bool for_update) { if (!table->file->has_transactions())