From 29b39e7a4423188d99570b290127a74151805ed5 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 10 Mar 2010 12:56:05 +0100 Subject: Bug#51830: Incorrect partition pruning on range partition (regression) Problem was that partition pruning did not exclude the last partition if the range was beyond it (i.e. not using MAXVALUE) Fix was to not include the last partition if the partitioning function value was not within the partition range. mysql-test/r/partition_innodb.result: Bug#51830: Incorrect partition pruning on range partition (regression) Updated result mysql-test/r/partition_pruning.result: Bug#51830: Incorrect partition pruning on range partition (regression) Updated result mysql-test/t/partition_innodb.test: Bug#51830: Incorrect partition pruning on range partition (regression) Added test for pruning in InnoDB, since it does not show for MyISAM due to 'Impossible WHERE noticed after reading const tables'. mysql-test/t/partition_pruning.test: Bug#51830: Incorrect partition pruning on range partition (regression) Added test sql/sql_partition.cc: Bug#51830: Incorrect partition pruning on range partition (regression) Also increase the partition id if not inside the last partition (and no MAXVALUE is defined). Added comments and DBUG_ASSERT. --- mysql-test/r/partition_pruning.result | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'mysql-test/r/partition_pruning.result') diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index cf0474a3f6b..7c83d81be1c 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -2101,6 +2101,21 @@ insert into t7 values (10),(30),(50); explain partitions select * from t7 where a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a < 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a <= 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a = 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a >= 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a > 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t7 where a < 10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2110,9 +2125,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t7 where a = 10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t7 p30 system NULL NULL NULL NULL 1 +explain partitions select * from t7 where a >= 10; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a > 10; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a < 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a <= 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a = 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a > 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a >= 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t7 where a < 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a <= 90; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t7 where a = 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2122,6 +2161,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t7 where a >= 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a > 91; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t7 where a > 11 and a < 29; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2137,6 +2179,21 @@ insert into t7 values (10),(30),(50); explain partitions select * from t7 where a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a < 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a <= 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a = 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a >= 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a > 9; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t7 where a < 10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2146,9 +2203,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t7 where a = 10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t7 p30 system NULL NULL NULL NULL 1 +explain partitions select * from t7 where a >= 10; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a > 10; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a < 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a <= 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a = 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a > 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a >= 89; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t7 where a < 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where +explain partitions select * from t7 where a <= 90; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t7 where a = 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2158,6 +2239,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t7 where a >= 90; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +explain partitions select * from t7 where a > 91; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t7 where a > 11 and a < 29; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -- cgit v1.2.1