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
9355e3e9
Commit
9355e3e9
authored
Mar 06, 2017
by
kevg
Committed by
Aleksey Midenkov
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: CREATE TABLE LIKE for versioned tables [fixes #146]
parent
17745222
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
4 deletions
+57
-4
mysql-test/suite/versioning/r/create.result
mysql-test/suite/versioning/r/create.result
+11
-0
mysql-test/suite/versioning/t/create.test
mysql-test/suite/versioning/t/create.test
+5
-0
sql/handler.cc
sql/handler.cc
+27
-0
sql/handler.h
sql/handler.h
+2
-0
sql/sql_parse.cc
sql/sql_parse.cc
+5
-4
sql/sql_table.cc
sql/sql_table.cc
+7
-0
No files found.
mysql-test/suite/versioning/r/create.result
View file @
9355e3e9
...
...
@@ -225,4 +225,15 @@ A int
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (a int) with system versioning;
create temporary table tmp with system versioning select * from t1;
create or replace table t1 (a int) with system versioning;
create table tt1 like t1;
show create table tt1;
Table Create Table
tt1 CREATE TABLE `tt1` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
drop table tt1;
drop table t1;
mysql-test/suite/versioning/t/create.test
View file @
9355e3e9
...
...
@@ -207,4 +207,9 @@ create or replace table t1 (
create
or
replace
table
t1
(
a
int
)
with
system
versioning
;
create
temporary
table
tmp
with
system
versioning
select
*
from
t1
;
create
or
replace
table
t1
(
a
int
)
with
system
versioning
;
create
table
tt1
like
t1
;
show
create
table
tt1
;
drop
table
tt1
;
drop
table
t1
;
sql/handler.cc
View file @
9355e3e9
...
...
@@ -6850,6 +6850,33 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
check_generated_type
(
table_name
,
alter_info
,
integer_fields
)));
}
bool
Vers_parse_info
::
fix_create_like
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
)
{
List_iterator
<
Create_field
>
it
(
alter_info
->
create_list
);
Create_field
*
f
=
NULL
;
DBUG_ASSERT
(
alter_info
->
create_list
.
elements
>
2
);
for
(
uint
i
=
0
;
i
<
alter_info
->
create_list
.
elements
-
1
;
++
i
)
f
=
it
++
;
DBUG_ASSERT
(
f
->
flags
&
VERS_SYS_START_FLAG
);
if
(
create_string
(
thd
->
mem_root
,
&
generated_as_row
.
start
,
f
->
field_name
)
||
create_string
(
thd
->
mem_root
,
&
period_for_system_time
.
start
,
f
->
field_name
))
return
true
;
f
=
it
++
;
DBUG_ASSERT
(
f
->
flags
&
VERS_SYS_END_FLAG
);
if
(
create_string
(
thd
->
mem_root
,
&
generated_as_row
.
end
,
f
->
field_name
)
||
create_string
(
thd
->
mem_root
,
&
period_for_system_time
.
end
,
f
->
field_name
))
return
true
;
create_info
->
options
|=
HA_VERSIONED_TABLE
;
return
false
;
}
bool
Vers_parse_info
::
check_with_conditions
(
const
char
*
table_name
)
const
{
if
(
!
generated_as_row
.
start
)
...
...
sql/handler.h
View file @
9355e3e9
...
...
@@ -1723,6 +1723,8 @@ struct Vers_parse_info
bool
integer_fields
,
const
char
*
table_name
);
bool
check_and_fix_alter
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE_SHARE
*
share
);
bool
fix_create_like
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
);
/** User has added 'WITH SYSTEM VERSIONING' to table definition */
bool
declared_with_system_versioning
:
1
;
...
...
sql/sql_parse.cc
View file @
9355e3e9
...
...
@@ -3877,10 +3877,11 @@ mysql_execute_command(THD *thd)
create_info
.
use_default_db_type
(
thd
);
DBUG_ASSERT
(
create_info
.
db_type
);
if
(
create_info
.
vers_info
.
check_and_fix_implicit
(
thd
,
&
alter_info
,
create_info
.
db_type
->
flags
&
HTON_SUPPORTS_SYS_VERSIONING
,
create_table
->
table_name
))
if
(
!
create_info
.
like
()
&&
create_info
.
vers_info
.
check_and_fix_implicit
(
thd
,
&
alter_info
,
create_info
.
db_type
->
flags
&
HTON_SUPPORTS_SYS_VERSIONING
,
create_table
->
table_name
))
{
goto
end_with_restore_list
;
}
...
...
sql/sql_table.cc
View file @
9355e3e9
...
...
@@ -5378,6 +5378,13 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
thd
->
work_part_info
=
src_table
->
table
->
part_info
->
get_clone
(
thd
);
#endif
if
(
src_table
->
table
->
versioned
()
&&
local_create_info
.
vers_info
.
fix_create_like
(
thd
,
&
local_alter_info
,
&
local_create_info
))
{
goto
err
;
}
/*
Adjust description of source table before using it for creation of
target table.
...
...
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