mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
This commit is contained in:
@ -378,3 +378,18 @@ select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins whe
|
|||||||
PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
|
PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
|
||||||
UNINSTALL SONAME 'ha_example';
|
UNINSTALL SONAME 'ha_example';
|
||||||
ERROR 42000: SONAME ha_example.so does not exist
|
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;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--source include/install_plugin_if_exists.inc
|
--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 @@ public:
|
|||||||
};
|
};
|
||||||
bool has_thd_temporary_tables();
|
bool has_thd_temporary_tables();
|
||||||
|
|
||||||
TABLE *create_and_open_tmp_table(handlerton *hton,
|
TABLE *create_and_open_tmp_table(LEX_CUSTRING *frm,
|
||||||
LEX_CUSTRING *frm,
|
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *db,
|
const char *db,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
@ -4780,7 +4779,7 @@ private:
|
|||||||
bool has_temporary_tables();
|
bool has_temporary_tables();
|
||||||
uint create_tmp_table_def_key(char *key, const char *db,
|
uint create_tmp_table_def_key(char *key, const char *db,
|
||||||
const char *table_name);
|
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 *path, const char *db,
|
||||||
const char *table_name);
|
const char *table_name);
|
||||||
TABLE *find_temporary_table(const char *key, uint key_length,
|
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;
|
create_info->table= 0;
|
||||||
if (!frm_only && create_info->tmp_table())
|
if (!frm_only && create_info->tmp_table())
|
||||||
{
|
{
|
||||||
TABLE *table= thd->create_and_open_tmp_table(create_info->db_type, frm,
|
TABLE *table= thd->create_and_open_tmp_table(frm, path, db.str,
|
||||||
path, db.str,
|
table_name.str, true,
|
||||||
table_name.str, true, false);
|
false);
|
||||||
|
|
||||||
if (!table)
|
if (!table)
|
||||||
{
|
{
|
||||||
@ -9863,7 +9863,7 @@ do_continue:;
|
|||||||
DBUG_ASSERT(!table->s->tmp_table);
|
DBUG_ASSERT(!table->s->tmp_table);
|
||||||
|
|
||||||
if (!(altered_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.get_tmp_path(),
|
||||||
alter_ctx.new_db.str,
|
alter_ctx.new_db.str,
|
||||||
alter_ctx.new_name.str,
|
alter_ctx.new_name.str,
|
||||||
@ -9990,11 +9990,11 @@ do_continue:;
|
|||||||
no_ha_table= false;
|
no_ha_table= false;
|
||||||
|
|
||||||
/* Open the table since we need to copy the data. */
|
/* Open the table since we need to copy the data. */
|
||||||
new_table=
|
new_table= thd->create_and_open_tmp_table(&frm,
|
||||||
thd->create_and_open_tmp_table(new_db_type, &frm, alter_ctx.get_tmp_path(),
|
alter_ctx.get_tmp_path(),
|
||||||
alter_ctx.new_db.str,
|
alter_ctx.new_db.str,
|
||||||
alter_ctx.new_name.str,
|
alter_ctx.new_name.str,
|
||||||
true, true);
|
true, true);
|
||||||
if (!new_table)
|
if (!new_table)
|
||||||
goto err_new_table_cleanup;
|
goto err_new_table_cleanup;
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ bool THD::has_thd_temporary_tables()
|
|||||||
/**
|
/**
|
||||||
Create a temporary table, open it and return the TABLE handle.
|
Create a temporary table, open it and return the TABLE handle.
|
||||||
|
|
||||||
@param hton [IN] Handlerton
|
|
||||||
@param frm [IN] Binary frm image
|
@param frm [IN] Binary frm image
|
||||||
@param path [IN] File path (without extension)
|
@param path [IN] File path (without extension)
|
||||||
@param db [IN] Schema name
|
@param db [IN] Schema name
|
||||||
@ -60,8 +59,7 @@ bool THD::has_thd_temporary_tables()
|
|||||||
@return Success A pointer to table object
|
@return Success A pointer to table object
|
||||||
Failure NULL
|
Failure NULL
|
||||||
*/
|
*/
|
||||||
TABLE *THD::create_and_open_tmp_table(handlerton *hton,
|
TABLE *THD::create_and_open_tmp_table(LEX_CUSTRING *frm,
|
||||||
LEX_CUSTRING *frm,
|
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *db,
|
const char *db,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
@ -73,7 +71,7 @@ TABLE *THD::create_and_open_tmp_table(handlerton *hton,
|
|||||||
TMP_TABLE_SHARE *share;
|
TMP_TABLE_SHARE *share;
|
||||||
TABLE *table= NULL;
|
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;
|
open_options|= HA_OPEN_FOR_CREATE;
|
||||||
table= open_temporary_table(share, table_name, open_in_engine);
|
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.
|
Create a temporary table.
|
||||||
|
|
||||||
@param hton [IN] Handlerton
|
|
||||||
@param frm [IN] Binary frm image
|
@param frm [IN] Binary frm image
|
||||||
@param path [IN] File path (without extension)
|
@param path [IN] File path (without extension)
|
||||||
@param db [IN] Schema name
|
@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
|
@return Success A pointer to table share object
|
||||||
Failure NULL
|
Failure NULL
|
||||||
*/
|
*/
|
||||||
TMP_TABLE_SHARE *THD::create_temporary_table(handlerton *hton,
|
TMP_TABLE_SHARE *THD::create_temporary_table(LEX_CUSTRING *frm,
|
||||||
LEX_CUSTRING *frm,
|
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *db,
|
const char *db,
|
||||||
const char *table_name)
|
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,
|
init_tmp_table_share(this, share, saved_key_cache, key_length,
|
||||||
strend(saved_key_cache) + 1, tmp_path);
|
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
|
Prefer using frm image over file. The image might not be available in
|
||||||
ALTER TABLE, when the discovering engine took over the ownership (see
|
ALTER TABLE, when the discovering engine took over the ownership (see
|
||||||
|
Reference in New Issue
Block a user