mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
versioning: use @@timestamp
Don't use hidden system time in versioning, but keep the system time logic in THD to workaround low-res system clock and replication not versioned to versioned. This reverts MDEV-14788 (System versioning cannot be based on local timestamps, as it is now). Versioning is based on local timestamps again, but timestamps are protected by MDEV-15923 (option to control who can set session @@timestamp).
This commit is contained in:
@ -3437,16 +3437,13 @@ public:
|
||||
{ query_start_sec_part_used=1; return start_time_sec_part; }
|
||||
MYSQL_TIME query_start_TIME();
|
||||
|
||||
private:
|
||||
struct {
|
||||
my_hrtime_t start;
|
||||
my_time_t sec;
|
||||
ulong sec_part;
|
||||
} system_time;
|
||||
|
||||
ulong systime_sec_part() { query_start_sec_part_used=1; return system_time.sec_part; }
|
||||
my_time_t systime() { return system_time.sec; }
|
||||
|
||||
private:
|
||||
void set_system_time()
|
||||
{
|
||||
my_hrtime_t hrtime= my_hrtime();
|
||||
@ -3471,29 +3468,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void set_system_time_from_user_time(bool with_sec_part)
|
||||
{
|
||||
if (with_sec_part)
|
||||
{
|
||||
system_time.sec= start_time;
|
||||
system_time.sec_part= start_time_sec_part;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (system_time.sec == start_time)
|
||||
system_time.sec_part++;
|
||||
else
|
||||
{
|
||||
system_time.sec= start_time;
|
||||
system_time.sec_part= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
inline void set_start_time()
|
||||
{
|
||||
set_system_time();
|
||||
if (user_time.val)
|
||||
{
|
||||
start_time= hrtime_to_my_time(user_time);
|
||||
@ -3501,6 +3478,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
set_system_time();
|
||||
start_time= system_time.sec;
|
||||
start_time_sec_part= system_time.sec_part;
|
||||
}
|
||||
@ -3511,6 +3489,7 @@ public:
|
||||
set_start_time();
|
||||
start_utime= utime_after_lock= microsecond_interval_timer();
|
||||
}
|
||||
/* only used in SET @@timestamp=... */
|
||||
inline void set_time(my_hrtime_t t)
|
||||
{
|
||||
user_time= t;
|
||||
@ -3526,13 +3505,22 @@ public:
|
||||
set_time(); // note that BINLOG itself requires SUPER
|
||||
else
|
||||
{
|
||||
start_time= t;
|
||||
start_time_sec_part= sec_part > TIME_MAX_SECOND_PART ? 0 : sec_part;
|
||||
if (sec_part <= TIME_MAX_SECOND_PART)
|
||||
{
|
||||
start_time= system_time.sec= t;
|
||||
start_time_sec_part= system_time.sec_part= sec_part;
|
||||
}
|
||||
else if (t != system_time.sec)
|
||||
{
|
||||
start_time= system_time.sec= t;
|
||||
start_time_sec_part= system_time.sec_part= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
start_time= t;
|
||||
start_time_sec_part= ++system_time.sec_part;
|
||||
}
|
||||
user_time.val= hrtime_from_time(start_time) + start_time_sec_part;
|
||||
if (slave_thread)
|
||||
set_system_time_from_user_time(sec_part <= TIME_MAX_SECOND_PART);
|
||||
else // BINLOG command
|
||||
set_system_time();
|
||||
PSI_CALL_set_thread_start_time(start_time);
|
||||
start_utime= utime_after_lock= microsecond_interval_timer();
|
||||
}
|
||||
|
Reference in New Issue
Block a user