summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-03-10 17:27:01 +0200
committerMonty <monty@mariadb.org>2021-03-10 17:27:10 +0200
commit1799caa3a1305d21acaa37169e6b14307b4b5f08 (patch)
tree44627a56ea056c3b116fed5a264dfc4165d4c279 /storage/connect
parent322129dfb4c2d3a85dfb80c43e11df8d301ce79b (diff)
downloadmariadb-git-1799caa3a1305d21acaa37169e6b14307b4b5f08.tar.gz
MDEV-24422 Server crashes in ha_connect::GetRealType upon ALTER TABLE
The problem was that the CONNECT engine is trying to open the .frm file during drop_table(), which the code did not take into account. Fixed by adding the HA_REUSES_FILE_NAMES table flag to CONNECT. Other things: - Fixed a wrong test of HA_REUSE_FILE_NAMES of in mysql_alter_table() (Comment was correct, no the code) - Added a test in the connect engine that if the .frm it tries to use in delete is not made for connect, it will generate an error instead of crash.
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/ha_connect.cc11
-rw-r--r--storage/connect/mysql-test/connect/r/alter_engine.result11
-rw-r--r--storage/connect/mysql-test/connect/t/alter_engine.test11
3 files changed, 32 insertions, 1 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 2206cfc271d..b1449af9636 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1169,7 +1169,8 @@ ulonglong ha_connect::table_flags() const
// HA_NULL_IN_KEY | not implemented yet
// HA_FAST_KEY_READ | causes error when sorting (???)
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
- HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN;
+ HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN |
+ HA_REUSES_FILE_NAMES;
ha_connect *hp= (ha_connect*)this;
PTOS pos= hp->GetTableOptionStruct();
@@ -5244,6 +5245,14 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
thd->push_internal_handler(&error_handler);
bool got_error= open_table_def(thd, share);
thd->pop_internal_handler();
+ if (!got_error && share->db_type() != connect_hton)
+ {
+ /* The .frm file is not for the connect engine. Something is wrong! */
+ got_error= 1;
+ rc= HA_ERR_INTERNAL_ERROR;
+ my_error(HA_ERR_INTERNAL_ERROR, MYF(0),
+ "TABLE_SHARE is not for the CONNECT engine");
+ }
if (!got_error) {
// Now we can work
if ((pos= share->option_struct)) {
diff --git a/storage/connect/mysql-test/connect/r/alter_engine.result b/storage/connect/mysql-test/connect/r/alter_engine.result
new file mode 100644
index 00000000000..530574d276d
--- /dev/null
+++ b/storage/connect/mysql-test/connect/r/alter_engine.result
@@ -0,0 +1,11 @@
+#
+# MDEV-24422 Server crashes in GetTypeID / ha_connect::GetRealType upon
+# altering table engine
+#
+CREATE TABLE t1 (f INT) ENGINE=CONNECT;
+Warnings:
+Warning 1105 No table_type. Will be set to DOS
+Warning 1105 No file name. Table will use t1.dos
+ALTER TABLE t1 ENGINE InnoDB;
+ALTER TABLE t1 ENGINE CONNECT;
+DROP TABLE t1;
diff --git a/storage/connect/mysql-test/connect/t/alter_engine.test b/storage/connect/mysql-test/connect/t/alter_engine.test
new file mode 100644
index 00000000000..789a0955d3b
--- /dev/null
+++ b/storage/connect/mysql-test/connect/t/alter_engine.test
@@ -0,0 +1,11 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-24422 Server crashes in GetTypeID / ha_connect::GetRealType upon
+--echo # altering table engine
+--echo #
+
+CREATE TABLE t1 (f INT) ENGINE=CONNECT;
+ALTER TABLE t1 ENGINE InnoDB;
+ALTER TABLE t1 ENGINE CONNECT;
+DROP TABLE t1;