summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/t/warnings-master.opt2
-rw-r--r--mysql-test/t/warnings.test12
-rw-r--r--sql/mysqld.cc4
3 files changed, 17 insertions, 1 deletions
diff --git a/mysql-test/t/warnings-master.opt b/mysql-test/t/warnings-master.opt
index 21356507809..1aa6001465b 100644
--- a/mysql-test/t/warnings-master.opt
+++ b/mysql-test/t/warnings-master.opt
@@ -1 +1 @@
---loose-skip-innodb
+--loose-skip-innodb --thread-handling=one-thread-per-connection
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 573f3c538c7..9360d32f93d 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -286,3 +286,15 @@ SHOW WARNINGS;
DROP TABLE t1;
DROP FUNCTION f1;
+
+# MDEV-14581 Warning info not cleared when caching THD
+connect (con1,localhost,root,,);
+SELECT TIME('10:10:10.11111111111');
+disconnect con1;
+
+connect (con2,localhost,root,,);
+SHOW WARNINGS;
+disconnect con2;
+
+connection default;
+
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1cf15abebdc..6783231022c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2961,6 +2961,10 @@ static bool cache_thread(THD *thd)
_db_pop_();
#endif
+ /* Clear warnings. */
+ if (!thd->get_stmt_da()->is_warning_info_empty())
+ thd->get_stmt_da()->clear_warning_info(thd->query_id);
+
set_timespec(abstime, THREAD_CACHE_TIMEOUT);
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
{