Commit 249b54c9 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-33125 CHECK TABLE does not recognize corruption

after EXCHANGE WITHOUT VALIDATION on system-time partitioning

MDEV-21011 disabled this check if there is no INTERVAL on history
partitions as the rows may be in any history partition. Now we
reenable the check and allow this condition.
parent 9d806a0f
......@@ -3431,4 +3431,68 @@ ERROR HY000: Maybe missing parameters: no rotation condition for multiple HISTOR
#
# End of 10.5 tests
#
#
# MDEV-33125 CHECK TABLE does not recognize corruption
# after EXCHANGE WITHOUT VALIDATION on system-time partitioning
#
create or replace table t1 (a int) with system versioning
partition by system_time partitions 2;
insert into t1 (a) values (1), (2);
create or replace table t2 (a int) with system versioning;
insert into t2 (a) values (3), (4);
create or replace table t3 (a int)
partition by range (a) (
partition p0 values less than (10),
partition p1 values less than maxvalue);
insert into t3 (a) values (5), (6);
create or replace table t4 (a int);
insert into t4 (a) values (10), (20);
alter table t1 exchange partition p0 with table t2;
ERROR HY000: Found a row that does not match the partition
alter table t1 exchange partition p0 with table t2 with validation;
ERROR HY000: Found a row that does not match the partition
call mtr.add_suppression("altered WITHOUT VALIDATION");
alter table t1 exchange partition p0 with table t2 without validation;
alter table t3 exchange partition p0 with table t4 without validation;
select a, check_row_ts(row_start, row_end) from t1 partition (p0) order by a;
a check_row_ts(row_start, row_end)
3 CURRENT ROW
4 CURRENT ROW
select a, check_row_ts(row_start, row_end) from t1 partition (pn) order by a;
a check_row_ts(row_start, row_end)
1 CURRENT ROW
2 CURRENT ROW
check table t1;
Table Op Msg_type Msg_text
test.t1 check error Found a misplaced row
test.t1 check error Partition p0 returned error
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
repair table t1;
Table Op Msg_type Msg_text
test.t1 repair warning Moved 2 misplaced rows
test.t1 repair status OK
select a, check_row_ts(row_start, row_end) from t1 partition (p0) order by a;
a check_row_ts(row_start, row_end)
select a, check_row_ts(row_start, row_end) from t1 partition (pn) order by a;
a check_row_ts(row_start, row_end)
1 CURRENT ROW
2 CURRENT ROW
3 CURRENT ROW
4 CURRENT ROW
select a from t3 partition (p0) order by a;
a
10
20
check table t3;
Table Op Msg_type Msg_text
test.t3 check error Found a misplaced row
test.t3 check error Partition p0 returned error
test.t3 check error Upgrade required. Please do "REPAIR TABLE `t3`" or dump/reload to fix it!
repair table t3;
Table Op Msg_type Msg_text
test.t3 repair warning Moved 2 misplaced rows
test.t3 repair status OK
select a from t3 partition (p0) order by a;
a
drop tables t1, t2, t3, t4;
set global innodb_stats_persistent= @save_persistent;
......@@ -2673,5 +2673,48 @@ create table t (a int) with system versioning partition by system_time partition
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-33125 CHECK TABLE does not recognize corruption
--echo # after EXCHANGE WITHOUT VALIDATION on system-time partitioning
--echo #
create or replace table t1 (a int) with system versioning
partition by system_time partitions 2;
insert into t1 (a) values (1), (2);
create or replace table t2 (a int) with system versioning;
insert into t2 (a) values (3), (4);
create or replace table t3 (a int)
partition by range (a) (
partition p0 values less than (10),
partition p1 values less than maxvalue);
insert into t3 (a) values (5), (6);
create or replace table t4 (a int);
insert into t4 (a) values (10), (20);
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table t1 exchange partition p0 with table t2;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table t1 exchange partition p0 with table t2 with validation;
call mtr.add_suppression("altered WITHOUT VALIDATION");
alter table t1 exchange partition p0 with table t2 without validation;
alter table t3 exchange partition p0 with table t4 without validation;
select a, check_row_ts(row_start, row_end) from t1 partition (p0) order by a;
select a, check_row_ts(row_start, row_end) from t1 partition (pn) order by a;
check table t1;
repair table t1;
select a, check_row_ts(row_start, row_end) from t1 partition (p0) order by a;
select a, check_row_ts(row_start, row_end) from t1 partition (pn) order by a;
select a from t3 partition (p0) order by a;
check table t3;
repair table t3;
select a from t3 partition (p0) order by a;
# Cleanup
drop tables t1, t2, t3, t4;
set global innodb_stats_persistent= @save_persistent;
--source suite/versioning/common_finish.inc
......@@ -11287,14 +11287,6 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
DBUG_ASSERT(m_file);
if (m_part_info->vers_info &&
read_part_id != m_part_info->vers_info->now_part->id &&
!m_part_info->vers_info->interval.is_set())
{
/* Skip this check as it is not supported for non-INTERVAL history partitions. */
DBUG_RETURN(HA_ADMIN_OK);
}
if (do_repair)
{
/* We must read the full row, if we need to move it! */
......@@ -11335,6 +11327,14 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
if (result)
break;
/* Row can be in any history partition if there is no interval set */
if (m_part_info->vers_info &&
correct_part_id != read_part_id &&
!m_part_info->vers_info->interval.is_set() &&
correct_part_id < m_part_info->vers_info->now_part->id &&
read_part_id < m_part_info->vers_info->now_part->id)
correct_part_id= read_part_id;
if (correct_part_id != read_part_id)
{
num_misplaced_rows++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment