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
229c5281
Commit
229c5281
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: hide system fields instead of drop [closes #210]
parent
46d572dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
8 deletions
+81
-8
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+25
-2
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+25
-2
sql/handler.cc
sql/handler.cc
+31
-4
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
229c5281
...
...
@@ -130,10 +130,33 @@ t CREATE TABLE `t` (
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t (
a int,
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))
with system versioning;
select * from t for system_time all;
a sys_trx_start sys_trx_end
alter table t drop column sys_trx_start;
alter table t drop column sys_trx_end;
select * from t for system_time all;
a
alter table t drop column sys_trx_start;
ERROR
HY000: Wrong parameters for `t`: Can not drop system versioning field
ERROR
42000: Can't DROP COLUMN `sys_trx_start`; check that it exists
alter table t drop column sys_trx_end;
ERROR HY000: Wrong parameters for `t`: Can not drop system versioning field
ERROR 42000: Can't DROP COLUMN `sys_trx_end`; check that it exists
create or replace table t (
a int,
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))
with system versioning;
select * from t for system_time all;
a sys_trx_start sys_trx_end
alter table t drop column sys_trx_start, drop column sys_trx_end;
select * from t for system_time all;
a
create or replace table t(
a int
);
...
...
mysql-test/suite/versioning/t/alter.test
View file @
229c5281
...
...
@@ -62,10 +62,33 @@ show create table t;
alter
table
t
drop
column
a
;
show
create
table
t
;
--
error
ER_VERS_WRONG_PARAMS
create
or
replace
table
t
(
a
int
,
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
))
with
system
versioning
;
select
*
from
t
for
system_time
all
;
alter
table
t
drop
column
sys_trx_start
;
--
error
ER_VERS_WRONG_PARAMS
alter
table
t
drop
column
sys_trx_end
;
select
*
from
t
for
system_time
all
;
--
error
ER_CANT_DROP_FIELD_OR_KEY
alter
table
t
drop
column
sys_trx_start
;
--
error
ER_CANT_DROP_FIELD_OR_KEY
alter
table
t
drop
column
sys_trx_end
;
create
or
replace
table
t
(
a
int
,
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
))
with
system
versioning
;
select
*
from
t
for
system_time
all
;
alter
table
t
drop
column
sys_trx_start
,
drop
column
sys_trx_end
;
select
*
from
t
for
system_time
all
;
create
or
replace
table
t
(
a
int
...
...
sql/handler.cc
View file @
229c5281
...
...
@@ -6630,6 +6630,7 @@ static bool vers_create_sys_field(THD *thd, const char *field_name,
return
true
;
alter_info
->
create_list
.
push_back
(
f
);
alter_info
->
flags
|=
Alter_info
::
ALTER_ADD_COLUMN
;
return
false
;
}
...
...
@@ -6885,15 +6886,41 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
if
(
alter_info
->
drop_list
.
elements
)
{
bool
done_start
=
false
;
bool
done_end
=
false
;
List_iterator
<
Alter_drop
>
it
(
alter_info
->
drop_list
);
while
(
Alter_drop
*
d
=
it
++
)
while
(
Alter_drop
*
d
=
it
++
)
{
if
(
is_trx_start
(
d
->
name
)
||
is_trx_end
(
d
->
name
))
const
char
*
name
=
d
->
name
;
Field
*
f
=
NULL
;
if
(
!
done_start
&&
is_trx_start
(
name
))
{
my_error
(
ER_VERS_WRONG_PARAMS
,
MYF
(
0
),
table_name
,
"Can not drop system versioning field"
);
f
=
share
->
vers_start_field
();
done_start
=
true
;
}
else
if
(
!
done_end
&&
is_trx_end
(
name
))
{
f
=
share
->
vers_end_field
();
done_end
=
true
;
}
else
continue
;
if
(
f
->
flags
&
HIDDEN_FLAG
)
{
my_error
(
ER_CANT_DROP_FIELD_OR_KEY
,
MYF
(
0
),
d
->
type_name
(),
name
);
return
true
;
}
if
(
vers_create_sys_field
(
thd
,
name
,
alter_info
,
f
->
flags
&
(
VERS_SYS_START_FLAG
|
VERS_SYS_END_FLAG
),
integer_fields
))
{
return
true
;
}
if
(
done_start
&&
done_end
)
break
;
}
}
...
...
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