summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2006-03-31 15:17:15 +0400
committerunknown <sergefp@mysql.com>2006-03-31 15:17:15 +0400
commit457510903fd4f4c98ca09c81d53c6a810084a8e0 (patch)
tree605c6048b6806d57e2dfffe278315fd0ed0da3b7
parentb002c11756aa59273b548c442dd69c8f41a9e9e2 (diff)
downloadmariadb-git-457510903fd4f4c98ca09c81d53c6a810084a8e0.tar.gz
Fix for BUG#18025: Wrong query results because of bugs in partition pruning:
- Fix typo bug in SEL_ARG::is_singlepoint() - In set_up_range_analysis_info(), treat MEDIUMINT as enumerable type just like other integer types mysql-test/r/partition_pruning.result: Testcase for BUG#18025 mysql-test/t/partition_pruning.test: Testcase for BUG#18025 sql/opt_range.cc: BUG#18025: Fix a typo bug in SEL_ARG::is_singlepoint() sql/sql_partition.cc: BUG#18025: In set_up_range_analysis_info(), treat MEDIUMINT as enumerable type just like other integer types.
-rw-r--r--mysql-test/r/partition_pruning.result38
-rw-r--r--mysql-test/t/partition_pruning.test32
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/sql_partition.cc1
4 files changed, 72 insertions, 1 deletions
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result
index cbad5d067b0..16dc23cdf42 100644
--- a/mysql-test/r/partition_pruning.result
+++ b/mysql-test/r/partition_pruning.result
@@ -545,3 +545,41 @@ show status like 'Handler_read_next';
Variable_name Value
Handler_read_next 0
drop table t1, t2;
+create table t1 ( f_int1 mediumint, f_int2 integer)
+partition by list(mod(f_int1,4)) (
+partition p_3 values in (-3),
+partition p_2 values in (-2),
+partition p_1 values in (-1),
+partition p0 values in (0),
+partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3)
+);
+insert into t1 values (9, 9), (8, 8), (7, 7), (6, 6), (5, 5),
+(4, 4), (3, 3), (2, 2), (1, 1);
+select * from t1 where f_int1 between 5 and 15 order by f_int1;
+f_int1 f_int2
+5 5
+6 6
+7 7
+8 8
+9 9
+drop table t1;
+create table t1 (a char(10)) partition by list(length(a)) (
+partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3),
+partition p4 values in (4),
+partition p5 values in (5)
+);
+insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
+select * from t1 where a>='a' and a <= 'dddd';
+a
+a
+bb
+ccc
+dddd
+explain partitions select * from t1 where a>='a' and a <= 'dddd';
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,p2,p3,p4,p5 ALL NULL NULL NULL NULL 5 Using where
+drop table t1;
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
index 30f4f37ee04..25320e9f80d 100644
--- a/mysql-test/t/partition_pruning.test
+++ b/mysql-test/t/partition_pruning.test
@@ -447,5 +447,37 @@ show status like 'Handler_read_next';
drop table t1, t2;
+# BUG#18025
+# part1: mediumint columns
+create table t1 ( f_int1 mediumint, f_int2 integer)
+partition by list(mod(f_int1,4)) (
+ partition p_3 values in (-3),
+ partition p_2 values in (-2),
+ partition p_1 values in (-1),
+ partition p0 values in (0),
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3)
+);
+
+insert into t1 values (9, 9), (8, 8), (7, 7), (6, 6), (5, 5),
+ (4, 4), (3, 3), (2, 2), (1, 1);
+select * from t1 where f_int1 between 5 and 15 order by f_int1;
+
+drop table t1;
+
+# part2: bug in pruning code
+create table t1 (a char(10)) partition by list(length(a)) (
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3),
+ partition p4 values in (4),
+ partition p5 values in (5)
+);
+insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
+select * from t1 where a>='a' and a <= 'dddd';
+explain partitions select * from t1 where a>='a' and a <= 'dddd';
+drop table t1;
+
# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447
# being fixed.
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 36de27ef3e3..9706a0ccd1e 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -339,7 +339,7 @@ public:
if (min_flag || max_flag)
return FALSE;
byte *min_val= (byte *)min_value;
- byte *max_val= (byte *)min_value;
+ byte *max_val= (byte *)max_value;
if (maybe_null)
{
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index d8a886d2227..bc41fdd1b8d 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -5643,6 +5643,7 @@ static void set_up_range_analysis_info(partition_info *part_info)
switch (field->type()) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
+ case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:
part_info->get_part_iter_for_interval=