Skip to content

Commit

Permalink
Fixed issue where the warning count fails to reset when the SET state…
Browse files Browse the repository at this point in the history
…ment generates a warning.
  • Loading branch information
rahim-kanji committed Nov 15, 2023
1 parent d67abde commit fedf984
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down

0 comments on commit fedf984

Please sign in to comment.