From 869e67c92f4b1cc251cc719e8cc7a8111b43f671 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 7 May 2024 20:38:34 +0200 Subject: [PATCH] cleanup: remove thd->stmt_changes_data what is done in the plugin - stays in the plugin --- plugin/query_response_time/plugin.cc | 4 +++- sql/handler.cc | 1 - sql/sql_class.cc | 5 +---- sql/sql_class.h | 4 +--- sql/sql_parse.cc | 2 -- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/plugin/query_response_time/plugin.cc b/plugin/query_response_time/plugin.cc index c528648f187..7ad50ac4bac 100644 --- a/plugin/query_response_time/plugin.cc +++ b/plugin/query_response_time/plugin.cc @@ -231,7 +231,9 @@ static void query_response_time_audit_notify(MYSQL_THD thd, if (event_general->event_subclass == MYSQL_AUDIT_GENERAL_STATUS && query_response_time_should_log(thd)) { - QUERY_TYPE query_type= (thd->stmt_changes_data ? WRITE : READ); + bool stmt_changes_data= is_update_query(thd->last_sql_command) + || thd->transaction->stmt.is_trx_read_write(); + QUERY_TYPE query_type= stmt_changes_data ? WRITE : READ; #ifndef DBUG_OFF if (THDVAR(thd, exec_time_debug)) { diff --git a/sql/handler.cc b/sql/handler.cc index 5eb6724926c..c0211accb2a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5288,7 +5288,6 @@ void handler::mark_trx_read_write_internal() if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE) ha_info->set_trx_read_write(); } - thd->stmt_changes_data= 1; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 559a6c68f82..34d5210b7f3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -661,7 +661,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) bootstrap(0), derived_tables_processing(FALSE), waiting_on_group_commit(FALSE), has_waiter(FALSE), - spcont(NULL), + last_sql_command(SQLCOM_END), spcont(NULL), m_parser_state(NULL), #ifndef EMBEDDED_LIBRARY audit_plugin_version(-1), @@ -6034,7 +6034,6 @@ void THD::store_slow_query_state(Sub_statement_state *backup) backup->tmp_tables_size= tmp_tables_size; backup->tmp_tables_used= tmp_tables_used; backup->handler_stats= handler_stats; - backup->stmt_changes_data= stmt_changes_data; } /* Reset variables related to slow query log */ @@ -6063,7 +6062,6 @@ void THD::reset_slow_query_state(Sub_statement_state *backup) } if ((variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE)) handler_stats.reset(); - stmt_changes_data= 0; // Can be used by audit plugins } /* @@ -6095,7 +6093,6 @@ void THD::add_slow_query_state(Sub_statement_state *backup) } if ((variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE)) handler_stats.add(&backup->handler_stats); - stmt_changes_data|= backup->stmt_changes_data; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 6e118d59dcc..c9ab2a953e8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2122,7 +2122,6 @@ public: bool last_insert_id_used; bool in_stored_procedure; bool do_union; - bool stmt_changes_data; enum enum_check_fields count_cuted_fields; }; @@ -3863,7 +3862,6 @@ public: See comment above regarding transaction_isolation. */ bool tx_read_only; - bool stmt_changes_data; enum_check_fields count_cuted_fields; DYNAMIC_ARRAY user_var_events; /* For user variables replication */ @@ -3998,7 +3996,7 @@ public: execution stack when the event turns out to be ignored. */ int slave_expected_error; - enum_sql_command last_sql_command; // Last sql_command exceuted in mysql_execute_command() + enum_sql_command last_sql_command; // Last sql_command executed in mysql_execute_command() sp_rcontext *spcont; // SP runtime context diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e4ad364a251..467d9b2083a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3515,8 +3515,6 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) like mysql_audit_plugin. */ thd->last_sql_command= lex->sql_command; - thd->stmt_changes_data|= (sql_command_flags[lex->sql_command] & - CF_CHANGES_DATA); /* Reset warning count for each query that uses tables