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
91ba4f04
Commit
91ba4f04
authored
Nov 20, 2017
by
Eugene Kosov
Committed by
Aleksey Midenkov
Nov 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: prohibit column conversion to system fields for non-empty table [fixes #310]
parent
00b98264
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
3 deletions
+58
-3
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+13
-0
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+15
-0
sql/handler.cc
sql/handler.cc
+25
-1
sql/handler.h
sql/handler.h
+1
-1
sql/share/errmsg-utf8.txt
sql/share/errmsg-utf8.txt
+3
-0
sql/sql_table.cc
sql/sql_table.cc
+1
-1
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
91ba4f04
...
...
@@ -593,6 +593,19 @@ alter table t add column b int;
select * from t for system_time all;
a b
2 NULL
create or replace table non_empty (
a int,
sys_trx_start bigint(20) unsigned,
sys_trx_end bigint(20) unsigned
) engine innodb;
insert into non_empty values (1, 100, 200);
alter table non_empty
change column sys_trx_start sys_trx_start bigint(20) unsigned generated always as row start;
ERROR HY000: Can not modify column `sys_trx_start` to GENERATED ALWAYS AS ROW START/END for non-empty table
alter table non_empty
change column sys_trx_end sys_trx_end bigint(20) unsigned generated always as row end;
ERROR HY000: Can not modify column `sys_trx_end` to GENERATED ALWAYS AS ROW START/END for non-empty table
drop table non_empty;
call verify_vtq;
No A B C D
1 1 1 1 1
...
...
mysql-test/suite/versioning/t/alter.test
View file @
91ba4f04
...
...
@@ -282,6 +282,21 @@ select * from t for system_time all;
alter
table
t
add
column
b
int
;
select
*
from
t
for
system_time
all
;
create
or
replace
table
non_empty
(
a
int
,
sys_trx_start
bigint
(
20
)
unsigned
,
sys_trx_end
bigint
(
20
)
unsigned
)
engine
innodb
;
insert
into
non_empty
values
(
1
,
100
,
200
);
--
error
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
alter
table
non_empty
change
column
sys_trx_start
sys_trx_start
bigint
(
20
)
unsigned
generated
always
as
row
start
;
--
error
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
alter
table
non_empty
change
column
sys_trx_end
sys_trx_end
bigint
(
20
)
unsigned
generated
always
as
row
end
;
drop
table
non_empty
;
call
verify_vtq
;
drop
table
t
;
...
...
sql/handler.cc
View file @
91ba4f04
...
...
@@ -6913,8 +6913,9 @@ static bool add_field_to_drop_list(THD *thd, Alter_info *alter_info,
bool
Vers_parse_info
::
check_and_fix_alter
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE
_SHARE
*
shar
e
)
TABLE
*
tabl
e
)
{
TABLE_SHARE
*
share
=
table
->
s
;
bool
integer_fields
=
create_info
->
db_type
->
flags
&
HTON_NATIVE_SYS_VERSIONING
;
const
char
*
table_name
=
share
->
table_name
.
str
;
...
...
@@ -6950,6 +6951,29 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
return
false
;
}
{
List_iterator_fast
<
Create_field
>
it
(
alter_info
->
create_list
);
while
(
Create_field
*
f
=
it
++
)
{
if
(
f
->
change
.
length
&&
f
->
flags
&
(
VERS_SYS_START_FLAG
|
VERS_SYS_END_FLAG
))
{
if
(
thd
->
mdl_context
.
upgrade_shared_lock
(
table
->
mdl_ticket
,
MDL_EXCLUSIVE
,
thd
->
variables
.
lock_wait_timeout
))
return
true
;
if
(
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_TIME
))
return
true
;
if
(
0
<
table
->
file
->
records
())
{
my_error
(
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
,
MYF
(
0
),
f
->
change
.
str
);
return
true
;
}
break
;
}
}
}
if
((
versioned_fields
||
unversioned_fields
)
&&
!
share
->
versioned
)
{
my_error_as
(
ER_VERS_WRONG_PARAMS
,
ER_VERS_NOT_VERSIONED
,
MYF
(
0
),
table_name
);
...
...
sql/handler.h
View file @
91ba4f04
...
...
@@ -1745,7 +1745,7 @@ struct Vers_parse_info
HA_CREATE_INFO
*
create_info
,
const
char
*
table_name
);
bool
check_and_fix_alter
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE
_SHARE
*
shar
e
);
HA_CREATE_INFO
*
create_info
,
TABLE
*
tabl
e
);
bool
fix_create_like
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE_LIST
*
table
);
...
...
sql/share/errmsg-utf8.txt
View file @
91ba4f04
...
...
@@ -7907,3 +7907,6 @@ ER_VERS_SYS_FIELD_NOT_HIDDEN
ER_NOT_LOG_TABLE
eng "Table `%s.%s` is not a log table"
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
eng "Can not modify column `%s` to GENERATED ALWAYS AS ROW START/END for non-empty table"
sql/sql_table.cc
View file @
91ba4f04
...
...
@@ -8977,7 +8977,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
DBUG_RETURN
(
true
);
if
(
create_info
->
vers_info
.
check_and_fix_alter
(
thd
,
alter_info
,
create_info
,
table
->
s
))
table
))
{
DBUG_RETURN
(
true
);
}
...
...
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