mirror of
https://github.com/MariaDB/server.git
synced 2025-07-04 01:23:45 +03:00
MDEV-14788 System versioning cannot be based on local timestamps, as it is now
use system time, not @@timestamp
This commit is contained in:
committed by
Aleksey Midenkov
parent
c92bf28b5f
commit
be81b00c84
@ -343,3 +343,15 @@ drop procedure test_02;
|
|||||||
drop procedure test_03;
|
drop procedure test_03;
|
||||||
drop procedure test_04;
|
drop procedure test_04;
|
||||||
drop procedure test_05;
|
drop procedure test_05;
|
||||||
|
set timestamp=1000000019;
|
||||||
|
select now() < sysdate();
|
||||||
|
now() < sysdate()
|
||||||
|
1
|
||||||
|
create table t1 (a int) with system versioning;
|
||||||
|
insert t1 values (1);
|
||||||
|
select * from t1 for system_time as of now(6);
|
||||||
|
a
|
||||||
|
select * from t1 for system_time as of sysdate(6);
|
||||||
|
a
|
||||||
|
1
|
||||||
|
drop table t1;
|
||||||
|
@ -240,3 +240,14 @@ drop procedure test_04;
|
|||||||
drop procedure test_05;
|
drop procedure test_05;
|
||||||
|
|
||||||
-- source suite/versioning/common_finish.inc
|
-- source suite/versioning/common_finish.inc
|
||||||
|
|
||||||
|
#
|
||||||
|
# MDEV-14788 System versioning cannot be based on local timestamps, as it is now
|
||||||
|
#
|
||||||
|
set timestamp=1000000019;
|
||||||
|
select now() < sysdate();
|
||||||
|
create table t1 (a int) with system versioning;
|
||||||
|
insert t1 values (1);
|
||||||
|
select * from t1 for system_time as of now(6);
|
||||||
|
select * from t1 for system_time as of sysdate(6);
|
||||||
|
drop table t1;
|
||||||
|
@ -2358,6 +2358,8 @@ public:
|
|||||||
// track down slow pthread_create
|
// track down slow pthread_create
|
||||||
ulonglong prior_thr_create_utime, thr_create_utime;
|
ulonglong prior_thr_create_utime, thr_create_utime;
|
||||||
ulonglong utime_after_query;
|
ulonglong utime_after_query;
|
||||||
|
my_time_t system_time;
|
||||||
|
ulong system_time_sec_part;
|
||||||
|
|
||||||
// Process indicator
|
// Process indicator
|
||||||
struct {
|
struct {
|
||||||
@ -3377,36 +3379,37 @@ public:
|
|||||||
MYSQL_TIME query_start_TIME();
|
MYSQL_TIME query_start_TIME();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void start_time_inc()
|
bool system_time_ge(my_time_t secs, ulong usecs)
|
||||||
{
|
{
|
||||||
++start_time_sec_part;
|
return (system_time == secs && system_time_sec_part >= usecs) ||
|
||||||
if (start_time_sec_part == HRTIME_RESOLUTION)
|
system_time > secs;
|
||||||
{
|
|
||||||
++start_time;
|
|
||||||
start_time_sec_part= 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start_time_ge(my_time_t secs, ulong usecs)
|
void set_system_time()
|
||||||
{
|
|
||||||
return (start_time == secs && start_time_sec_part >= usecs) ||
|
|
||||||
start_time > secs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_current_time()
|
|
||||||
{
|
{
|
||||||
my_hrtime_t hrtime= my_hrtime();
|
my_hrtime_t hrtime= my_hrtime();
|
||||||
my_time_t secs= hrtime_to_my_time(hrtime);
|
my_time_t secs= hrtime_to_my_time(hrtime);
|
||||||
ulong usecs= hrtime_sec_part(hrtime);
|
ulong usecs= hrtime_sec_part(hrtime);
|
||||||
if (start_time_ge(secs, usecs))
|
if (system_time_ge(secs, usecs))
|
||||||
{
|
{
|
||||||
start_time_inc();
|
if (++system_time_sec_part == HRTIME_RESOLUTION)
|
||||||
|
{
|
||||||
|
++system_time;
|
||||||
|
system_time_sec_part= 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start_time= secs;
|
system_time= secs;
|
||||||
start_time_sec_part= usecs;
|
system_time_sec_part= usecs;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_current_time()
|
||||||
|
{
|
||||||
|
set_system_time();
|
||||||
|
start_time= system_time;
|
||||||
|
start_time_sec_part= system_time_sec_part;
|
||||||
PSI_CALL_set_thread_start_time(start_time);
|
PSI_CALL_set_thread_start_time(start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3415,6 +3418,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (user_time.val)
|
if (user_time.val)
|
||||||
{
|
{
|
||||||
|
set_system_time();
|
||||||
start_time= hrtime_to_my_time(user_time);
|
start_time= hrtime_to_my_time(user_time);
|
||||||
start_time_sec_part= hrtime_sec_part(user_time);
|
start_time_sec_part= hrtime_sec_part(user_time);
|
||||||
PSI_CALL_set_thread_start_time(start_time);
|
PSI_CALL_set_thread_start_time(start_time);
|
||||||
|
@ -7768,7 +7768,9 @@ void TABLE::vers_update_fields()
|
|||||||
{
|
{
|
||||||
if (!vers_write)
|
if (!vers_write)
|
||||||
return;
|
return;
|
||||||
if (vers_start_field()->set_time())
|
vers_start_field()->set_notnull();
|
||||||
|
if (vers_start_field()->store_timestamp(in_use->system_time,
|
||||||
|
in_use->system_time_sec_part))
|
||||||
DBUG_ASSERT(0);
|
DBUG_ASSERT(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -8620,9 +8622,9 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id)
|
|||||||
if (!table && open())
|
if (!table && open())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
timeval start_time= {thd->start_time, long(thd->start_time_sec_part)};
|
timeval start_time= {thd->system_time, long(thd->system_time_sec_part)};
|
||||||
thd->set_start_time();
|
thd->set_start_time();
|
||||||
timeval end_time= {thd->start_time, long(thd->start_time_sec_part)};
|
timeval end_time= {thd->system_time, long(thd->system_time_sec_part)};
|
||||||
store(FLD_TRX_ID, start_id);
|
store(FLD_TRX_ID, start_id);
|
||||||
store(FLD_COMMIT_ID, end_id);
|
store(FLD_COMMIT_ID, end_id);
|
||||||
store(FLD_BEGIN_TS, start_time);
|
store(FLD_BEGIN_TS, start_time);
|
||||||
|
Reference in New Issue
Block a user