mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
SQL: low timer resolution hack for THD::start_time [#307]
Windows platform is suffered with this problem.
This commit is contained in:
parent
3d51315912
commit
5aae304fa0
2 changed files with 35 additions and 3 deletions
|
@ -3323,11 +3323,37 @@ public:
|
|||
inline ulong query_start_sec_part()
|
||||
{ query_start_sec_part_used=1; return start_time_sec_part; }
|
||||
MYSQL_TIME query_start_TIME();
|
||||
|
||||
void start_time_inc()
|
||||
{
|
||||
++start_time_sec_part;
|
||||
if (start_time_sec_part == HRTIME_RESOLUTION)
|
||||
{
|
||||
++start_time;
|
||||
start_time_sec_part= 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool start_time_ge(my_time_t secs, ulong usecs)
|
||||
{
|
||||
return (start_time == secs && start_time_sec_part >= usecs) ||
|
||||
start_time > secs;
|
||||
}
|
||||
|
||||
inline void set_current_time()
|
||||
{
|
||||
my_hrtime_t hrtime= my_hrtime();
|
||||
start_time= hrtime_to_my_time(hrtime);
|
||||
start_time_sec_part= hrtime_sec_part(hrtime);
|
||||
my_time_t secs= hrtime_to_my_time(hrtime);
|
||||
ulong usecs= hrtime_sec_part(hrtime);
|
||||
if (start_time_ge(secs, usecs))
|
||||
{
|
||||
start_time_inc();
|
||||
}
|
||||
else
|
||||
{
|
||||
start_time= secs;
|
||||
start_time_sec_part= usecs;
|
||||
}
|
||||
#ifdef HAVE_PSI_THREAD_INTERFACE
|
||||
PSI_THREAD_CALL(set_thread_start_time)(start_time);
|
||||
#endif
|
||||
|
|
|
@ -8536,8 +8536,14 @@ void TR_table::store_data(ulonglong trx_id, ulonglong commit_id, timeval commit_
|
|||
timeval start_time= {thd->start_time, thd->start_time_sec_part};
|
||||
store(FLD_TRX_ID, trx_id);
|
||||
store(FLD_COMMIT_ID, commit_id);
|
||||
store(FLD_COMMIT_TS, commit_ts);
|
||||
store(FLD_BEGIN_TS, start_time);
|
||||
if (thd->start_time_ge(commit_ts.tv_sec, commit_ts.tv_usec))
|
||||
{
|
||||
thd->start_time_inc();
|
||||
commit_ts.tv_sec= thd->start_time;
|
||||
commit_ts.tv_usec= thd->start_time_sec_part;
|
||||
}
|
||||
store(FLD_COMMIT_TS, commit_ts);
|
||||
store_iso_level(thd->tx_isolation);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue