diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-02-06 11:41:36 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-04-03 16:47:25 +0400 |
commit | 1dac55cf0ef4a412d56ea870835e1e199a400820 (patch) | |
tree | b6c24683247c7657fd24592e110d6639da9f050d | |
parent | 3638636f9b0c07665c5df498c31ae9c6ccac0b34 (diff) | |
download | mariadb-git-1dac55cf0ef4a412d56ea870835e1e199a400820.tar.gz |
Removed redundant SE lock for tmp tables
CREATE TEMPORARY TABLE locks SE plugin 6 times. 5 of these locks are
released by the end of the statement. And only 1 acquired by
init_from_binary_frm_image() / plugin_lock() remains.
The lock removed in this patch was clearly redundant.
Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
-rw-r--r-- | mysql-test/main/plugin.result | 15 | ||||
-rw-r--r-- | mysql-test/main/plugin.test | 16 | ||||
-rw-r--r-- | sql/sql_class.h | 5 | ||||
-rw-r--r-- | sql/sql_table.cc | 18 | ||||
-rw-r--r-- | sql/temporary_tables.cc | 12 |
5 files changed, 45 insertions, 21 deletions
diff --git a/mysql-test/main/plugin.result b/mysql-test/main/plugin.result index 947a2b6bd7a..49342705289 100644 --- a/mysql-test/main/plugin.result +++ b/mysql-test/main/plugin.result @@ -378,3 +378,18 @@ select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins whe PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE UNINSTALL SONAME 'ha_example'; ERROR 42000: SONAME ha_example.so does not exist +# +# Make sure temporary tables maintain plugin references properly +# +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TEMPORARY TABLE t1(a INT) ENGINE=example; +UNINSTALL PLUGIN example; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown +INSTALL PLUGIN example SONAME 'ha_example'; +ERROR HY000: Plugin 'example' already installed +DROP TABLE t1; +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TEMPORARY TABLE t1(a INT) ENGINE=example; +DROP TABLE t1; +UNINSTALL PLUGIN example; diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test index 68aab865036..0990cb206d8 100644 --- a/mysql-test/main/plugin.test +++ b/mysql-test/main/plugin.test @@ -267,3 +267,19 @@ RENAME TABLE t1 TO t2; DROP TABLE t1; --source include/install_plugin_if_exists.inc + + +--echo # +--echo # Make sure temporary tables maintain plugin references properly +--echo # +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TEMPORARY TABLE t1(a INT) ENGINE=example; +UNINSTALL PLUGIN example; +--error ER_PLUGIN_INSTALLED +INSTALL PLUGIN example SONAME 'ha_example'; +DROP TABLE t1; + +INSTALL PLUGIN example SONAME 'ha_example'; +CREATE TEMPORARY TABLE t1(a INT) ENGINE=example; +DROP TABLE t1; +UNINSTALL PLUGIN example; diff --git a/sql/sql_class.h b/sql/sql_class.h index 1078484cfac..a93072f80b0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4738,8 +4738,7 @@ public: }; bool has_thd_temporary_tables(); - TABLE *create_and_open_tmp_table(handlerton *hton, - LEX_CUSTRING *frm, + TABLE *create_and_open_tmp_table(LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name, @@ -4780,7 +4779,7 @@ private: bool has_temporary_tables(); uint create_tmp_table_def_key(char *key, const char *db, const char *table_name); - TMP_TABLE_SHARE *create_temporary_table(handlerton *hton, LEX_CUSTRING *frm, + TMP_TABLE_SHARE *create_temporary_table(LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name); TABLE *find_temporary_table(const char *key, uint key_length, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 378e04c2fac..ba44972e88a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5039,9 +5039,9 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db, create_info->table= 0; if (!frm_only && create_info->tmp_table()) { - TABLE *table= thd->create_and_open_tmp_table(create_info->db_type, frm, - path, db.str, - table_name.str, true, false); + TABLE *table= thd->create_and_open_tmp_table(frm, path, db.str, + table_name.str, true, + false); if (!table) { @@ -9863,7 +9863,7 @@ do_continue:; DBUG_ASSERT(!table->s->tmp_table); if (!(altered_table= - thd->create_and_open_tmp_table(new_db_type, &frm, + thd->create_and_open_tmp_table(&frm, alter_ctx.get_tmp_path(), alter_ctx.new_db.str, alter_ctx.new_name.str, @@ -9990,11 +9990,11 @@ do_continue:; no_ha_table= false; /* Open the table since we need to copy the data. */ - new_table= - thd->create_and_open_tmp_table(new_db_type, &frm, alter_ctx.get_tmp_path(), - alter_ctx.new_db.str, - alter_ctx.new_name.str, - true, true); + new_table= thd->create_and_open_tmp_table(&frm, + alter_ctx.get_tmp_path(), + alter_ctx.new_db.str, + alter_ctx.new_name.str, + true, true); if (!new_table) goto err_new_table_cleanup; diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 9cdae7d1885..c5b709f4ec1 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -49,7 +49,6 @@ bool THD::has_thd_temporary_tables() /** Create a temporary table, open it and return the TABLE handle. - @param hton [IN] Handlerton @param frm [IN] Binary frm image @param path [IN] File path (without extension) @param db [IN] Schema name @@ -60,8 +59,7 @@ bool THD::has_thd_temporary_tables() @return Success A pointer to table object Failure NULL */ -TABLE *THD::create_and_open_tmp_table(handlerton *hton, - LEX_CUSTRING *frm, +TABLE *THD::create_and_open_tmp_table(LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name, @@ -73,7 +71,7 @@ TABLE *THD::create_and_open_tmp_table(handlerton *hton, TMP_TABLE_SHARE *share; TABLE *table= NULL; - if ((share= create_temporary_table(hton, frm, path, db, table_name))) + if ((share= create_temporary_table(frm, path, db, table_name))) { open_options|= HA_OPEN_FOR_CREATE; table= open_temporary_table(share, table_name, open_in_engine); @@ -905,7 +903,6 @@ uint THD::create_tmp_table_def_key(char *key, const char *db, /** Create a temporary table. - @param hton [IN] Handlerton @param frm [IN] Binary frm image @param path [IN] File path (without extension) @param db [IN] Schema name @@ -914,8 +911,7 @@ uint THD::create_tmp_table_def_key(char *key, const char *db, @return Success A pointer to table share object Failure NULL */ -TMP_TABLE_SHARE *THD::create_temporary_table(handlerton *hton, - LEX_CUSTRING *frm, +TMP_TABLE_SHARE *THD::create_temporary_table(LEX_CUSTRING *frm, const char *path, const char *db, const char *table_name) @@ -953,8 +949,6 @@ TMP_TABLE_SHARE *THD::create_temporary_table(handlerton *hton, init_tmp_table_share(this, share, saved_key_cache, key_length, strend(saved_key_cache) + 1, tmp_path); - share->db_plugin= ha_lock_engine(this, hton); - /* Prefer using frm image over file. The image might not be available in ALTER TABLE, when the discovering engine took over the ownership (see |