From 91ffdc8380ab48a2d57dc81472beb80af115318f Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 6 Apr 2020 15:41:33 +0300 Subject: Don't try to open temporary tables if there are no temporary tables. This was done to increase performance when not using temporary tables as checking if a table is a temporary table involves a lot of code. --- sql/sql_cte.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_cte.cc') diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 93344956468..1d3226fef34 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -834,6 +834,7 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd, st_select_lex_unit *res= NULL; Query_arena backup; Query_arena *arena= thd->activate_stmt_arena_if_needed(&backup); + bool has_tmp_tables; if (!(lex= (LEX*) new(thd->mem_root) st_lex_local)) { @@ -879,11 +880,12 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd, spec_tables= lex->query_tables; spec_tables_tail= 0; + has_tmp_tables= thd->has_temporary_tables(); for (TABLE_LIST *tbl= spec_tables; tbl; tbl= tbl->next_global) { - if (!tbl->derived && !tbl->schema_table && + if (has_tmp_tables && !tbl->derived && !tbl->schema_table && thd->open_temporary_table(tbl)) goto err; spec_tables_tail= tbl; -- cgit v1.2.1