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
18405e5f
Commit
18405e5f
authored
Dec 14, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Partitioning syntax for versioning
partition by system_time ( partition p0 history, partition pn current )
parent
f1490133
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
114 additions
and
111 deletions
+114
-111
mysql-test/suite/versioning/r/partition.result
mysql-test/suite/versioning/r/partition.result
+48
-48
mysql-test/suite/versioning/t/partition.test
mysql-test/suite/versioning/t/partition.test
+32
-32
sql/ha_partition.cc
sql/ha_partition.cc
+1
-1
sql/lex.h
sql/lex.h
+1
-0
sql/partition_element.h
sql/partition_element.h
+2
-2
sql/partition_info.cc
sql/partition_info.cc
+12
-12
sql/partition_info.h
sql/partition_info.h
+4
-4
sql/share/errmsg-utf8.txt
sql/share/errmsg-utf8.txt
+2
-2
sql/sql_partition.cc
sql/sql_partition.cc
+6
-6
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-4
No files found.
mysql-test/suite/versioning/r/partition.result
View file @
18405e5f
...
@@ -29,50 +29,50 @@ x
...
@@ -29,50 +29,50 @@ x
300
300
create or replace table t1 (x int)
create or replace table t1 (x int)
partition by system_time (
partition by system_time (
partition p0
versioning
,
partition p0
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
ERROR HY000: System Versioning required: t1
ERROR HY000: System Versioning required: t1
create or replace table t1 (x int);
create or replace table t1 (x int);
alter table t1
alter table t1
partition by system_time (
partition by system_time (
partition p0
versioning
,
partition p0
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
Got one of the listed errors
Got one of the listed errors
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition p0
as of current_timestamp
);
partition p0
current
);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition p0
as of current_timestamp
,
partition p0
current
,
partition p1
as of current_timestamp
);
partition p1
current
);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
);
partition p1
history
);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition pn
as of current_timestamp
,
partition pn
current
,
partition p0
versioning
);
partition p0
history
);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition p0
versioning
,
partition p0
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
alter table t1 add partition (
alter table t1 add partition (
partition p1
as of current_timestamp
);
partition p1
current
);
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
alter table t1 add partition (
alter table t1 add partition (
partition p1
versioning
);
partition p1
history
);
Warnings:
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple
`VERSIONING`
partitions.
Warning 4115 Maybe missing parameters: no rotation condition for multiple
HISTORY
partitions.
show create table t1;
show create table t1;
Table Create Table
Table Create Table
t1 CREATE TABLE `t1` (
t1 CREATE TABLE `t1` (
...
@@ -82,15 +82,15 @@ t1 CREATE TABLE `t1` (
...
@@ -82,15 +82,15 @@ t1 CREATE TABLE `t1` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITION BY SYSTEM_TIME
(PARTITION `p0`
VERSIONING
ENGINE = ${INNODB_OR_MYISAM},
(PARTITION `p0`
HISTORY
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1`
VERSIONING
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1`
HISTORY
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn`
AS OF CURRENT_TIMESTAMP
ENGINE = ${INNODB_OR_MYISAM})
PARTITION `pn`
CURRENT
ENGINE = ${INNODB_OR_MYISAM})
insert into t1 values (1), (2);
insert into t1 values (1), (2);
alter table t1 drop partition pn;
alter table t1 drop partition pn;
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
alter table t1 drop partition p1;
alter table t1 drop partition p1;
alter table t1 drop partition p0;
alter table t1 drop partition p0;
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one
HISTORY and exactly one last CURRENT
select x from t1;
select x from t1;
x
x
1
1
...
@@ -98,8 +98,8 @@ x
...
@@ -98,8 +98,8 @@ x
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time (
partition by system_time (
partition p0
versioning
,
partition p0
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
set @now= now(6);
set @now= now(6);
insert into t1 values (1);
insert into t1 values (1);
set @ts_start= sys_commit_ts('sys_trx_start');
set @ts_start= sys_commit_ts('sys_trx_start');
...
@@ -178,16 +178,16 @@ select @ts2 = @ts3;
...
@@ -178,16 +178,16 @@ select @ts2 = @ts3;
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time limit 0 (
partition by system_time limit 0 (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
,
partition p1
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time limit 1 (
partition by system_time limit 1 (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
,
partition p1
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
show create table t1;
show create table t1;
Table Create Table
Table Create Table
t1 CREATE TABLE `t1` (
t1 CREATE TABLE `t1` (
...
@@ -197,9 +197,9 @@ t1 CREATE TABLE `t1` (
...
@@ -197,9 +197,9 @@ t1 CREATE TABLE `t1` (
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p0`
VERSIONING
ENGINE = ${INNODB_OR_MYISAM},
(PARTITION `p0`
HISTORY
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1`
VERSIONING
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `p1`
HISTORY
ENGINE = ${INNODB_OR_MYISAM},
PARTITION `pn`
AS OF CURRENT_TIMESTAMP
ENGINE = ${INNODB_OR_MYISAM})
PARTITION `pn`
CURRENT
ENGINE = ${INNODB_OR_MYISAM})
alter table t1 drop partition non_existent;
alter table t1 drop partition non_existent;
ERROR HY000: Error in list of partitions to DROP
ERROR HY000: Error in list of partitions to DROP
insert into t1 values (1), (2);
insert into t1 values (1), (2);
...
@@ -219,7 +219,7 @@ x
...
@@ -219,7 +219,7 @@ x
insert into t1 values (3);
insert into t1 values (3);
delete from t1;
delete from t1;
Warnings:
Warnings:
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more
VERSIONING
partitions
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more
HISTORY
partitions
select * from t1 partition (p1);
select * from t1 partition (p1);
x
x
2
2
...
@@ -227,16 +227,16 @@ x
...
@@ -227,16 +227,16 @@ x
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time interval 0 second (
partition by system_time interval 0 second (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
,
partition p1
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
create or replace table t1 (x int)
create or replace table t1 (x int)
with system versioning
with system versioning
partition by system_time interval 1 second (
partition by system_time interval 1 second (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
,
partition p1
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
insert into t1 values (1), (2), (3);
insert into t1 values (1), (2), (3);
select * from t1 partition (pn);
select * from t1 partition (pn);
x
x
...
@@ -261,9 +261,9 @@ with system versioning
...
@@ -261,9 +261,9 @@ with system versioning
partition by system_time limit 1
partition by system_time limit 1
subpartition by key (x)
subpartition by key (x)
subpartitions 2 (
subpartitions 2 (
partition p0
versioning
,
partition p0
history
,
partition p1
versioning
,
partition p1
history
,
partition pn
as of current_timestamp
);
partition pn
current
);
insert into t1 (x) values (1), (2), (3);
insert into t1 (x) values (1), (2), (3);
select * from t1 partition (pnsp0);
select * from t1 partition (pnsp0);
x
x
...
@@ -275,7 +275,7 @@ x
...
@@ -275,7 +275,7 @@ x
delete from t1;
delete from t1;
Warnings:
Warnings:
Note 4116 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
Note 4116 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more
VERSIONING
partitions
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more
HISTORY
partitions
select * from t1 partition (p0sp0);
select * from t1 partition (p0sp0);
x
x
1
1
...
...
mysql-test/suite/versioning/t/partition.test
View file @
18405e5f
...
@@ -26,56 +26,56 @@ select * from t1 partition (p1);
...
@@ -26,56 +26,56 @@ select * from t1 partition (p1);
--
error
ER_VERSIONING_REQUIRED
--
error
ER_VERSIONING_REQUIRED
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
partition
by
system_time
(
partition
by
system_time
(
partition
p0
versioning
,
partition
p0
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
create
or
replace
table
t1
(
x
int
);
create
or
replace
table
t1
(
x
int
);
--
error
ER_VERSIONING_REQUIRED
,
ER_VERSIONING_REQUIRED
--
error
ER_VERSIONING_REQUIRED
,
ER_VERSIONING_REQUIRED
alter
table
t1
alter
table
t1
partition
by
system_time
(
partition
by
system_time
(
partition
p0
versioning
,
partition
p0
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
--
error
ER_VERS_WRONG_PARTS
--
error
ER_VERS_WRONG_PARTS
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
p0
as
of
current_timestamp
);
partition
p0
current
);
--
error
ER_VERS_WRONG_PARTS
--
error
ER_VERS_WRONG_PARTS
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
p0
as
of
current_timestamp
,
partition
p0
current
,
partition
p1
as
of
current_timestamp
);
partition
p1
current
);
--
error
ER_VERS_WRONG_PARTS
--
error
ER_VERS_WRONG_PARTS
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
);
partition
p1
history
);
--
error
ER_VERS_WRONG_PARTS
--
error
ER_VERS_WRONG_PARTS
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
pn
as
of
current_timestamp
,
partition
pn
current
,
partition
p0
versioning
);
partition
p0
history
);
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
p0
versioning
,
partition
p0
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
# alter table
# alter table
--
error
ER_VERS_WRONG_PARTS
--
error
ER_VERS_WRONG_PARTS
alter
table
t1
add
partition
(
alter
table
t1
add
partition
(
partition
p1
as
of
current_timestamp
);
partition
p1
current
);
alter
table
t1
add
partition
(
alter
table
t1
add
partition
(
partition
p1
versioning
);
partition
p1
history
);
--
replace_result
InnoDB
$
{
INNODB_OR_MYISAM
}
MyISAM
$
{
INNODB_OR_MYISAM
}
"bigint(20) unsigned"
$
{
SYS_TRX_TYPE
}
timestamp
(
6
)
$
{
SYS_TRX_TYPE
}
--
replace_result
InnoDB
$
{
INNODB_OR_MYISAM
}
MyISAM
$
{
INNODB_OR_MYISAM
}
"bigint(20) unsigned"
$
{
SYS_TRX_TYPE
}
timestamp
(
6
)
$
{
SYS_TRX_TYPE
}
show
create
table
t1
;
show
create
table
t1
;
...
@@ -94,8 +94,8 @@ select x from t1;
...
@@ -94,8 +94,8 @@ select x from t1;
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
(
partition
by
system_time
(
partition
p0
versioning
,
partition
p0
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
set
@
now
=
now
(
6
);
set
@
now
=
now
(
6
);
insert
into
t1
values
(
1
);
insert
into
t1
values
(
1
);
...
@@ -157,16 +157,16 @@ select @ts2 = @ts3;
...
@@ -157,16 +157,16 @@ select @ts2 = @ts3;
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
limit
0
(
partition
by
system_time
limit
0
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
,
partition
p1
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
limit
1
(
partition
by
system_time
limit
1
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
,
partition
p1
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
--
replace_result
InnoDB
$
{
INNODB_OR_MYISAM
}
MyISAM
$
{
INNODB_OR_MYISAM
}
"bigint(20) unsigned"
$
{
SYS_TRX_TYPE
}
timestamp
(
6
)
$
{
SYS_TRX_TYPE
}
--
replace_result
InnoDB
$
{
INNODB_OR_MYISAM
}
MyISAM
$
{
INNODB_OR_MYISAM
}
"bigint(20) unsigned"
$
{
SYS_TRX_TYPE
}
timestamp
(
6
)
$
{
SYS_TRX_TYPE
}
show
create
table
t1
;
show
create
table
t1
;
...
@@ -189,16 +189,16 @@ select * from t1 partition (p1);
...
@@ -189,16 +189,16 @@ select * from t1 partition (p1);
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
interval
0
second
(
partition
by
system_time
interval
0
second
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
,
partition
p1
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
create
or
replace
table
t1
(
x
int
)
create
or
replace
table
t1
(
x
int
)
with
system
versioning
with
system
versioning
partition
by
system_time
interval
1
second
(
partition
by
system_time
interval
1
second
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
,
partition
p1
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
select
*
from
t1
partition
(
pn
);
select
*
from
t1
partition
(
pn
);
...
@@ -216,9 +216,9 @@ with system versioning
...
@@ -216,9 +216,9 @@ with system versioning
partition
by
system_time
limit
1
partition
by
system_time
limit
1
subpartition
by
key
(
x
)
subpartition
by
key
(
x
)
subpartitions
2
(
subpartitions
2
(
partition
p0
versioning
,
partition
p0
history
,
partition
p1
versioning
,
partition
p1
history
,
partition
pn
as
of
current_timestamp
);
partition
pn
current
);
insert
into
t1
(
x
)
values
(
1
),
(
2
),
(
3
);
insert
into
t1
(
x
)
values
(
1
),
(
2
),
(
3
);
select
*
from
t1
partition
(
pnsp0
);
select
*
from
t1
partition
(
pnsp0
);
...
...
sql/ha_partition.cc
View file @
18405e5f
...
@@ -4395,7 +4395,7 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
...
@@ -4395,7 +4395,7 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
uint
sub_factor
=
m_part_info
->
num_subparts
?
m_part_info
->
num_subparts
:
1
;
uint
sub_factor
=
m_part_info
->
num_subparts
?
m_part_info
->
num_subparts
:
1
;
DBUG_ASSERT
(
m_tot_parts
==
m_part_info
->
num_parts
*
sub_factor
);
DBUG_ASSERT
(
m_tot_parts
==
m_part_info
->
num_parts
*
sub_factor
);
uint
lpart_id
=
new_part_id
/
sub_factor
;
uint
lpart_id
=
new_part_id
/
sub_factor
;
// lpart_id is
VERSIONING
partition because new_part_id != old_part_id
// lpart_id is
HISTORY
partition because new_part_id != old_part_id
m_part_info
->
vers_update_stats
(
thd
,
lpart_id
);
m_part_info
->
vers_update_stats
(
thd
,
lpart_id
);
}
}
...
...
sql/lex.h
View file @
18405e5f
...
@@ -273,6 +273,7 @@ static SYMBOL symbols[] = {
...
@@ -273,6 +273,7 @@ static SYMBOL symbols[] = {
{
"HAVING"
,
SYM
(
HAVING
)},
{
"HAVING"
,
SYM
(
HAVING
)},
{
"HELP"
,
SYM
(
HELP_SYM
)},
{
"HELP"
,
SYM
(
HELP_SYM
)},
{
"HIGH_PRIORITY"
,
SYM
(
HIGH_PRIORITY
)},
{
"HIGH_PRIORITY"
,
SYM
(
HIGH_PRIORITY
)},
{
"HISTORY"
,
SYM
(
HISTORY_SYM
)},
{
"HOST"
,
SYM
(
HOST_SYM
)},
{
"HOST"
,
SYM
(
HOST_SYM
)},
{
"HOSTS"
,
SYM
(
HOSTS_SYM
)},
{
"HOSTS"
,
SYM
(
HOSTS_SYM
)},
{
"HOUR"
,
SYM
(
HOUR_SYM
)},
{
"HOUR"
,
SYM
(
HOUR_SYM
)},
...
...
sql/partition_element.h
View file @
18405e5f
...
@@ -156,8 +156,8 @@ class partition_element :public Sql_alloc
...
@@ -156,8 +156,8 @@ class partition_element :public Sql_alloc
enum
elem_type
enum
elem_type
{
{
CONVENTIONAL
=
0
,
CONVENTIONAL
=
0
,
AS_OF_NOW
,
CURRENT
,
VERSIONING
HISTORY
};
};
List
<
partition_element
>
subpartitions
;
List
<
partition_element
>
subpartitions
;
...
...
sql/partition_info.cc
View file @
18405e5f
...
@@ -927,7 +927,7 @@ bool partition_info::vers_set_expression(THD *thd, partition_element *el, MYSQL_
...
@@ -927,7 +927,7 @@ bool partition_info::vers_set_expression(THD *thd, partition_element *el, MYSQL_
for
(
uint
i
=
0
;
i
<
num_columns
;
++
i
)
for
(
uint
i
=
0
;
i
<
num_columns
;
++
i
)
{
{
part_column_list_val
*
col_val
=
add_column_value
(
thd
);
part_column_list_val
*
col_val
=
add_column_value
(
thd
);
if
(
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
type
()
==
partition_element
::
CURRENT
)
{
{
col_val
->
max_value
=
true
;
col_val
->
max_value
=
true
;
col_val
->
item_expression
=
NULL
;
col_val
->
item_expression
=
NULL
;
...
@@ -991,20 +991,20 @@ bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
...
@@ -991,20 +991,20 @@ bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
if
(
alter_add
)
if
(
alter_add
)
{
{
/* Non-empty historical partitions are left as is. */
/* Non-empty historical partitions are left as is. */
if
(
el
->
type
()
==
partition_element
::
VERSIONING
&&
!
el
->
empty
)
if
(
el
->
type
()
==
partition_element
::
HISTORY
&&
!
el
->
empty
)
{
{
++
id
;
++
id
;
continue
;
continue
;
}
}
/* Newly added element is inserted before AS_OF_NOW. */
/* Newly added element is inserted before AS_OF_NOW. */
if
(
el
->
id
==
UINT32_MAX
||
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
id
==
UINT32_MAX
||
el
->
type
()
==
partition_element
::
CURRENT
)
{
{
DBUG_ASSERT
(
table
&&
table
->
s
);
DBUG_ASSERT
(
table
&&
table
->
s
);
Vers_min_max_stats
*
stat_trx_end
=
new
(
&
table
->
s
->
mem_root
)
Vers_min_max_stats
*
stat_trx_end
=
new
(
&
table
->
s
->
mem_root
)
Vers_min_max_stats
(
&
table
->
s
->
vers_end_field
()
->
field_name
,
table
->
s
);
Vers_min_max_stats
(
&
table
->
s
->
vers_end_field
()
->
field_name
,
table
->
s
);
table
->
s
->
stat_trx
[
id
*
num_columns
+
STAT_TRX_END
]
=
stat_trx_end
;
table
->
s
->
stat_trx
[
id
*
num_columns
+
STAT_TRX_END
]
=
stat_trx_end
;
el
->
id
=
id
++
;
el
->
id
=
id
++
;
if
(
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
type
()
==
partition_element
::
CURRENT
)
break
;
break
;
goto
set_expression
;
goto
set_expression
;
}
}
...
@@ -1037,7 +1037,7 @@ bool partition_info::vers_scan_min_max(THD *thd, partition_element *part)
...
@@ -1037,7 +1037,7 @@ bool partition_info::vers_scan_min_max(THD *thd, partition_element *part)
uint32
part_id
=
part
->
id
*
sub_factor
;
uint32
part_id
=
part
->
id
*
sub_factor
;
uint32
part_id_end
=
part_id
+
sub_factor
;
uint32
part_id_end
=
part_id
+
sub_factor
;
DBUG_ASSERT
(
part
->
empty
);
DBUG_ASSERT
(
part
->
empty
);
DBUG_ASSERT
(
part
->
type
()
==
partition_element
::
VERSIONING
);
DBUG_ASSERT
(
part
->
type
()
==
partition_element
::
HISTORY
);
DBUG_ASSERT
(
table
->
s
->
stat_trx
);
DBUG_ASSERT
(
table
->
s
->
stat_trx
);
for
(;
part_id
<
part_id_end
;
++
part_id
)
for
(;
part_id
<
part_id_end
;
++
part_id
)
{
{
...
@@ -1198,7 +1198,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
...
@@ -1198,7 +1198,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
partition_element
*
el
=
NULL
,
*
prev
;
partition_element
*
el
=
NULL
,
*
prev
;
while
((
prev
=
el
,
el
=
it
++
))
while
((
prev
=
el
,
el
=
it
++
))
{
{
if
(
el
->
type
()
==
partition_element
::
VERSIONING
&&
dont_stat
)
if
(
el
->
type
()
==
partition_element
::
HISTORY
&&
dont_stat
)
{
{
if
(
el
->
id
==
table
->
s
->
hist_part_id
)
if
(
el
->
id
==
table
->
s
->
hist_part_id
)
{
{
...
@@ -1216,7 +1216,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
...
@@ -1216,7 +1216,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
if
(
!
is_create_table_ind
)
if
(
!
is_create_table_ind
)
{
{
if
(
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
type
()
==
partition_element
::
CURRENT
)
{
{
uchar
buf
[
8
];
uchar
buf
[
8
];
Field_timestampf
fld
(
buf
,
NULL
,
0
,
Field
::
NONE
,
&
table
->
vers_end_field
()
->
field_name
,
NULL
,
6
);
Field_timestampf
fld
(
buf
,
NULL
,
0
,
Field
::
NONE
,
&
table
->
vers_end_field
()
->
field_name
,
NULL
,
6
);
...
@@ -1237,10 +1237,10 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
...
@@ -1237,10 +1237,10 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
}
}
}
}
if
(
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
type
()
==
partition_element
::
CURRENT
)
break
;
break
;
DBUG_ASSERT
(
el
->
type
()
==
partition_element
::
VERSIONING
);
DBUG_ASSERT
(
el
->
type
()
==
partition_element
::
HISTORY
);
if
(
vers_info
->
hist_part
)
if
(
vers_info
->
hist_part
)
{
{
...
@@ -2085,13 +2085,13 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
...
@@ -2085,13 +2085,13 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
}
}
if
(
part_type
==
VERSIONING_PARTITION
)
if
(
part_type
==
VERSIONING_PARTITION
)
{
{
if
(
part_elem
->
type
()
==
partition_element
::
VERSIONING
)
if
(
part_elem
->
type
()
==
partition_element
::
HISTORY
)
{
{
hist_parts
++
;
hist_parts
++
;
}
}
else
else
{
{
DBUG_ASSERT
(
part_elem
->
type
()
==
partition_element
::
AS_OF_NOW
);
DBUG_ASSERT
(
part_elem
->
type
()
==
partition_element
::
CURRENT
);
now_parts
++
;
now_parts
++
;
}
}
}
}
...
@@ -2141,7 +2141,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
...
@@ -2141,7 +2141,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
Sql_condition
::
WARN_LEVEL_WARN
,
Sql_condition
::
WARN_LEVEL_WARN
,
WARN_VERS_PARAMETERS
,
WARN_VERS_PARAMETERS
,
ER_THD
(
thd
,
WARN_VERS_PARAMETERS
),
ER_THD
(
thd
,
WARN_VERS_PARAMETERS
),
"no rotation condition for multiple
`VERSIONING`
partitions."
);
"no rotation condition for multiple
HISTORY
partitions."
);
}
}
}
}
if
(
now_parts
>
1
)
if
(
now_parts
>
1
)
...
...
sql/partition_info.h
View file @
18405e5f
...
@@ -58,11 +58,11 @@ struct Vers_part_info : public Sql_alloc
...
@@ -58,11 +58,11 @@ struct Vers_part_info : public Sql_alloc
if
(
now_part
)
if
(
now_part
)
{
{
DBUG_ASSERT
(
now_part
->
id
!=
UINT32_MAX
);
DBUG_ASSERT
(
now_part
->
id
!=
UINT32_MAX
);
DBUG_ASSERT
(
now_part
->
type
()
==
partition_element
::
AS_OF_NOW
);
DBUG_ASSERT
(
now_part
->
type
()
==
partition_element
::
CURRENT
);
DBUG_ASSERT
(
!
fully
||
(
bool
)
hist_part
);
DBUG_ASSERT
(
!
fully
||
(
bool
)
hist_part
);
DBUG_ASSERT
(
!
hist_part
||
(
DBUG_ASSERT
(
!
hist_part
||
(
hist_part
->
id
!=
UINT32_MAX
&&
hist_part
->
id
!=
UINT32_MAX
&&
hist_part
->
type
()
==
partition_element
::
VERSIONING
));
hist_part
->
type
()
==
partition_element
::
HISTORY
));
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -436,7 +436,7 @@ class partition_info : public Sql_alloc
...
@@ -436,7 +436,7 @@ class partition_info : public Sql_alloc
while
((
el
=
it
++
))
while
((
el
=
it
++
))
{
{
DBUG_ASSERT
(
el
->
type
()
!=
partition_element
::
CONVENTIONAL
);
DBUG_ASSERT
(
el
->
type
()
!=
partition_element
::
CONVENTIONAL
);
if
(
el
->
type
()
==
partition_element
::
VERSIONING
&&
if
(
el
->
type
()
==
partition_element
::
HISTORY
&&
el
->
id
==
table
->
s
->
hist_part_id
)
el
->
id
==
table
->
s
->
hist_part_id
)
{
{
vers_info
->
hist_part
=
el
;
vers_info
->
hist_part
=
el
;
...
@@ -508,7 +508,7 @@ class partition_info : public Sql_alloc
...
@@ -508,7 +508,7 @@ class partition_info : public Sql_alloc
{
{
DBUG_ASSERT
(
vers_info
&&
vers_info
->
initialized
());
DBUG_ASSERT
(
vers_info
&&
vers_info
->
initialized
());
DBUG_ASSERT
(
table
&&
table
->
s
);
DBUG_ASSERT
(
table
&&
table
->
s
);
DBUG_ASSERT
(
el
&&
el
->
type
()
==
partition_element
::
VERSIONING
);
DBUG_ASSERT
(
el
&&
el
->
type
()
==
partition_element
::
HISTORY
);
bool
updated
;
bool
updated
;
mysql_rwlock_wrlock
(
&
table
->
s
->
LOCK_stat_serial
);
mysql_rwlock_wrlock
(
&
table
->
s
->
LOCK_stat_serial
);
el
->
empty
=
false
;
el
->
empty
=
false
;
...
...
sql/share/errmsg-utf8.txt
View file @
18405e5f
...
@@ -7837,7 +7837,7 @@ ER_PARTITION_WRONG_TYPE
...
@@ -7837,7 +7837,7 @@ ER_PARTITION_WRONG_TYPE
eng "Wrong partition type, expected type: %`s"
eng "Wrong partition type, expected type: %`s"
WARN_VERS_PART_FULL
WARN_VERS_PART_FULL
eng "Versioned table %`s.%`s: partition %`s is full, add more
VERSIONING
partitions"
eng "Versioned table %`s.%`s: partition %`s is full, add more
HISTORY
partitions"
WARN_VERS_PARAMETERS
WARN_VERS_PARAMETERS
eng "Maybe missing parameters: %s"
eng "Maybe missing parameters: %s"
...
@@ -7897,7 +7897,7 @@ ER_PART_WRONG_VALUE
...
@@ -7897,7 +7897,7 @@ ER_PART_WRONG_VALUE
eng "Wrong parameters for partitioned %`s: wrong value for '%s'"
eng "Wrong parameters for partitioned %`s: wrong value for '%s'"
ER_VERS_WRONG_PARTS
ER_VERS_WRONG_PARTS
eng "Wrong partitions consistency for %`s: must have at least one
VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP
"
eng "Wrong partitions consistency for %`s: must have at least one
HISTORY and exactly one last CURRENT
"
ER_VERS_HISTORY_LOCK
ER_VERS_HISTORY_LOCK
eng "Versioned SELECT write-locking of history rows"
eng "Versioned SELECT write-locking of history rows"
...
...
sql/sql_partition.cc
View file @
18405e5f
...
@@ -2220,11 +2220,11 @@ static int add_partition_values(String *str, partition_info *part_info,
...
@@ -2220,11 +2220,11 @@ static int add_partition_values(String *str, partition_info *part_info,
{
{
switch
(
p_elem
->
type
())
switch
(
p_elem
->
type
())
{
{
case
partition_element
:
:
AS_OF_NOW
:
case
partition_element
:
:
CURRENT
:
err
+=
str
->
append
(
STRING_WITH_LEN
(
"
AS OF CURRENT_TIMESTAMP
"
));
err
+=
str
->
append
(
STRING_WITH_LEN
(
"
CURRENT
"
));
break
;
break
;
case
partition_element
:
:
VERSIONING
:
case
partition_element
:
:
HISTORY
:
err
+=
str
->
append
(
STRING_WITH_LEN
(
"
VERSIONING
"
));
err
+=
str
->
append
(
STRING_WITH_LEN
(
"
HISTORY
"
));
break
;
break
;
default:
default:
DBUG_ASSERT
(
0
&&
"wrong p_elem->type"
);
DBUG_ASSERT
(
0
&&
"wrong p_elem->type"
);
...
@@ -5000,7 +5000,7 @@ that are reorganised.
...
@@ -5000,7 +5000,7 @@ that are reorganised.
partition_element
*
el
;
partition_element
*
el
;
while
((
el
=
it
++
))
while
((
el
=
it
++
))
{
{
if
(
el
->
type
()
==
partition_element
::
AS_OF_NOW
)
if
(
el
->
type
()
==
partition_element
::
CURRENT
)
{
{
DBUG_ASSERT
(
tab_part_info
->
vers_info
&&
el
==
tab_part_info
->
vers_info
->
now_part
);
DBUG_ASSERT
(
tab_part_info
->
vers_info
&&
el
==
tab_part_info
->
vers_info
->
now_part
);
it
.
remove
();
it
.
remove
();
...
@@ -5094,7 +5094,7 @@ that are reorganised.
...
@@ -5094,7 +5094,7 @@ that are reorganised.
alter_info
->
partition_names
))
alter_info
->
partition_names
))
{
{
if
(
tab_part_info
->
part_type
==
VERSIONING_PARTITION
&&
if
(
tab_part_info
->
part_type
==
VERSIONING_PARTITION
&&
part_elem
->
type
()
==
partition_element
::
AS_OF_NOW
)
part_elem
->
type
()
==
partition_element
::
CURRENT
)
{
{
DBUG_ASSERT
(
table
&&
table
->
s
&&
table
->
s
->
table_name
.
str
);
DBUG_ASSERT
(
table
&&
table
->
s
&&
table
->
s
->
table_name
.
str
);
my_error
(
ER_VERS_WRONG_PARTS
,
MYF
(
0
),
table
->
s
->
table_name
.
str
);
my_error
(
ER_VERS_WRONG_PARTS
,
MYF
(
0
),
table
->
s
->
table_name
.
str
);
...
...
sql/sql_yacc.yy
View file @
18405e5f
...
@@ -1156,6 +1156,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
...
@@ -1156,6 +1156,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token HEX_NUM
%token HEX_NUM
%token HEX_STRING
%token HEX_STRING
%token HIGH_PRIORITY
%token HIGH_PRIORITY
%token HISTORY_SYM /* MYSQL */
%token HOST_SYM
%token HOST_SYM
%token HOSTS_SYM
%token HOSTS_SYM
%token HOUR_MICROSECOND_SYM
%token HOUR_MICROSECOND_SYM
...
@@ -5460,7 +5461,7 @@ opt_part_values:
...
@@ -5460,7 +5461,7 @@ opt_part_values:
part_info->part_type= LIST_PARTITION;
part_info->part_type= LIST_PARTITION;
}
}
part_values_in {}
part_values_in {}
|
AS OF_SYM NOW
_SYM
|
CURRENT
_SYM
{
{
LEX *lex= Lex;
LEX *lex= Lex;
partition_info *part_info= lex->part_info;
partition_info *part_info= lex->part_info;
...
@@ -5479,7 +5480,7 @@ opt_part_values:
...
@@ -5479,7 +5480,7 @@ opt_part_values:
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
Lex->create_last_non_select_table->table_name));
Lex->create_last_non_select_table->table_name));
}
}
elem->type(partition_element::
AS_OF_NOW
);
elem->type(partition_element::
CURRENT
);
DBUG_ASSERT(part_info->vers_info);
DBUG_ASSERT(part_info->vers_info);
part_info->vers_info->now_part= elem;
part_info->vers_info->now_part= elem;
if (part_info->init_column_part(thd))
if (part_info->init_column_part(thd))
...
@@ -5487,7 +5488,7 @@ opt_part_values:
...
@@ -5487,7 +5488,7 @@ opt_part_values:
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
}
}
|
VERSIONING
_SYM
|
HISTORY
_SYM
{
{
LEX *lex= Lex;
LEX *lex= Lex;
partition_info *part_info= lex->part_info;
partition_info *part_info= lex->part_info;
...
@@ -5510,7 +5511,7 @@ opt_part_values:
...
@@ -5510,7 +5511,7 @@ opt_part_values:
DBUG_ASSERT(Lex->create_last_non_select_table->table_name);
DBUG_ASSERT(Lex->create_last_non_select_table->table_name);
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name));
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name));
}
}
elem->type(partition_element::
VERSIONING
);
elem->type(partition_element::
HISTORY
);
if (part_info->init_column_part(thd))
if (part_info->init_column_part(thd))
{
{
MYSQL_YYABORT;
MYSQL_YYABORT;
...
@@ -15506,6 +15507,7 @@ keyword_sp_not_data_type:
...
@@ -15506,6 +15507,7 @@ keyword_sp_not_data_type:
| GOTO_SYM {}
| GOTO_SYM {}
| HASH_SYM {}
| HASH_SYM {}
| HARD_SYM {}
| HARD_SYM {}
| HISTORY_SYM {}
| HOSTS_SYM {}
| HOSTS_SYM {}
| HOUR_SYM {}
| HOUR_SYM {}
| ID_SYM {}
| ID_SYM {}
...
...
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