Commit 7fefd53f authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-14581 Server does not clear diagnostics between sessions

Amend previous patch, so it works in all cases (also for "change user"
command, and for RESET CONNECTION in 10.3)
parent 33fadbfe
...@@ -2962,10 +2962,6 @@ static bool cache_thread(THD *thd) ...@@ -2962,10 +2962,6 @@ static bool cache_thread(THD *thd)
_db_pop_(); _db_pop_();
#endif #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); set_timespec(abstime, THREAD_CACHE_TIMEOUT);
while (!abort_loop && ! wake_thread && ! kill_cached_threads) while (!abort_loop && ! wake_thread && ! kill_cached_threads)
{ {
......
...@@ -1332,6 +1332,11 @@ void THD::change_user(void) ...@@ -1332,6 +1332,11 @@ void THD::change_user(void)
cleanup_done= 0; cleanup_done= 0;
reset_killed(); reset_killed();
thd_clear_errors(this); thd_clear_errors(this);
/* Clear warnings. */
if (!get_stmt_da()->is_warning_info_empty())
get_stmt_da()->clear_warning_info(0);
init(); init();
stmt_map.reset(); stmt_map.reset();
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
......
...@@ -16348,6 +16348,7 @@ static void test_change_user() ...@@ -16348,6 +16348,7 @@ static void test_change_user()
const char *db= "mysqltest_user_test_database"; const char *db= "mysqltest_user_test_database";
int rc; int rc;
MYSQL* conn; MYSQL* conn;
MYSQL_RES* res;
DBUG_ENTER("test_change_user"); DBUG_ENTER("test_change_user");
myheader("test_change_user"); myheader("test_change_user");
...@@ -16484,6 +16485,20 @@ static void test_change_user() ...@@ -16484,6 +16485,20 @@ static void test_change_user()
rc= mysql_change_user(conn, user_pw, pw, ""); rc= mysql_change_user(conn, user_pw, pw, "");
myquery(rc); myquery(rc);
/* MDEV-14581 : Check that there are no warnings after change user.*/
rc = mysql_query(conn,"SIGNAL SQLSTATE '01000'");
myquery(rc);
rc = mysql_change_user(conn, user_pw, pw, "");
myquery(rc);
rc = mysql_query(conn, "SHOW WARNINGS");
myquery(rc);
res = mysql_store_result(conn);
rc = my_process_result_set(res);
DIE_UNLESS(rc == 0);
mysql_free_result(res);
rc= mysql_change_user(conn, user_no_pw, pw, db); rc= mysql_change_user(conn, user_no_pw, pw, db);
DIE_UNLESS(rc); DIE_UNLESS(rc);
if (! opt_silent) if (! opt_silent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment