summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2021-07-26 22:43:16 +0200
committerVicențiu Ciorbaru <cvicentiu@gmail.com>2021-10-29 14:56:09 +0300
commit12eb8ad7b98b03a6a7659fce7b75bdc8696ccaf6 (patch)
treee68e16ee5fd97ad25be0401adad2261e0696d31d
parentd7af7bfc2b6ab89801059406e1bd74846a2ca8e8 (diff)
downloadmariadb-git-12eb8ad7b98b03a6a7659fce7b75bdc8696ccaf6.tar.gz
MDEV-26242: Assertion `i >= 0' failed on setting default_tmp_storage_engine to 'DEFAULT' in 10.7bb-10.7-vicentiu-MDEV-26242
Locking / unlocking plugins is already handled by Sys_var_plugin::check method. No need to do that in the specialized checking code, use var->save_value instead to get the plugin handle.
-rw-r--r--mysql-test/suite/sys_vars/r/default_tmp_storage_engine_rocksdb.result51
-rw-r--r--mysql-test/suite/sys_vars/t/default_tmp_storage_engine_rocksdb.test34
-rw-r--r--sql/sys_vars.cc10
3 files changed, 87 insertions, 8 deletions
diff --git a/mysql-test/suite/sys_vars/r/default_tmp_storage_engine_rocksdb.result b/mysql-test/suite/sys_vars/r/default_tmp_storage_engine_rocksdb.result
index a93be903deb..9ec7b900ccf 100644
--- a/mysql-test/suite/sys_vars/r/default_tmp_storage_engine_rocksdb.result
+++ b/mysql-test/suite/sys_vars/r/default_tmp_storage_engine_rocksdb.result
@@ -49,3 +49,54 @@ DROP TABLE t2;
CREATE TEMPORARY TABLE t2 LIKE t1;
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
DROP TABLE t1;
+#
+# MDEV-26242: Assertion `i >= 0' failed on setting
+# default_tmp_storage_engine to 'DEFAULT' in 10.7
+#
+SHOW VARIABLES like '%storage_engine';
+Variable_name Value
+default_storage_engine ROCKSDB
+default_tmp_storage_engine Aria
+enforce_storage_engine
+storage_engine ROCKSDB
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+@@GLOBAL.default_tmp_storage_engine @@GLOBAL.default_storage_engine @@GLOBAL.storage_engine @@SESSION.default_tmp_storage_engine @@SESSION.default_storage_engine @@SESSION.storage_engine
+NULL MyISAM MyISAM Aria ROCKSDB ROCKSDB
+SELECT @@GLOBAL.table_type;
+ERROR HY000: Unknown system variable 'table_type'
+SET default_storage_engine=DEFAULT;
+SET default_tmp_storage_engine=innodb;
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+@@GLOBAL.default_tmp_storage_engine @@GLOBAL.default_storage_engine @@GLOBAL.storage_engine @@SESSION.default_tmp_storage_engine @@SESSION.default_storage_engine @@SESSION.storage_engine
+NULL MyISAM MyISAM InnoDB MyISAM MyISAM
+CREATE TABLE t (t int);
+CREATE TEMPORARY TABLE t1 (t int);
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `t` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `t` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t;
+SET GLOBAL default_tmp_storage_engine='default';
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+@@GLOBAL.default_tmp_storage_engine @@GLOBAL.default_storage_engine @@GLOBAL.storage_engine @@SESSION.default_tmp_storage_engine @@SESSION.default_storage_engine @@SESSION.storage_engine
+MyISAM MyISAM MyISAM InnoDB MyISAM MyISAM
+CREATE TABLE t (t int);
+CREATE TEMPORARY TABLE t1 (t int);
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `t` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `t` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t;
+SET GLOBAL default_tmp_storage_engine=NULL;
diff --git a/mysql-test/suite/sys_vars/t/default_tmp_storage_engine_rocksdb.test b/mysql-test/suite/sys_vars/t/default_tmp_storage_engine_rocksdb.test
index a3436059e39..3454e5d6fc4 100644
--- a/mysql-test/suite/sys_vars/t/default_tmp_storage_engine_rocksdb.test
+++ b/mysql-test/suite/sys_vars/t/default_tmp_storage_engine_rocksdb.test
@@ -4,6 +4,8 @@
--source include/have_rocksdb.inc
--source include/not_embedded.inc
+--source include/have_innodb.inc
+
--error ER_UNKNOWN_STORAGE_ENGINE
SET default_tmp_storage_engine = engine_doesnt_exist;
--error ER_ILLEGAL_HA_CREATE_OPTION
@@ -50,3 +52,35 @@ DROP TABLE t2;
CREATE TEMPORARY TABLE t2 LIKE t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-26242: Assertion `i >= 0' failed on setting
+--echo # default_tmp_storage_engine to 'DEFAULT' in 10.7
+--echo #
+
+
+SHOW VARIABLES like '%storage_engine';
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+SELECT @@GLOBAL.table_type;
+
+SET default_storage_engine=DEFAULT;
+SET default_tmp_storage_engine=innodb;
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+
+CREATE TABLE t (t int);
+CREATE TEMPORARY TABLE t1 (t int);
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE t1;
+DROP TABLE t1, t;
+
+SET GLOBAL default_tmp_storage_engine='default';
+SELECT @@GLOBAL.default_tmp_storage_engine, @@GLOBAL.default_storage_engine, @@GLOBAL.storage_engine, @@SESSION.default_tmp_storage_engine, @@SESSION.default_storage_engine, @@SESSION.storage_engine;
+
+CREATE TABLE t (t int);
+CREATE TEMPORARY TABLE t1 (t int);
+SHOW CREATE TABLE t;
+SHOW CREATE TABLE t1;
+DROP TABLE t1, t;
+
+SET GLOBAL default_tmp_storage_engine=NULL; \ No newline at end of file
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 812a947416c..e18ca6392d8 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -742,13 +742,9 @@ static Sys_var_charptr_fscs Sys_character_sets_dir(
static bool check_engine_supports_temporary(sys_var *self, THD *thd, set_var *var)
{
- String str, *res;
- LEX_CSTRING name;
- if (!var->value || var->value->is_null())
+ plugin_ref plugin= var->save_result.plugin;
+ if (!plugin)
return false;
- res= var->value->val_str(&str);
- res->get_value(&name);
- plugin_ref plugin= ha_resolve_by_name(thd, &name, true);
DBUG_ASSERT(plugin);
handlerton *hton= plugin_hton(plugin);
DBUG_ASSERT(hton);
@@ -756,10 +752,8 @@ static bool check_engine_supports_temporary(sys_var *self, THD *thd, set_var *va
{
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), hton_name(hton)->str,
"TEMPORARY");
- plugin_unlock(thd, plugin);
return true;
}
- plugin_unlock(thd, plugin);
return false;
}