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
d72462a2
Commit
d72462a2
authored
Dec 27, 2017
by
Eugene Kosov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: TRX_ID to TIMESTAMP versioning switch [fixes #428]
parent
d1e4c5d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
26 deletions
+44
-26
mysql-test/suite/versioning/r/trx_id.result
mysql-test/suite/versioning/r/trx_id.result
+12
-0
mysql-test/suite/versioning/t/trx_id.test
mysql-test/suite/versioning/t/trx_id.test
+11
-0
sql/handler.cc
sql/handler.cc
+21
-26
No files found.
mysql-test/suite/versioning/r/trx_id.result
View file @
d72462a2
...
...
@@ -79,6 +79,18 @@ algorithm=copy;
select check_result(count(*) = @tmp) from mysql.transaction_registry;
check_result(count(*) = @tmp)
[CORRECT]
# TRX_ID to TIMESTAMP versioning switch
create or replace table t1 (
x int,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
period for system_time (sys_start, sys_end)
) engine innodb with system versioning;
insert into t1 values (1);
alter table t1 drop column sys_start, drop column sys_end;
select sys_end = 18446744073709551615 as transaction_based from t1 for system_time all;
transaction_based
1
drop table t1;
set global system_versioning_transaction_registry=off;
drop function check_result;
mysql-test/suite/versioning/t/trx_id.test
View file @
d72462a2
...
...
@@ -81,6 +81,17 @@ alter table t1
select
check_result
(
count
(
*
)
=
@
tmp
)
from
mysql
.
transaction_registry
;
--
echo
# TRX_ID to TIMESTAMP versioning switch
create
or
replace
table
t1
(
x
int
,
sys_start
bigint
unsigned
as
row
start
invisible
,
sys_end
bigint
unsigned
as
row
end
invisible
,
period
for
system_time
(
sys_start
,
sys_end
)
)
engine
innodb
with
system
versioning
;
insert
into
t1
values
(
1
);
alter
table
t1
drop
column
sys_start
,
drop
column
sys_end
;
select
sys_end
=
18446744073709551615
as
transaction_based
from
t1
for
system_time
all
;
drop
table
t1
;
set
global
system_versioning_transaction_registry
=
off
;
drop
function
check_result
;
sql/handler.cc
View file @
d72462a2
...
...
@@ -6852,8 +6852,7 @@ bool Vers_parse_info::is_end(const Create_field &f) const
return
f
.
flags
&
VERS_SYS_END_FLAG
;
}
static
Create_field
*
vers_init_sys_field
(
THD
*
thd
,
const
char
*
field_name
,
int
flags
)
static
Create_field
*
vers_init_sys_field
(
THD
*
thd
,
const
char
*
field_name
,
int
flags
,
bool
integer
)
{
Create_field
*
f
=
new
(
thd
->
mem_root
)
Create_field
();
if
(
!
f
)
...
...
@@ -6864,8 +6863,17 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name,
f
->
field_name
.
length
=
strlen
(
field_name
);
f
->
charset
=
system_charset_info
;
f
->
flags
=
flags
;
f
->
set_handler
(
&
type_handler_timestamp2
);
f
->
length
=
MAX_DATETIME_PRECISION
;
if
(
integer
)
{
f
->
set_handler
(
&
type_handler_longlong
);
f
->
length
=
MY_INT64_NUM_DECIMAL_DIGITS
-
1
;
f
->
flags
|=
UNSIGNED_FLAG
;
}
else
{
f
->
set_handler
(
&
type_handler_timestamp2
);
f
->
length
=
MAX_DATETIME_PRECISION
;
}
f
->
invisible
=
INVISIBLE_SYSTEM
;
if
(
f
->
check
(
thd
))
...
...
@@ -6877,7 +6885,7 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name,
static
bool
vers_create_sys_field
(
THD
*
thd
,
const
char
*
field_name
,
Alter_info
*
alter_info
,
int
flags
)
{
Create_field
*
f
=
vers_init_sys_field
(
thd
,
field_name
,
flags
);
Create_field
*
f
=
vers_init_sys_field
(
thd
,
field_name
,
flags
,
false
);
if
(
!
f
)
return
true
;
...
...
@@ -6887,23 +6895,6 @@ static bool vers_create_sys_field(THD *thd, const char *field_name,
return
false
;
}
static
bool
vers_change_sys_field
(
THD
*
thd
,
const
char
*
field_name
,
Alter_info
*
alter_info
,
int
flags
,
const
char
*
change
)
{
Create_field
*
f
=
vers_init_sys_field
(
thd
,
field_name
,
flags
);
if
(
!
f
)
return
true
;
f
->
change
.
str
=
change
;
f
->
change
.
length
=
strlen
(
change
);
alter_info
->
flags
|=
Alter_info
::
ALTER_CHANGE_COLUMN
;
alter_info
->
create_list
.
push_back
(
f
);
return
false
;
}
const
LString
Vers_parse_info
::
default_start
=
"sys_trx_start"
;
const
LString
Vers_parse_info
::
default_end
=
"sys_trx_end"
;
...
...
@@ -7330,11 +7321,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return
true
;
}
if
(
vers_change_sys_field
(
thd
,
name
,
alter_info
,
f
->
flags
&
VERS_SYSTEM_FIELD
,
name
))
{
bool
integer
=
table
->
vers_start_field
()
->
type
()
==
MYSQL_TYPE_LONGLONG
;
Create_field
*
field
=
vers_init_sys_field
(
thd
,
name
,
f
->
flags
&
VERS_SYSTEM_FIELD
,
integer
);
if
(
!
field
)
return
true
;
}
field
->
change
=
f
->
field_name
;
alter_info
->
flags
|=
Alter_info
::
ALTER_CHANGE_COLUMN
;
alter_info
->
create_list
.
push_back
(
field
);
it
.
remove
();
...
...
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