mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
SQL: low timer resolution hack for THD::start_time [#307]
Windows platform is suffered with this problem.
This commit is contained in:
@ -3323,11 +3323,37 @@ public:
|
|||||||
inline ulong query_start_sec_part()
|
inline ulong query_start_sec_part()
|
||||||
{ query_start_sec_part_used=1; return start_time_sec_part; }
|
{ query_start_sec_part_used=1; return start_time_sec_part; }
|
||||||
MYSQL_TIME query_start_TIME();
|
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()
|
inline void set_current_time()
|
||||||
{
|
{
|
||||||
my_hrtime_t hrtime= my_hrtime();
|
my_hrtime_t hrtime= my_hrtime();
|
||||||
start_time= hrtime_to_my_time(hrtime);
|
my_time_t secs= hrtime_to_my_time(hrtime);
|
||||||
start_time_sec_part= hrtime_sec_part(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
|
#ifdef HAVE_PSI_THREAD_INTERFACE
|
||||||
PSI_THREAD_CALL(set_thread_start_time)(start_time);
|
PSI_THREAD_CALL(set_thread_start_time)(start_time);
|
||||||
#endif
|
#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};
|
timeval start_time= {thd->start_time, thd->start_time_sec_part};
|
||||||
store(FLD_TRX_ID, trx_id);
|
store(FLD_TRX_ID, trx_id);
|
||||||
store(FLD_COMMIT_ID, commit_id);
|
store(FLD_COMMIT_ID, commit_id);
|
||||||
store(FLD_COMMIT_TS, commit_ts);
|
|
||||||
store(FLD_BEGIN_TS, start_time);
|
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);
|
store_iso_level(thd->tx_isolation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user