Skip to content

Commit

Permalink
MDEV-22164 log a warning when WITHOUT VALIDATION was used
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jan 8, 2024
1 parent 4089296 commit c0c1c80
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 9 additions & 0 deletions mysql-test/suite/parts/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ drop database db;
#
# MDEV-22164 without validation for exchange partition/convert in
#
call mtr.add_suppression('was altered WITHOUT');
create table validation(x int);
drop table validation;
create table t (a int primary key);
Expand Down Expand Up @@ -406,6 +407,7 @@ ERROR HY000: Found a row that does not match the partition
alter table tp exchange partition p1 with table t with validation;
ERROR HY000: Found a row that does not match the partition
alter table tp exchange partition p1 with table t without validation;
FOUND 1 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from t order by a;
a
200
Expand Down Expand Up @@ -438,10 +440,12 @@ alter table tp exchange partition p1 with table t without validation;
call validation;
ERROR HY000: Found a row that does not match the partition
call without_validation;
FOUND 2 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
call validation;
call validation;
ERROR HY000: Found a row that does not match the partition
call without_validation;
FOUND 3 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from t order by a;
a
200
Expand All @@ -464,10 +468,12 @@ prepare without_validation from "alter table tp exchange partition p1 with table
execute validation;
ERROR HY000: Found a row that does not match the partition
execute without_validation;
FOUND 4 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
execute validation;
execute validation;
ERROR HY000: Found a row that does not match the partition
execute without_validation;
FOUND 5 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from t order by a;
a
200
Expand All @@ -490,6 +496,7 @@ ERROR HY000: Found a row that does not match the partition
alter table tp convert table t to partition p2 values less than (maxvalue) with validation;
ERROR HY000: Found a row that does not match the partition
alter table tp convert table t to partition p2 values less than (maxvalue) without validation;
FOUND 6 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from tp partition (p0) order by a;
a
2
Expand All @@ -508,6 +515,7 @@ insert tp values (1), (2), (3), (4);
alter table tp exchange partition p0 with table t;
ERROR HY000: Found a row that does not match the partition
alter table tp exchange partition p0 with table t without validation;
FOUND 7 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from t;
a
2
Expand All @@ -523,6 +531,7 @@ insert tp values (12), (2), (3), (4);
alter table tp exchange partition p0 with table t;
ERROR HY000: Table has no partition for value 0
alter table tp exchange partition p0 with table t without validation;
FOUND 8 /Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted/ in mysqld.1.err
select * from t;
a
2
Expand Down
11 changes: 11 additions & 0 deletions mysql-test/suite/parts/t/alter_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ drop database db;
--echo #
--echo # MDEV-22164 without validation for exchange partition/convert in
--echo #
call mtr.add_suppression('was altered WITHOUT');
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN=Table `test`.`tp` was altered WITHOUT VALIDATION: the table might be corrupted;

create table validation(x int);
drop table validation;
Expand Down Expand Up @@ -355,6 +358,7 @@ alter table tp exchange partition p1 with table t;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table tp exchange partition p1 with table t with validation;
alter table tp exchange partition p1 with table t without validation;
source include/search_pattern_in_file.inc;
select * from t order by a;
select * from tp partition (p1) order by a;
alter table tp check partition p0;
Expand All @@ -374,10 +378,12 @@ alter table tp exchange partition p1 with table t without validation;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
call validation;
call without_validation;
source include/search_pattern_in_file.inc;
call validation;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
call validation;
call without_validation;
source include/search_pattern_in_file.inc;
select * from t order by a;
select * from tp partition (p1) order by a;
call validation;
Expand All @@ -392,10 +398,12 @@ prepare without_validation from "alter table tp exchange partition p1 with table
--error ER_ROW_DOES_NOT_MATCH_PARTITION
execute validation;
execute without_validation;
source include/search_pattern_in_file.inc;
execute validation;
--error ER_ROW_DOES_NOT_MATCH_PARTITION
execute validation;
execute without_validation;
source include/search_pattern_in_file.inc;
select * from t order by a;
select * from tp partition (p1) order by a;
execute validation;
Expand All @@ -410,6 +418,7 @@ alter table tp convert table t to partition p2 values less than (maxvalue);
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table tp convert table t to partition p2 values less than (maxvalue) with validation;
alter table tp convert table t to partition p2 values less than (maxvalue) without validation;
source include/search_pattern_in_file.inc;
select * from tp partition (p0) order by a;
select * from tp partition (p1) order by a;
select * from tp partition (p2) order by a;
Expand All @@ -425,6 +434,7 @@ insert tp values (1), (2), (3), (4);
--error ER_ROW_DOES_NOT_MATCH_PARTITION
alter table tp exchange partition p0 with table t;
alter table tp exchange partition p0 with table t without validation;
source include/search_pattern_in_file.inc;
select * from t;
alter table tp exchange partition p0 with table t;
drop table tp;
Expand All @@ -441,6 +451,7 @@ insert tp values (12), (2), (3), (4);
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
alter table tp exchange partition p0 with table t;
alter table tp exchange partition p0 with table t without validation;
source include/search_pattern_in_file.inc;
select * from t;
alter table tp exchange partition p0 with table t;

Expand Down
12 changes: 10 additions & 2 deletions sql/sql_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4104,11 +4104,19 @@ bool verify_data_with_partition(TABLE *table, TABLE *part_table,
uchar *old_rec;
partition_info *part_info;
DBUG_ENTER("verify_data_with_partition");
DBUG_ASSERT(table && table->file && part_table && part_table->part_info &&
part_table->file);
DBUG_ASSERT(table);
DBUG_ASSERT(table->file);
DBUG_ASSERT(part_table);
DBUG_ASSERT(part_table->file);
DBUG_ASSERT(part_table->part_info);

if (table->in_use->lex->without_validation)
{
sql_print_warning("Table %`s.%`s was altered WITHOUT VALIDATION: "
"the table might be corrupted",
part_table->s->db.str, part_table->s->table_name.str);
DBUG_RETURN(false);
}

/*
Verify all table rows.
Expand Down

0 comments on commit c0c1c80

Please sign in to comment.