From fedf984d2af79fe77e280bf9e496ac8e917536fe Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 15 Nov 2023 18:31:27 +0500 Subject: [PATCH] Fixed issue where the warning count fails to reset when the SET statement generates a warning. --- lib/mysql_connection.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 2bb5e2b8e4..3788287b13 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -554,11 +554,13 @@ void MySQL_Connection::update_warning_count_from_connection() { // 'mysql_thread_query_digest' is set to false, fetching that statement from the cache may still contain the digest text. // To prevent this, we will check the digest text in conjunction with 'mysql_thread_query_digest' to verify whether it // is enabled or disabled. - if (myds && myds->sess && (myds->sess->CurrentQuery.QueryParserArgs.digest_text || - (myds->sess->CurrentQuery.stmt_info && myds->sess->CurrentQuery.stmt_info->digest_text && - mysql_thread___query_digests == true))) { - const bool handle_warnings_enabled = parent->myhgc->handle_warnings_enabled(); - if (handle_warnings_enabled && mysql_errno(mysql) == 0 && mysql_warning_count(mysql) > 0) { + if (myds && myds->sess && myds->sess->CurrentQuery.QueryParserArgs.digest_text) { + const char* dig_text = myds->sess->CurrentQuery.QueryParserArgs.digest_text; + const size_t dig_len = strlen(dig_text); + // SHOW WARNINGS doesn't have any impact warning count, + // so we are replication same behaviour here + if (parent->myhgc->handle_warnings_enabled() && + (dig_len != 13 || strncasecmp(dig_text, "SHOW WARNINGS", 13) != 0)) { warning_count = mysql_warning_count(mysql); } } @@ -571,8 +573,7 @@ void MySQL_Connection::update_warning_count_from_statement() { // is enabled or disabled. if (myds && myds->sess && myds->sess->CurrentQuery.stmt_info && myds->sess->CurrentQuery.stmt_info->digest_text && mysql_thread___query_digests == true) { - const bool handle_warnings_enabled = parent->myhgc->handle_warnings_enabled(); - if (handle_warnings_enabled && mysql_stmt_warning_count(query.stmt) > 0) { + if (parent->myhgc->handle_warnings_enabled()) { warning_count = mysql_stmt_warning_count(query.stmt); } }