summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-06-19 08:56:10 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-06-19 08:56:10 +0300
commit192aa295b4bc877d0fed24154c57304c3f789179 (patch)
tree893239effa9f3c9a7d00b324de9b4e41c63bdb4d /sql
parent03f3ba2dcb07a672f9c1d87489b9ec88af62a96f (diff)
parent8acbf9c1f961aa1008ef509e059e1a09943f5ed3 (diff)
downloadmariadb-git-192aa295b4bc877d0fed24154c57304c3f789179.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/records.cc3
-rw-r--r--sql/sql_admin.cc28
-rw-r--r--sql/sql_insert.cc3
-rw-r--r--sql/sql_parse.cc9
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/temporary_tables.cc5
6 files changed, 33 insertions, 17 deletions
diff --git a/sql/records.cc b/sql/records.cc
index 5dd4318b105..3d709182a4e 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -195,8 +195,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
info->table=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_admin.cc b/sql/sql_admin.cc
index 157d5d9f050..1c1ab82e570 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -700,19 +700,23 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
MDL_SHARED_NO_READ_WRITE lock (MDL_SHARED_WRITE cannot be upgraded)
by *not* having HA_CONCURRENT_OPTIMIZE table_flag.
*/
- if (lock_type == TL_WRITE && !table->table->s->tmp_table &&
- table->mdl_request.type > MDL_SHARED_WRITE)
+ if (lock_type == TL_WRITE && table->mdl_request.type > MDL_SHARED_WRITE)
{
- if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
- goto err;
- DEBUG_SYNC(thd, "after_admin_flush");
- /* Flush entries in the query cache involving this table. */
- query_cache_invalidate3(thd, table->table, 0);
- /*
- XXX: hack: switch off open_for_modify to skip the
- flush that is made later in the execution flow.
- */
- open_for_modify= 0;
+ if (table->table->s->tmp_table)
+ thd->close_unused_temporary_table_instances(tables);
+ else
+ {
+ if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
+ goto err;
+ DEBUG_SYNC(thd, "after_admin_flush");
+ /* Flush entries in the query cache involving this table. */
+ query_cache_invalidate3(thd, table->table, 0);
+ /*
+ XXX: hack: switch off open_for_modify to skip the
+ flush that is made later in the execution flow.
+ */
+ open_for_modify= 0;
+ }
}
if (table->table->s->crashed && operator_func == &handler::ha_check)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 1f3a70721fc..a64c120f14c 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1786,12 +1786,15 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
if (table->vfield)
{
+ my_bool abort_on_warning= thd->abort_on_warning;
/*
We have not yet called update_virtual_fields(VOL_UPDATE_FOR_READ)
in handler methods for the just read row in record[1].
*/
table->move_fields(table->field, table->record[1], table->record[0]);
+ thd->abort_on_warning= 0;
table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_REPLACE);
+ thd->abort_on_warning= abort_on_warning;
table->move_fields(table->field, table->record[0], table->record[1]);
}
if (info->handle_duplicates == DUP_UPDATE)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 01d13ac8789..e47700e0c33 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -791,8 +791,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_DROP_SEQUENCE]|= 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;
@@ -4743,7 +4741,14 @@ mysql_execute_command(THD *thd)
case SQLCOM_DROP_SEQUENCE:
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/sql_table.cc b/sql/sql_table.cc
index 9da889852b2..9719f55f0bc 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9845,6 +9845,8 @@ do_continue:;
DEBUG_SYNC(thd, "alter_table_copy_after_lock_upgrade");
}
+ else
+ thd->close_unused_temporary_table_instances(table_list);
// It's now safe to take the table level lock.
if (lock_tables(thd, table_list, alter_ctx.tables_opened,
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 396afc756f7..99ef1868158 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2016 MariaDB Corporation
+ Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -395,6 +395,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)