summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-06-20 11:34:24 +0200
committerSergei Golubchik <serg@mariadb.org>2014-06-20 15:47:44 +0200
commitce6a63ec41160ef6b7c0110d3f40aea79b8f3129 (patch)
tree4be27ef7152fd4f557bb09ad8943893f2d62ea1c /sql/sql_base.cc
parentcc5b3998b6767523792f7e4ec8c9a100db2d06ce (diff)
downloadmariadb-git-ce6a63ec41160ef6b7c0110d3f40aea79b8f3129.tar.gz
MDEV-4260 Don't create frm files for temporary tables
* Don't write frm for tmp tables * pass frm image down to open_table_uncached, when possible * don't use truncate-by-recreate for temp tables - cannot recreate without frm, and delete_all_rows is faster anyway
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 055806609e7..d60506dcad7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5508,6 +5508,7 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
@param thd Thread context.
@param hton Storage engine of the table, if known,
or NULL otherwise.
+ @param frm frm image
@param path Path (without .frm)
@param db Database name.
@param table_name Table name.
@@ -5527,6 +5528,7 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
*/
TABLE *open_table_uncached(THD *thd, handlerton *hton,
+ LEX_CUSTRING *frm,
const char *path, const char *db,
const char *table_name,
bool add_to_temporary_tables_list,
@@ -5561,7 +5563,17 @@ TABLE *open_table_uncached(THD *thd, handlerton *hton,
strend(saved_cache_key)+1, tmp_path);
share->db_plugin= ha_lock_engine(thd, hton);
- if (open_table_def(thd, share, GTS_TABLE | GTS_USE_DISCOVERY))
+ /*
+ Use the frm image, if possible, open the file otherwise.
+
+ The image might be unavailable in ALTER TABLE, when the discovering
+ engine took over the ownership (see TABLE::read_frm_image).
+ */
+ int res= frm->str
+ ? share->init_from_binary_frm_image(thd, false, frm->str, frm->length)
+ : open_table_def(thd, share, GTS_TABLE | GTS_USE_DISCOVERY);
+
+ if (res)
{
/* No need to lock share->mutex as this is not needed for tmp tables */
free_table_share(share);