Commit 1dac55cf authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.
parent 3638636f
......@@ -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;
......@@ -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;
......@@ -4738,8 +4738,7 @@ class THD: public THD_count, /* this must be first */
};
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 @@ class THD: public THD_count, /* this must be first */
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,
......
......@@ -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,8 +9990,8 @@ 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(),
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);
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment