Skip to content

Commit

Permalink
Revert "SQL: Backup_query_start_time RAII"
Browse files Browse the repository at this point in the history
This reverts commit 07b1a77.
  • Loading branch information
vuvova committed Jan 13, 2018
1 parent a544f92 commit 376b0ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
7 changes: 5 additions & 2 deletions sql/sp_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3272,7 +3272,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
int res;
bool save_enable_slow_log;
const CSET_STRING query_backup= thd->query_string;
Backup_query_start_time time_info;
QUERY_START_TIME_INFO time_info;
Sub_statement_state backup_state;
DBUG_ENTER("sp_instr_stmt::execute");
DBUG_PRINT("info", ("command: %d", m_lex_keeper.sql_command()));
Expand All @@ -3288,7 +3288,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
Save start time info for the CALL statement and overwrite it with the
current time for log_slow_statement() to log the individual query timing.
*/
time_info.backup(*thd);
thd->backup_query_start_time(&time_info);
thd->set_time();
}
thd->store_slow_query_state(&backup_state);
Expand Down Expand Up @@ -3354,6 +3354,9 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
thd->get_stmt_da()->reset_diagnostics_area();
}
}
/* Restore the original query start time */
if (thd->enable_slow_log)
thd->restore_query_start_time(&time_info);

DBUG_RETURN(res || thd->is_error());
}
Expand Down
30 changes: 4 additions & 26 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -2089,36 +2089,14 @@ struct QUERY_START_TIME_INFO
my_time_t start_time;
ulong start_time_sec_part;
ulonglong start_utime, utime_after_lock;
};

class Backup_query_start_time : public QUERY_START_TIME_INFO
{
QUERY_START_TIME_INFO *m_origin;

public:
Backup_query_start_time() : m_origin(NULL)
{}
Backup_query_start_time(QUERY_START_TIME_INFO &origin)
void backup_query_start_time(QUERY_START_TIME_INFO *backup)
{
backup(origin);
*backup= *this;
}
~Backup_query_start_time()
void restore_query_start_time(QUERY_START_TIME_INFO *backup)
{
restore();
}
void backup(QUERY_START_TIME_INFO &origin)
{
m_origin= &origin;
QUERY_START_TIME_INFO *backup_= this;
*backup_= origin;
}
void restore()
{
if (m_origin)
{
*m_origin= *this;
m_origin= NULL;
}
*this= *backup;
}
};

Expand Down

0 comments on commit 376b0ea

Please sign in to comment.