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
46d572dd
Commit
46d572dd
authored
Jun 27, 2017
by
Eugene Kosov
Committed by
Aleksey Midenkov
Jun 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: default engine fix in create from versioned [fixes #206]
parent
faab918e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
3 deletions
+64
-3
mysql-test/suite/versioning/r/create.result
mysql-test/suite/versioning/r/create.result
+18
-0
mysql-test/suite/versioning/t/create.test
mysql-test/suite/versioning/t/create.test
+29
-0
sql/handler.cc
sql/handler.cc
+17
-3
No files found.
mysql-test/suite/versioning/r/create.result
View file @
46d572dd
...
...
@@ -61,6 +61,15 @@ drop table tmp;
end if;
end~~
drop table if exists t1;
create function if not exists non_default_engine()
returns varchar(255)
deterministic
begin
if default_engine() = 'innodb' then
return 'myisam';
end if;
return 'innodb';
end~~
create table t1 (
x1 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start comment 'start',
...
...
@@ -328,9 +337,18 @@ select st, en from t2 for system_time all where y = 2 into @st, @en;
select y from t2 for system_time all where st = @st and en = @en;
y
2
create or replace table t1 (a int) with system versioning engine INNODB_OR_MYISAM;
create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
create or replace table t2 engine INNODB_OR_MYISAM as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
ERROR HY000: `sys_trx_start` must be of type `SYS_TRX_TYPE` for versioned table `t2`
create or replace table t1 (a int, id int) with system versioning engine INNODB_OR_MYISAM;
create or replace table t2 (b int, id int);
create or replace table t3 as
select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
drop table t1;
drop table t2;
drop table t3;
drop function non_default_engine;
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
drop function default_engine;
...
...
mysql-test/suite/versioning/t/create.test
View file @
46d572dd
...
...
@@ -4,7 +4,21 @@
drop
table
if
exists
t1
;
--
enable_warnings
delimiter
~~
;
create
function
if
not
exists
non_default_engine
()
returns
varchar
(
255
)
deterministic
begin
if
default_engine
()
=
'innodb'
then
return
'myisam'
;
end
if
;
return
'innodb'
;
end
~~
delimiter
;
~~
--
let
$sys_datatype
=
`select sys_datatype()`
--
let
$default_engine
=
`select default_engine()`
--
let
$non_default_engine
=
`select non_default_engine()`
--
replace_result
"bigint unsigned"
SYS_TRX_TYPE
timestamp
(
6
)
SYS_TRX_TYPE
eval
create
table
t1
(
...
...
@@ -257,8 +271,23 @@ select y from t2 for system_time all where st = @st and en = @en;
select
st
,
en
from
t2
for
system_time
all
where
y
=
2
into
@
st
,
@
en
;
select
y
from
t2
for
system_time
all
where
st
=
@
st
and
en
=
@
en
;
--
replace_result
innodb
INNODB_OR_MYISAM
myisam
INNODB_OR_MYISAM
eval
create
or
replace
table
t1
(
a
int
)
with
system
versioning
engine
$non_default_engine
;
create
or
replace
table
t2
as
select
a
,
sys_trx_start
,
sys_trx_end
from
t1
for
system_time
all
;
--
replace_result
innodb
INNODB_OR_MYISAM
myisam
INNODB_OR_MYISAM
"BIGINT(20) UNSIGNED"
SYS_TRX_TYPE
"TIMESTAMP(6)"
SYS_TRX_TYPE
--
error
ER_VERS_FIELD_WRONG_TYPE
eval
create
or
replace
table
t2
engine
$default_engine
as
select
a
,
sys_trx_start
,
sys_trx_end
from
t1
for
system_time
all
;
--
replace_result
innodb
INNODB_OR_MYISAM
myisam
INNODB_OR_MYISAM
eval
create
or
replace
table
t1
(
a
int
,
id
int
)
with
system
versioning
engine
$non_default_engine
;
create
or
replace
table
t2
(
b
int
,
id
int
);
create
or
replace
table
t3
as
select
t2
.
b
,
t1
.
a
,
t1
.
sys_trx_start
,
t1
.
sys_trx_end
from
t2
inner
join
t1
on
t2
.
id
=
t1
.
id
;
drop
table
t1
;
drop
table
t2
;
drop
table
t3
;
drop
function
non_default_engine
;
--
source
suite
/
versioning
/
common_finish
.
inc
sql/handler.cc
View file @
46d572dd
...
...
@@ -6663,9 +6663,6 @@ bool Vers_parse_info::check_and_fix_implicit(
HA_CREATE_INFO
*
create_info
,
const
char
*
table_name
)
{
bool
integer_fields
=
create_info
->
db_type
->
flags
&
HTON_NATIVE_SYS_VERSIONING
;
SELECT_LEX
&
slex
=
thd
->
lex
->
select_lex
;
int
vers_tables
=
0
;
bool
from_select
=
slex
.
item_list
.
elements
?
true
:
false
;
...
...
@@ -6677,6 +6674,21 @@ bool Vers_parse_info::check_and_fix_implicit(
if
(
table
->
table
&&
table
->
table
->
versioned
())
vers_tables
++
;
}
// Possibly override default storage engine to match
// one used in source table.
if
(
!
(
create_info
->
used_fields
&
HA_CREATE_USED_ENGINE
))
{
List_iterator_fast
<
Create_field
>
it
(
alter_info
->
create_list
);
while
(
Create_field
*
f
=
it
++
)
{
if
(
is_trx_start
(
*
f
)
||
is_trx_end
(
*
f
))
{
create_info
->
db_type
=
f
->
field
->
orig_table
->
file
->
ht
;
break
;
}
}
}
}
// CREATE ... SELECT: if at least one table in SELECT is versioned,
...
...
@@ -6750,6 +6762,8 @@ bool Vers_parse_info::check_and_fix_implicit(
}
}
bool
integer_fields
=
create_info
->
db_type
->
flags
&
HTON_NATIVE_SYS_VERSIONING
;
if
(
vers_tables
>
0
)
{
if
(
!
generated_as_row
.
start
&&
!
generated_as_row
.
end
)
...
...
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