Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
be81b00c
Commit
be81b00c
authored
Jan 04, 2018
by
Sergei Golubchik
Committed by
Aleksey Midenkov
Jan 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-14788 System versioning cannot be based on local timestamps, as it is now
use system time, not @@timestamp
parent
c92bf28b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
21 deletions
+50
-21
mysql-test/suite/versioning/r/insert.result
mysql-test/suite/versioning/r/insert.result
+12
-0
mysql-test/suite/versioning/t/insert.test
mysql-test/suite/versioning/t/insert.test
+11
-0
sql/sql_class.h
sql/sql_class.h
+22
-18
sql/table.cc
sql/table.cc
+5
-3
No files found.
mysql-test/suite/versioning/r/insert.result
View file @
be81b00c
...
...
@@ -343,3 +343,15 @@ drop procedure test_02;
drop procedure test_03;
drop procedure test_04;
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;
mysql-test/suite/versioning/t/insert.test
View file @
be81b00c
...
...
@@ -240,3 +240,14 @@ drop procedure test_04;
drop
procedure
test_05
;
--
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
;
sql/sql_class.h
View file @
be81b00c
...
...
@@ -2358,6 +2358,8 @@ class THD :public Statement,
// track down slow pthread_create
ulonglong
prior_thr_create_utime
,
thr_create_utime
;
ulonglong
utime_after_query
;
my_time_t
system_time
;
ulong
system_time_sec_part
;
// Process indicator
struct
{
...
...
@@ -3377,36 +3379,37 @@ class THD :public Statement,
MYSQL_TIME
query_start_TIME
();
private
:
void
start_time_inc
(
)
bool
system_time_ge
(
my_time_t
secs
,
ulong
usecs
)
{
++
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
;
return
(
system_time
==
secs
&&
system_time_sec_part
>=
usecs
)
||
system_time
>
secs
;
}
void
set_
current
_time
()
void
set_
system
_time
()
{
my_hrtime_t
hrtime
=
my_hrtime
();
my_time_t
secs
=
hrtime_to_my_time
(
hrtime
);
ulong
usecs
=
hrtime_sec_part
(
hrtime
);
if
(
s
tart
_time_ge
(
secs
,
usecs
))
if
(
s
ystem
_time_ge
(
secs
,
usecs
))
{
start_time_inc
();
if
(
++
system_time_sec_part
==
HRTIME_RESOLUTION
)
{
++
system_time
;
system_time_sec_part
=
0
;
}
}
else
{
s
tart
_time
=
secs
;
s
tart
_time_sec_part
=
usecs
;
s
ystem
_time
=
secs
;
s
ystem
_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
);
}
...
...
@@ -3415,6 +3418,7 @@ class THD :public Statement,
{
if
(
user_time
.
val
)
{
set_system_time
();
start_time
=
hrtime_to_my_time
(
user_time
);
start_time_sec_part
=
hrtime_sec_part
(
user_time
);
PSI_CALL_set_thread_start_time
(
start_time
);
...
...
sql/table.cc
View file @
be81b00c
...
...
@@ -7768,7 +7768,9 @@ void TABLE::vers_update_fields()
{
if
(
!
vers_write
)
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
);
}
else
...
...
@@ -8620,9 +8622,9 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id)
if
(
!
table
&&
open
())
return
true
;
timeval
start_time
=
{
thd
->
s
tart_time
,
long
(
thd
->
start
_time_sec_part
)};
timeval
start_time
=
{
thd
->
s
ystem_time
,
long
(
thd
->
system
_time_sec_part
)};
thd
->
set_start_time
();
timeval
end_time
=
{
thd
->
s
tart_time
,
long
(
thd
->
start
_time_sec_part
)};
timeval
end_time
=
{
thd
->
s
ystem_time
,
long
(
thd
->
system
_time_sec_part
)};
store
(
FLD_TRX_ID
,
start_id
);
store
(
FLD_COMMIT_ID
,
end_id
);
store
(
FLD_BEGIN_TS
,
start_time
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment