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
414651c8
Commit
414651c8
authored
May 23, 2017
by
Eugene Kosov
Committed by
Aleksey Midenkov
May 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: ALTER ADD COLUMN order fix
parent
3bdf5b60
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
42 deletions
+13
-42
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+12
-16
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+0
-5
sql/handler.cc
sql/handler.cc
+1
-21
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
414651c8
...
...
@@ -77,9 +77,9 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column c int;
...
...
@@ -87,10 +87,10 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column d int first;
...
...
@@ -99,10 +99,10 @@ Table Create Table
t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column e int after d;
...
...
@@ -112,26 +112,22 @@ t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column f int after sys_trx_start;
ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field
alter table t add column f int after sys_trx_end;
ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field
alter table t drop column a;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t drop column sys_trx_start;
...
...
@@ -179,9 +175,9 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t;
...
...
@@ -339,9 +335,9 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t;
...
...
@@ -366,9 +362,9 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t;
...
...
mysql-test/suite/versioning/t/alter.test
View file @
414651c8
...
...
@@ -59,11 +59,6 @@ show create table t;
alter
table
t
add
column
e
int
after
d
;
show
create
table
t
;
--
error
ER_VERS_WRONG_PARAMS
alter
table
t
add
column
f
int
after
sys_trx_start
;
--
error
ER_VERS_WRONG_PARAMS
alter
table
t
add
column
f
int
after
sys_trx_end
;
alter
table
t
drop
column
a
;
show
create
table
t
;
...
...
sql/handler.cc
View file @
414651c8
...
...
@@ -6874,31 +6874,11 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
if
(
alter_info
->
create_list
.
elements
)
{
DBUG_ASSERT
(
share
->
fields
>
2
);
const
char
*
after_this
=
share
->
field
[
share
->
fields
-
3
]
->
field_name
;
List_iterator
<
Create_field
>
it
(
alter_info
->
create_list
);
List_iterator_fast
<
Create_field
>
it
(
alter_info
->
create_list
);
while
(
Create_field
*
f
=
it
++
)
{
if
(
f
->
versioning
==
Column_definition
::
WITHOUT_VERSIONING
)
f
->
flags
|=
VERS_OPTIMIZED_UPDATE_FLAG
;
if
(
f
->
change
)
continue
;
if
(
f
->
after
)
{
if
(
is_trx_start
(
f
->
after
)
||
is_trx_end
(
f
->
after
))
{
my_error
(
ER_VERS_WRONG_PARAMS
,
MYF
(
0
),
table_name
,
"Can not put new field after system versioning field"
);
return
true
;
}
continue
;
}
// TODO: ALTER_COLUMN_ORDER?
f
->
after
=
after_this
;
}
}
...
...
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