From abfcdb8fbc4dec1ef9e6ea8fc9961344186b0209 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 28 Jan 2017 14:52:19 -0800 Subject: Fixed bug mdev-10773. The temporary tables created for recursive table references should be closed in close_thread_tables(), because they might be used in the statements like ANALYZE WITH r AS (...) SELECT * from r where r is defined through recursion. --- sql/sql_union.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sql/sql_union.cc') diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b30b5528741..71d0e331101 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -283,7 +283,14 @@ void select_union_recursive::cleanup() tab->file->extra(HA_EXTRA_RESET_STATE); tab->file->ha_delete_all_rows(); } - free_tmp_table(thd, tab); + /* + The table will be closed later in close_thread_tables(), + because it might be used in the statements like + ANALYZE WITH r AS (...) SELECT * from r + where r is defined through recursion. + */ + tab->next= thd->rec_tables; + thd->rec_tables= tab; } } -- cgit v1.2.1