summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2019-06-19 00:35:44 +0300
committerMichael Widenius <monty@mariadb.org>2019-06-19 00:35:44 +0300
commit8acbf9c1f961aa1008ef509e059e1a09943f5ed3 (patch)
treef3b0b2c2d0510aea9e06a75eb4f949d0281ebd48 /sql
parentb23c82fef38839f9f6b758091dfb5064c017f608 (diff)
downloadmariadb-git-8acbf9c1f961aa1008ef509e059e1a09943f5ed3.tar.gz
MDEV-19595 fixed
The test cases for the MDEV found several independent bugs in MariaDB server and Aria: - If a temporary table was marked as crashed, it could never be deleted. - Opening of a crashed temporary table gave an error message but the error was never forwarded to the caller which caused an assert() in my_ok() - init_read_record() did mmap of all temporary tables, which is probably not a good idea as this area can potentially be very big. Changed code to only mmap internal temporary tables. - mmap-ed tables where not unmapped in case of repair/optimize which caused bad data in table and crashes if the original table files where replaced with new ones (as the old mmap was still in place). Fixed by removing the mmap in case of repair. - Cleaned up usage of code that disabled mmap in Aria
Diffstat (limited to 'sql')
-rw-r--r--sql/records.cc3
-rw-r--r--sql/sql_parse.cc8
-rw-r--r--sql/temporary_tables.cc5
3 files changed, 12 insertions, 4 deletions
diff --git a/sql/records.cc b/sql/records.cc
index 3db34425e29..6a611d46ca4 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -197,8 +197,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
info->forms= &info->table; /* Only one table */
info->addon_field= addon_field;
- if ((table->s->tmp_table == INTERNAL_TMP_TABLE ||
- table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) &&
+ if ((table->s->tmp_table == INTERNAL_TMP_TABLE) &&
!addon_field)
(void) table->file->extra(HA_EXTRA_MMAP);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 976cfe3df03..6e2c38ad053 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -779,7 +779,6 @@ void init_update_queries(void)
Note that SQLCOM_RENAME_TABLE should not be in this list!
*/
sql_command_flags[SQLCOM_CREATE_TABLE]|= CF_PREOPEN_TMP_TABLES;
- sql_command_flags[SQLCOM_DROP_TABLE]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_CREATE_INDEX]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_ALTER_TABLE]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_TRUNCATE]|= CF_PREOPEN_TMP_TABLES;
@@ -4459,7 +4458,14 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_DROP_TABLE:
{
+ int result;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
+
+ thd->open_options|= HA_OPEN_FOR_REPAIR;
+ result= thd->open_temporary_tables(all_tables);
+ thd->open_options&= ~HA_OPEN_FOR_REPAIR;
+ if (result)
+ goto error;
if (!lex->tmp_table())
{
if (check_table_access(thd, DROP_ACL, all_tables, FALSE, UINT_MAX, FALSE))
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 15a81f4b375..ae7cb274843 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -382,6 +382,9 @@ bool THD::open_temporary_table(TABLE_LIST *tl)
rgi_slave->is_parallel_exec &&
wait_for_prior_commit())
DBUG_RETURN(true);
+
+ if (!table && is_error())
+ DBUG_RETURN(true); // Error when opening table
}
if (!table)
@@ -1103,7 +1106,7 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
if (open_table_from_share(this, share, alias,
open_in_engine ? (uint)HA_OPEN_KEYFILE : 0,
- EXTRA_RECORD, ha_open_options, table,
+ EXTRA_RECORD, open_options | ha_open_options, table,
open_in_engine ? false : true))
{
my_free(table);