From df93b4f259515a5603e05b85d0acd45f0afd62c9 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 1 Nov 2023 11:56:24 +0100 Subject: [PATCH] Fix MDEV-30820 problem found by Monty --- mysql-test/main/log_slow_debug.result | 7 +++++-- mysql-test/main/log_slow_debug.test | 11 ++++++++--- sql/sql_class.cc | 2 -- sql/sql_class.h | 6 +++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/log_slow_debug.result b/mysql-test/main/log_slow_debug.result index 88019d87322..64397fbe3f5 100644 --- a/mysql-test/main/log_slow_debug.result +++ b/mysql-test/main/log_slow_debug.result @@ -231,15 +231,18 @@ SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL log_output= "TABLE"; SET GLOBAL slow_query_log= ON; SET SESSION long_query_time= 0; -SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows"; +SET debug_dbug="+d,debug_huge_number_of_examined_rows"; SELECT * FROM tab_MDEV_30820 ORDER BY 1; ID A 1 0 2 0 -SET GLOBAL debug_dbug=@old_dbug; +SET debug_dbug=@old_dbug; SET @@long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; +SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%"; +rows_examined sql_text +18446744073708551615 SELECT * FROM tab_MDEV_30820 ORDER BY 1 drop table tab_MDEV_30820; # # End of 10.4 test diff --git a/mysql-test/main/log_slow_debug.test b/mysql-test/main/log_slow_debug.test index 5c8385f2fc9..e93c4a9675a 100644 --- a/mysql-test/main/log_slow_debug.test +++ b/mysql-test/main/log_slow_debug.test @@ -104,16 +104,21 @@ SET GLOBAL log_output= "TABLE"; SET GLOBAL slow_query_log= ON; SET SESSION long_query_time= 0; -SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows"; +SET debug_dbug="+d,debug_huge_number_of_examined_rows"; +--disable_ps_protocol +--disable_view_protocol SELECT * FROM tab_MDEV_30820 ORDER BY 1; -SET GLOBAL debug_dbug=@old_dbug; - +--enable_view_protocol +--enable_ps_protocol +SET debug_dbug=@old_dbug; ## Reset to initial values SET @@long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; +SELECT rows_examined, sql_text from mysql.slow_log where sql_text like "SELECT%FROM tab_MDEV_30820%"; + drop table tab_MDEV_30820; --echo # diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 479ff0e68d0..93f42a462e5 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5682,8 +5682,6 @@ void THD::set_examined_row_count(ha_rows count) void THD::inc_sent_row_count(ha_rows count) { m_sent_row_count+= count; - DBUG_EXECUTE_IF("debug_huge_number_of_examined_rows", - m_examined_row_count= (ULONGLONG_MAX - 1000000);); MYSQL_SET_STATEMENT_ROWS_SENT(m_statement_psi, m_sent_row_count); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 3e95b614756..c7f36ce3d8c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3013,7 +3013,11 @@ public: { return m_sent_row_count; } ha_rows get_examined_row_count() const - { return m_examined_row_count; } + { + DBUG_EXECUTE_IF("debug_huge_number_of_examined_rows", + return (ULONGLONG_MAX - 1000000);); + return m_examined_row_count; + } ulonglong get_affected_rows() const { return affected_rows; }