mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-8001 - mysql_reset_thd_for_next_command() takes 0.04% in OLTP RO
Removed mysql_reset_thd_for_next_command(). Call THD::reset_for_next_command() directly instead. mysql_reset_thd_for_next_command() overhead dropped 0.04% -> out of radar. THD::reset_for_next_command() overhead didn't increase.
This commit is contained in:
@ -1337,7 +1337,7 @@ Event_job_data::execute(THD *thd, bool drop)
|
||||
|
||||
DBUG_ENTER("Event_job_data::execute");
|
||||
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
/*
|
||||
MySQL parser currently assumes that current database is either
|
||||
|
@ -5796,7 +5796,7 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
*/
|
||||
lex_start(thd);
|
||||
thd->lex->local_file= local_fname;
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
/*
|
||||
We test replicate_*_db rules. Note that we have already prepared
|
||||
@ -6539,7 +6539,7 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
thd->variables.gtid_domain_id= this->domain_id;
|
||||
thd->variables.gtid_seq_no= this->seq_no;
|
||||
rgi->gtid_ev_flags2= flags2;
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
if (opt_gtid_strict_mode && opt_bin_log && opt_log_slave_updates)
|
||||
{
|
||||
@ -7347,9 +7347,9 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
mysql.gtid_slave_pos table with the GTID of the current transaction.
|
||||
|
||||
Therefore, it acts much like a normal SQL statement, so we need to do
|
||||
mysql_reset_thd_for_next_command() as if starting a new statement.
|
||||
THD::reset_for_next_command() as if starting a new statement.
|
||||
*/
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
/*
|
||||
Record any GTID in the same transaction, so slave state is transactionally
|
||||
consistent.
|
||||
@ -8578,7 +8578,7 @@ int Append_block_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
as the present method does not call mysql_parse().
|
||||
*/
|
||||
lex_start(thd);
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
/* old copy may exist already */
|
||||
mysql_file_delete(key_file_log_event_data, fname, MYF(0));
|
||||
if ((fd= mysql_file_create(key_file_log_event_data,
|
||||
@ -9640,18 +9640,18 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
Lock_tables() reads the contents of thd->lex, so they must be
|
||||
initialized.
|
||||
|
||||
We also call the mysql_reset_thd_for_next_command(), since this
|
||||
We also call the THD::reset_for_next_command(), since this
|
||||
is the logical start of the next "statement". Note that this
|
||||
call might reset the value of current_stmt_binlog_format, so
|
||||
we need to do any changes to that value after this function.
|
||||
*/
|
||||
delete_explain_query(thd->lex);
|
||||
lex_start(thd);
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
/*
|
||||
The current statement is just about to begin and
|
||||
has not yet modified anything. Note, all.modified is reset
|
||||
by mysql_reset_thd_for_next_command.
|
||||
by THD::reset_for_next_command().
|
||||
*/
|
||||
thd->transaction.stmt.modified_non_trans_table= FALSE;
|
||||
thd->transaction.stmt.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "sql_base.h" // close_tables_for_reopen
|
||||
#include "key.h" // key_copy
|
||||
#include "lock.h" // mysql_unlock_tables
|
||||
#include "sql_parse.h" // mysql_reset_thd_for_next_command
|
||||
#include "rpl_rli.h"
|
||||
#include "rpl_utility.h"
|
||||
#endif
|
||||
@ -82,14 +81,14 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)
|
||||
Lock_tables() reads the contents of ev_thd->lex, so they must be
|
||||
initialized.
|
||||
|
||||
We also call the mysql_reset_thd_for_next_command(), since this
|
||||
We also call the THD::reset_for_next_command(), since this
|
||||
is the logical start of the next "statement". Note that this
|
||||
call might reset the value of current_stmt_binlog_format, so
|
||||
we need to do any changes to that value after this function.
|
||||
*/
|
||||
delete_explain_query(thd->lex);
|
||||
lex_start(ev_thd);
|
||||
mysql_reset_thd_for_next_command(ev_thd);
|
||||
ev_thd->reset_for_next_command();
|
||||
|
||||
/*
|
||||
This is a row injection, so we flag the "statement" as
|
||||
|
@ -533,7 +533,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
|
||||
}
|
||||
|
||||
if (!in_statement)
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
DBUG_EXECUTE_IF("gtid_inject_record_gtid",
|
||||
{
|
||||
|
@ -1485,7 +1485,7 @@ rpl_load_gtid_slave_state(THD *thd)
|
||||
goto end;
|
||||
array_inited= true;
|
||||
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
tlist.init_one_table(STRING_WITH_LEN("mysql"),
|
||||
rpl_gtid_slave_state_table_name.str,
|
||||
|
@ -2685,7 +2685,7 @@ public:
|
||||
can not continue. In particular, disables activation of
|
||||
CONTINUE or EXIT handlers of stored routines.
|
||||
Reset in the end of processing of the current user request, in
|
||||
@see mysql_reset_thd_for_next_command().
|
||||
@see THD::reset_for_next_command().
|
||||
*/
|
||||
bool is_fatal_error;
|
||||
/**
|
||||
|
@ -1593,7 +1593,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
packet= arg_end + 1;
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
lex_start(thd);
|
||||
/* Must be before we init the table list. */
|
||||
if (lower_case_table_names)
|
||||
@ -6723,15 +6723,8 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize)
|
||||
(prepared or conventional). It is not called by substatements of
|
||||
routines.
|
||||
|
||||
@todo Remove mysql_reset_thd_for_next_command and only use the
|
||||
member function.
|
||||
|
||||
@todo Call it after we use THD for queries, not before.
|
||||
*/
|
||||
void mysql_reset_thd_for_next_command(THD *thd)
|
||||
{
|
||||
thd->reset_for_next_command();
|
||||
}
|
||||
|
||||
void THD::reset_for_next_command()
|
||||
{
|
||||
@ -7005,7 +6998,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
|
||||
if (thd->wsrep_conflict_state == ABORTED ||
|
||||
thd->wsrep_conflict_state == CERT_FAILURE)
|
||||
{
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
thd->killed= NOT_KILLED;
|
||||
if (is_autocommit &&
|
||||
thd->lex->sql_command != SQLCOM_SELECT &&
|
||||
@ -7101,13 +7094,13 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
|
||||
of (among others) lex->safe_to_cache_query and thd->server_status,
|
||||
which are reset respectively in
|
||||
- lex_start()
|
||||
- mysql_reset_thd_for_next_command()
|
||||
- THD::reset_for_next_command()
|
||||
So, initializing the lexical analyser *before* using the query cache
|
||||
is required for the cache to work properly.
|
||||
FIXME: cleanup the dependencies in the code to simplify this.
|
||||
*/
|
||||
lex_start(thd);
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0)
|
||||
{
|
||||
@ -7221,7 +7214,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length)
|
||||
if (!(error= parser_state.init(thd, rawbuf, length)))
|
||||
{
|
||||
lex_start(thd);
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
if (!parse_sql(thd, & parser_state, NULL, true) &&
|
||||
all_tables_not_ok(thd, lex->select_lex.table_list.first))
|
||||
|
@ -88,7 +88,6 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length);
|
||||
void mysql_init_select(LEX *lex);
|
||||
void mysql_parse(THD *thd, char *rawbuf, uint length,
|
||||
Parser_state *parser_state);
|
||||
void mysql_reset_thd_for_next_command(THD *thd);
|
||||
bool mysql_new_select(LEX *lex, bool move_down);
|
||||
void create_select_for_variable(const char *var_name);
|
||||
void create_table_set_open_action_and_adjust_tables(LEX *lex);
|
||||
|
@ -2309,7 +2309,7 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length)
|
||||
DBUG_PRINT("prep_query", ("%s", packet));
|
||||
|
||||
/* First of all clear possible warnings from the previous command */
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
if (! (stmt= new Prepared_statement(thd)))
|
||||
goto end; /* out of memory: error is set in Sql_alloc */
|
||||
@ -2700,7 +2700,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
|
||||
packet+= 9; /* stmt_id + 5 bytes of flags */
|
||||
|
||||
/* First of all clear possible warnings from the previous command */
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
if (!(stmt= find_prepared_statement(thd, stmt_id)))
|
||||
{
|
||||
@ -2799,7 +2799,7 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length)
|
||||
DBUG_ENTER("mysqld_stmt_fetch");
|
||||
|
||||
/* First of all clear possible warnings from the previous command */
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
status_var_increment(thd->status_var.com_stmt_fetch);
|
||||
if (!(stmt= find_prepared_statement(thd, stmt_id)))
|
||||
@ -2859,7 +2859,7 @@ void mysqld_stmt_reset(THD *thd, char *packet)
|
||||
DBUG_ENTER("mysqld_stmt_reset");
|
||||
|
||||
/* First of all clear possible warnings from the previous command */
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
|
||||
status_var_increment(thd->status_var.com_stmt_reset);
|
||||
if (!(stmt= find_prepared_statement(thd, stmt_id)))
|
||||
|
@ -192,7 +192,7 @@ void wsrep_replay_transaction(THD *thd)
|
||||
thd->wsrep_conflict_state= REPLAYING;
|
||||
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
|
||||
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
thd->reset_for_next_command();
|
||||
thd->killed= NOT_KILLED;
|
||||
close_thread_tables(thd);
|
||||
if (thd->locked_tables_mode && thd->lock)
|
||||
|
Reference in New Issue
Block a user