1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-22164 log a warning when WITHOUT VALIDATION was used

This commit is contained in:
Sergei Golubchik
2024-01-08 13:06:16 +01:00
parent 4089296a57
commit c0c1c80346
3 changed files with 30 additions and 2 deletions

View File

@@ -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);
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

View File

@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;

View File

@@ -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.