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
df0e1817
Commit
df0e1817
authored
Jan 26, 2018
by
Aleksey Midenkov
Committed by
Sergei Golubchik
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vers SQL: partition rotation by INTERVAL fix
Update partition stats on ha_partition::write_row()
parent
45e1c9bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
19 deletions
+52
-19
mysql-test/suite/versioning/r/partition.result
mysql-test/suite/versioning/r/partition.result
+24
-5
mysql-test/suite/versioning/t/partition.test
mysql-test/suite/versioning/t/partition.test
+20
-5
sql/ha_partition.cc
sql/ha_partition.cc
+5
-7
sql/partition_info.h
sql/partition_info.h
+3
-2
No files found.
mysql-test/suite/versioning/r/partition.result
View file @
df0e1817
...
...
@@ -268,31 +268,50 @@ partition p0 history,
partition p1 history,
partition pn current);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
### ha_partition::update_row() check
create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 values (1), (2), (3);
insert into t1 values (1), (2), (3)
, (4)
;
select * from t1 partition (pn);
x
1
2
3
4
delete from t1 where x < 3;
delete from t1;
select * from t1 partition (p0);
Warnings:
Note 4114 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
select * from t1 partition (p0) order by x;
x
1
2
select * from t1 partition (p1) order by x;
x
3
insert into t1 values (4);
delete from t1;
4
### ha_partition::write_row() check
create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 values (1);
update t1 set x= 2;
update t1 set x= 3;
Warnings:
Note 4114 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
select * from t1 partition (p0);
x
1
select * from t1 partition (p1);
x
4
2
## Subpartitions
create or replace table t1 (x int)
with system versioning
...
...
mysql-test/suite/versioning/t/partition.test
View file @
df0e1817
...
...
@@ -122,7 +122,6 @@ alter table t1 add partition (partition px history);
--
echo
## INSERT, UPDATE, DELETE
create
or
replace
table
t1
(
x
int
)
with
system
versioning
partition
by
system_time
(
...
...
@@ -241,6 +240,7 @@ partition by system_time interval 0 second (
partition
p1
history
,
partition
pn
current
);
--
echo
### ha_partition::update_row() check
create
or
replace
table
t1
(
x
int
)
with
system
versioning
partition
by
system_time
interval
1
second
(
...
...
@@ -248,14 +248,29 @@ partition by system_time interval 1 second (
partition
p1
history
,
partition
pn
current
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
insert
into
t1
values
(
1
),
(
2
),
(
3
)
,
(
4
)
;
select
*
from
t1
partition
(
pn
);
delete
from
t1
;
select
*
from
t1
partition
(
p0
);
delete
from
t1
where
x
<
3
;
--
sleep
2
insert
into
t1
values
(
4
);
delete
from
t1
;
select
*
from
t1
partition
(
p0
)
order
by
x
;
select
*
from
t1
partition
(
p1
)
order
by
x
;
--
echo
### ha_partition::write_row() check
create
or
replace
table
t1
(
x
int
)
with
system
versioning
partition
by
system_time
interval
1
second
(
partition
p0
history
,
partition
p1
history
,
partition
pn
current
);
insert
into
t1
values
(
1
);
update
t1
set
x
=
2
;
sleep
2
;
update
t1
set
x
=
3
;
select
*
from
t1
partition
(
p0
);
select
*
from
t1
partition
(
p1
);
--
echo
## Subpartitions
...
...
sql/ha_partition.cc
View file @
df0e1817
...
...
@@ -4269,6 +4269,10 @@ int ha_partition::write_row(uchar * buf)
if
(
have_auto_increment
&&
!
table
->
s
->
next_number_keypart
)
set_auto_increment_if_higher
(
table
->
next_number_field
);
reenable_binlog
(
thd
);
if
(
m_part_info
->
part_type
==
VERSIONING_PARTITION
)
m_part_info
->
vers_update_stats
(
thd
,
part_id
);
exit:
thd
->
variables
.
sql_mode
=
saved_sql_mode
;
table
->
auto_increment_field_not_null
=
saved_auto_inc_field_not_null
;
...
...
@@ -4378,13 +4382,7 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
goto
exit
;
if
(
m_part_info
->
part_type
==
VERSIONING_PARTITION
)
{
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
);
uint
lpart_id
=
new_part_id
/
sub_factor
;
// 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
,
new_part_id
);
tmp_disable_binlog
(
thd
);
/* Do not replicate the low-level changes. */
error
=
m_file
[
old_part_id
]
->
ha_delete_row
(
old_data
);
...
...
sql/partition_info.h
View file @
df0e1817
...
...
@@ -521,8 +521,9 @@ class partition_info : public Sql_alloc
void
vers_update_stats
(
THD
*
thd
,
uint
part_id
)
{
DBUG_ASSERT
(
vers_info
&&
vers_info
->
initialized
());
if
(
part_id
<
vers_info
->
now_part
->
id
)
vers_update_stats
(
thd
,
get_partition
(
part_id
));
uint
lpart_id
=
num_subparts
?
part_id
/
num_subparts
:
part_id
;
if
(
lpart_id
<
vers_info
->
now_part
->
id
)
vers_update_stats
(
thd
,
get_partition
(
lpart_id
));
}
bool
vers_update_range_constants
(
THD
*
thd
)
{
...
...
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