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
f96b1a4e
Commit
f96b1a4e
authored
Jan 10, 2018
by
Eugene Kosov
Committed by
Sergei Golubchik
Jan 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-14798 Add, drop system versioning semantic and syntax
parent
eedab70c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
65 deletions
+50
-65
mysql-test/suite/versioning/r/alter.result
mysql-test/suite/versioning/r/alter.result
+7
-24
mysql-test/suite/versioning/t/alter.test
mysql-test/suite/versioning/t/alter.test
+9
-22
sql/handler.cc
sql/handler.cc
+30
-18
sql/handler.h
sql/handler.h
+3
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-0
No files found.
mysql-test/suite/versioning/r/alter.result
View file @
f96b1a4e
...
...
@@ -125,7 +125,10 @@ with system versioning;
select * from t for system_time all;
a
alter table t drop column row_start;
ERROR HY000: Wrong parameters for `t`: missing 'DROP COLUMN row_end'
alter table t drop column row_end;
ERROR HY000: Wrong parameters for `t`: missing 'DROP COLUMN row_start'
alter table t drop column row_start, drop column row_end;
select * from t for system_time all;
a
alter table t drop column row_start;
...
...
@@ -383,30 +386,6 @@ ERROR HY000: Can not change system versioning field `row_start`
insert into t values (1);
alter table t modify column row_start bigint unsigned;
ERROR HY000: Can not change system versioning field `row_start`
create or replace table t (
a int,
row_start timestamp(6) as row start invisible,
row_end timestamp(6) as row end invisible,
period for system_time(row_start, row_end)
) with system versioning;
select * from t;
a
alter table t drop system versioning;
ERROR HY000: System versioning field `row_start` exists
alter table t drop column row_start;
select * from t;
a
alter table t drop system versioning;
ERROR HY000: System versioning field `row_end` exists
alter table t drop column row_end;
select * from t;
a
alter table t drop system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set system_versioning_alter_history= SURVIVE;
ERROR 42000: Variable 'system_versioning_alter_history' can't be set to the value of 'SURVIVE'
set system_versioning_alter_history= DROP;
...
...
@@ -465,5 +444,9 @@ ERROR 42S21: Duplicate column name 'row_start'
set statement system_versioning_alter_history=keep for
alter table t1 add column row_start timestamp(6);
ERROR 42S21: Duplicate column name 'row_start'
# MDEV-14798 Add, drop system versioning semantic and syntax
create or replace table t (a int) with system versioning;
alter table t add period for system_time(sys_trx_start, sys_trx_end);
ERROR HY000: Table `t` is already system-versioned
drop database test;
create database test;
mysql-test/suite/versioning/t/alter.test
View file @
f96b1a4e
...
...
@@ -78,8 +78,11 @@ create or replace table t (
with
system
versioning
;
select
*
from
t
for
system_time
all
;
--
error
ER_MISSING
alter
table
t
drop
column
row_start
;
--
error
ER_MISSING
alter
table
t
drop
column
row_end
;
alter
table
t
drop
column
row_start
,
drop
column
row_end
;
select
*
from
t
for
system_time
all
;
--
error
ER_CANT_DROP_FIELD_OR_KEY
...
...
@@ -263,28 +266,6 @@ insert into t values (1);
--
error
ER_VERS_ALTER_SYSTEM_FIELD
alter
table
t
modify
column
row_start
bigint
unsigned
;
create
or
replace
table
t
(
a
int
,
row_start
timestamp
(
6
)
as
row
start
invisible
,
row_end
timestamp
(
6
)
as
row
end
invisible
,
period
for
system_time
(
row_start
,
row_end
)
)
with
system
versioning
;
select
*
from
t
;
--
error
ER_VERS_SYS_FIELD_EXISTS
alter
table
t
drop
system
versioning
;
alter
table
t
drop
column
row_start
;
select
*
from
t
;
--
error
ER_VERS_SYS_FIELD_EXISTS
alter
table
t
drop
system
versioning
;
alter
table
t
drop
column
row_end
;
select
*
from
t
;
alter
table
t
drop
system
versioning
;
show
create
table
t
;
## These experimental options are now disabled
--
error
ER_WRONG_VALUE_FOR_VAR
...
...
@@ -404,5 +385,11 @@ alter table t1 add column row_start int;
set
statement
system_versioning_alter_history
=
keep
for
alter
table
t1
add
column
row_start
timestamp
(
6
);
--
echo
# MDEV-14798 Add, drop system versioning semantic and syntax
create
or
replace
table
t
(
a
int
)
with
system
versioning
;
--
error
ER_VERS_ALREADY_VERSIONED
alter
table
t
add
period
for
system_time
(
sys_trx_start
,
sys_trx_end
);
drop
database
test
;
create
database
test
;
sql/handler.cc
View file @
f96b1a4e
...
...
@@ -7133,11 +7133,17 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return
false
;
}
static
bool
add_field_to_drop_list
(
THD
*
thd
,
Alter_info
*
alter_info
,
Field
*
field
)
static
bool
add_field_to_drop_list_if_not_exists
(
THD
*
thd
,
Alter_info
*
alter_info
,
Field
*
field
)
{
DBUG_ASSERT
(
field
);
DBUG_ASSERT
(
field
->
field_name
.
str
);
List_iterator_fast
<
Alter_drop
>
it
(
alter_info
->
drop_list
);
while
(
Alter_drop
*
drop
=
it
++
)
{
if
(
!
my_strcasecmp
(
system_charset_info
,
field
->
field_name
.
str
,
drop
->
name
))
return
false
;
}
alter_info
->
flags
|=
Alter_info
::
ALTER_DROP_COLUMN
;
Alter_drop
*
ad
=
new
(
thd
->
mem_root
)
Alter_drop
(
Alter_drop
::
COLUMN
,
field
->
field_name
.
str
,
false
);
...
...
@@ -7201,21 +7207,8 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return
true
;
}
if
(
share
->
vers_start_field
()
->
invisible
<
INVISIBLE_SYSTEM
)
{
my_error
(
ER_VERS_SYS_FIELD_EXISTS
,
MYF
(
0
),
share
->
vers_start_field
()
->
field_name
.
str
);
return
true
;
}
if
(
share
->
vers_end_field
()
->
invisible
<
INVISIBLE_SYSTEM
)
{
my_error
(
ER_VERS_SYS_FIELD_EXISTS
,
MYF
(
0
),
share
->
vers_end_field
()
->
field_name
.
str
);
return
true
;
}
if
(
add_field_to_drop_list
(
thd
,
alter_info
,
share
->
vers_start_field
())
||
add_field_to_drop_list
(
thd
,
alter_info
,
share
->
vers_end_field
()))
if
(
add_field_to_drop_list_if_not_exists
(
thd
,
alter_info
,
share
->
vers_start_field
())
||
add_field_to_drop_list_if_not_exists
(
thd
,
alter_info
,
share
->
vers_end_field
()))
return
true
;
if
(
share
->
primary_key
!=
MAX_KEY
&&
!
is_adding_primary_key
(
alter_info
)
&&
...
...
@@ -7275,6 +7268,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return
true
;
}
if
(
add_period
)
{
if
(
share
->
versioned
)
{
my_error
(
ER_VERS_ALREADY_VERSIONED
,
MYF
(
0
),
table_name
);
return
true
;
}
}
if
(
share
->
versioned
)
{
// copy info from existing table
...
...
@@ -7346,6 +7348,16 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
if
(
done_start
&&
done_end
)
break
;
}
if
((
done_start
||
done_end
)
&&
done_start
!=
done_end
)
{
String
tmp
;
tmp
.
append
(
"DROP COLUMN "
);
tmp
.
append
(
done_start
?
table
->
vers_end_field
()
->
field_name
:
table
->
vers_start_field
()
->
field_name
);
my_error
(
ER_MISSING
,
MYF
(
0
),
table_name
,
tmp
.
c_ptr
());
return
true
;
}
}
return
false
;
...
...
@@ -7426,7 +7438,7 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_
bool
Vers_parse_info
::
need_check
(
const
Alter_info
*
alter_info
)
const
{
return
versioned_fields
||
unversioned_fields
||
return
versioned_fields
||
unversioned_fields
||
add_period
||
alter_info
->
flags
&
Alter_info
::
ALTER_ADD_SYSTEM_VERSIONING
||
alter_info
->
flags
&
Alter_info
::
ALTER_DROP_SYSTEM_VERSIONING
||
*
this
;
}
...
...
sql/handler.h
View file @
f96b1a4e
...
...
@@ -1725,7 +1725,8 @@ struct Vers_parse_info
{
Vers_parse_info
()
:
versioned_fields
(
false
),
unversioned_fields
(
false
)
unversioned_fields
(
false
),
add_period
(
false
)
{}
struct
start_end_t
...
...
@@ -1789,6 +1790,7 @@ struct Vers_parse_info
*/
bool
versioned_fields
:
1
;
bool
unversioned_fields
:
1
;
bool
add_period
:
1
;
// ADD PERIOD FOR SYSTEM_TIME was specified
};
/**
...
...
sql/sql_yacc.yy
View file @
f96b1a4e
...
...
@@ -8080,6 +8080,7 @@ alter_list_item:
}
| ADD period_for_system_time
{
Lex->vers_get_info().add_period= true;
}
| add_column '(' create_field_list ')'
{
...
...
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