mirror of
https://github.com/MariaDB/server.git
synced 2025-07-01 03:26:54 +03:00
MDEV-12914: Engine for temporary tables which are implicitly created as RocksDB is substituted silently
- There should be no substitution if engine exists, only when doesn't
exist
- Handling of an error when sys_var `default_tmp_storage_engine` is
assigned to unsupported engine.
- rocksdb doesn't support embedded server ebfc4e6ad0
so is excluded
Closes PR #774
Reviewed by: serg@mariadb.com
vicentiu@mariadb.org
This commit is contained in:
@ -754,7 +754,7 @@ ERROR HY000: Field 'c' is of a not allowed type for this type of partitioning
|
||||
#
|
||||
CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
|
||||
CREATE TEMPORARY TABLE tmp_t1 LIKE t1;
|
||||
ERROR HY000: Partitioned tables do not support CREATE TEMPORARY TABLE
|
||||
ERROR HY000: Table storage engine 'partition' does not support the create option 'TEMPORARY'
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with
|
||||
|
@ -788,7 +788,7 @@ PARTITION BY HASH (c) PARTITIONS 4;
|
||||
--echo # with temporary table and partitions
|
||||
--echo #
|
||||
CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
|
||||
--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CREATE TEMPORARY TABLE tmp_t1 LIKE t1;
|
||||
DROP TABLE t1;
|
||||
--echo #
|
||||
|
@ -0,0 +1,51 @@
|
||||
#
|
||||
# MDEV-12914: Engine for temporary tables which are implicitly
|
||||
# created as RocksDB is substitued siliently with MyIsam
|
||||
SET default_tmp_storage_engine = engine_doesnt_exist;
|
||||
ERROR 42000: Unknown storage engine 'engine_doesnt_exist'
|
||||
SET default_tmp_storage_engine = rocksdb;
|
||||
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
|
||||
SET default_tmp_storage_engine = CONCAT('rocks','db');
|
||||
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
|
||||
CREATE TABLE t1 (i int) ENGINE = RocksDB;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL
|
||||
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
|
||||
DROP TABLE t1;
|
||||
SET default_storage_engine = DEFAULT;
|
||||
SET default_tmp_storage_engine = DEFAULT;
|
||||
CREATE TABLE t1 (t int);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TEMPORARY TABLE `t2` (
|
||||
`t` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1, t2;
|
||||
SET default_storage_engine = rocksdb;
|
||||
SET default_tmp_storage_engine = default;
|
||||
CREATE TABLE t1 (t int);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t` int(11) DEFAULT NULL
|
||||
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
|
||||
CREATE TEMPORARY TABLE t2 (t int);
|
||||
ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
|
||||
SET default_tmp_storage_engine = aria;
|
||||
CREATE TEMPORARY TABLE t2 (t int);
|
||||
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;
|
@ -0,0 +1,52 @@
|
||||
--echo #
|
||||
--echo # MDEV-12914: Engine for temporary tables which are implicitly
|
||||
--echo # created as RocksDB is substitued siliently with MyIsam
|
||||
|
||||
--source include/have_rocksdb.inc
|
||||
--source include/not_embedded.inc
|
||||
--error ER_UNKNOWN_STORAGE_ENGINE
|
||||
SET default_tmp_storage_engine = engine_doesnt_exist;
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
SET default_tmp_storage_engine = rocksdb;
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
SET default_tmp_storage_engine = CONCAT('rocks','db');
|
||||
|
||||
CREATE TABLE t1 (i int) ENGINE = RocksDB;
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
SET default_storage_engine = DEFAULT;
|
||||
SET default_tmp_storage_engine = DEFAULT;
|
||||
|
||||
CREATE TABLE t1 (t int);
|
||||
SHOW CREATE TABLE t1;
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
SET default_storage_engine = rocksdb;
|
||||
# setting default or null for tmp SE should use default SE
|
||||
SET default_tmp_storage_engine = default;
|
||||
|
||||
CREATE TABLE t1 (t int);
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CREATE TEMPORARY TABLE t2 (t int);
|
||||
|
||||
SET default_tmp_storage_engine = aria;
|
||||
CREATE TEMPORARY TABLE t2 (t int);
|
||||
DROP TABLE t2;
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CREATE TEMPORARY TABLE t2 LIKE t1;
|
||||
|
||||
DROP TABLE t1;
|
@ -6,8 +6,6 @@ SET @sys.debug = 'OFF',
|
||||
@sys.diagnostics.allow_i_s_tables = 'OFF',
|
||||
@sys.diagnostics.include_raw = 'OFF';
|
||||
CALL sys.diagnostics(0, 0, 'full');
|
||||
summary
|
||||
Disabled 1 thread
|
||||
ERROR 45000: in_max_runtime must be greater than 0
|
||||
CALL sys.diagnostics(2, 0, 'full');
|
||||
ERROR 45000: in_interval must be greater than 0
|
||||
|
@ -19,6 +19,7 @@ SET @sys.debug = 'ON',
|
||||
@sys.diagnostics.allow_i_s_tables = 'ON',
|
||||
@sys.diagnostics.include_raw = 'ON';
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
CALL sys.diagnostics(4, 2, 'full');
|
||||
|
||||
SET @sys.debug = 'OFF',
|
||||
|
@ -11470,16 +11470,11 @@ bool check_engine(THD *thd, const char *db_name,
|
||||
if (create_info->tmp_table() &&
|
||||
ha_check_storage_engine_flag(*new_engine, HTON_TEMPORARY_NOT_SUPPORTED))
|
||||
{
|
||||
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
|
||||
{
|
||||
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
|
||||
hton_name(*new_engine)->str, "TEMPORARY");
|
||||
*new_engine= 0;
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
*new_engine= myisam_hton;
|
||||
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
|
||||
hton_name(*new_engine)->str, "TEMPORARY");
|
||||
*new_engine= 0;
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
lex_string_set(&create_info->new_storage_engine_name,
|
||||
ha_resolve_storage_engine_name(*new_engine));
|
||||
DBUG_RETURN(false);
|
||||
|
@ -741,6 +741,29 @@ static Sys_var_charptr_fscs Sys_character_sets_dir(
|
||||
READ_ONLY GLOBAL_VAR(charsets_dir), CMD_LINE(REQUIRED_ARG),
|
||||
DEFAULT(0));
|
||||
|
||||
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())
|
||||
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);
|
||||
if (ha_check_storage_engine_flag(hton, HTON_TEMPORARY_NOT_SUPPORTED))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static bool check_not_null(sys_var *self, THD *thd, set_var *var)
|
||||
{
|
||||
return var->value && var->value->is_null();
|
||||
@ -4239,7 +4262,8 @@ static Sys_var_plugin Sys_storage_engine(
|
||||
static Sys_var_plugin Sys_default_tmp_storage_engine(
|
||||
"default_tmp_storage_engine", "The default storage engine for user-created temporary tables",
|
||||
SESSION_VAR(tmp_table_plugin), NO_CMD_LINE,
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_tmp_storage_engine));
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_tmp_storage_engine),
|
||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_engine_supports_temporary));
|
||||
|
||||
static Sys_var_plugin Sys_enforce_storage_engine(
|
||||
"enforce_storage_engine", "Force the use of a storage engine for new tables",
|
||||
|
Reference in New Issue
Block a user