[Commits] 0a86a91: MDEV-10765: Wrong result - query does not retrieve values from default partition on a table partitioned by list columns

Oleksandr Byelkin sanja at mariadb.com
Thu Sep 8 20:43:10 EEST 2016


revision-id: 0a86a915842d268477c5febd8481263f00d6c792 (mariadb-10.1.8-242-g0a86a91)
parent(s): effb65bc863da0f1115e16ef5f11d11a13cdc7a0
committer: Oleksandr Byelkin
timestamp: 2016-09-08 19:43:09 +0200
message:

MDEV-10765: Wrong result - query does not retrieve values from default partition on a table partitioned by list columns

Partial matches should be treat as not exact one.

---
 mysql-test/r/partition_default.result | 29 +++++++++++++++++++++++++++++
 mysql-test/t/partition_default.test   | 19 +++++++++++++++++++
 sql/sql_partition.cc                  |  5 +++++
 3 files changed, 53 insertions(+)

diff --git a/mysql-test/r/partition_default.result b/mysql-test/r/partition_default.result
index ab9fa58..abaeced 100644
--- a/mysql-test/r/partition_default.result
+++ b/mysql-test/r/partition_default.result
@@ -1149,3 +1149,32 @@ t1	CREATE TABLE `t1` (
  PARTITION p2 VALUES IN ((1,4),(2,5),(3,6)) ENGINE = MyISAM,
  PARTITION p1 VALUES IN ((1,1),(0,0)) ENGINE = MyISAM) */
 drop table t1;
+#
+# MDEV-10765: Wrong result - query does not retrieve values from
+# default partition on a table partitioned by list columns
+#
+create table t1 (i int, j int) partition by list columns(i,j) (partition p1 values in ((10,10)), partition p2 default);
+insert into t1 values (10,1);
+select * from t1 where i = 10;
+i	j
+10	1
+explain partitions
+select * from t1 where i = 10;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	p1,p2	system	NULL	NULL	NULL	NULL	1	
+select * from t1 where i = 10 and j=1;
+i	j
+10	1
+explain partitions
+select * from t1 where i = 10 and j=1;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	p2	system	NULL	NULL	NULL	NULL	1	
+insert into t1 values (10,10);
+select * from t1 where i = 10 and j=10;
+i	j
+10	10
+explain partitions
+select * from t1 where i = 10 and j=10;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	p1	system	NULL	NULL	NULL	NULL	1	
+drop table t1;
diff --git a/mysql-test/t/partition_default.test b/mysql-test/t/partition_default.test
index 8f7fe58..e4a39e2 100644
--- a/mysql-test/t/partition_default.test
+++ b/mysql-test/t/partition_default.test
@@ -453,3 +453,22 @@ create table t1 (a int, b int)
 show create table t1;
 
 drop table t1;
+
+--echo #
+--echo # MDEV-10765: Wrong result - query does not retrieve values from
+--echo # default partition on a table partitioned by list columns
+--echo #
+
+create table t1 (i int, j int) partition by list columns(i,j) (partition p1 values in ((10,10)), partition p2 default);
+insert into t1 values (10,1);
+select * from t1 where i = 10;
+explain partitions
+select * from t1 where i = 10;
+select * from t1 where i = 10 and j=1;
+explain partitions
+select * from t1 where i = 10 and j=1;
+insert into t1 values (10,10);
+select * from t1 where i = 10 and j=10;
+explain partitions
+select * from t1 where i = 10 and j=10;
+drop table t1;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 54396b9..24dff23 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -7723,6 +7723,7 @@ int get_part_iter_for_interval_cols_via_map(partition_info *part_info,
   bool can_match_multiple_values;
   uint32 nparts;
   get_col_endpoint_func  UNINIT_VAR(get_col_endpoint);
+  uint full_length= 0;
   DBUG_ENTER("get_part_iter_for_interval_cols_via_map");
 
   if (part_info->part_type == RANGE_PARTITION)
@@ -7740,9 +7741,13 @@ int get_part_iter_for_interval_cols_via_map(partition_info *part_info,
   else
     assert(0);
 
+  for (uint32 i= 0; i < part_info->num_columns; i++)
+    full_length+= store_length_array[i];
+
   can_match_multiple_values= ((flags &
                                (NO_MIN_RANGE | NO_MAX_RANGE | NEAR_MIN |
                                 NEAR_MAX)) ||
+                              (min_len != full_length) ||
                               memcmp(min_value, max_value, min_len));
   DBUG_ASSERT(can_match_multiple_values || (flags & EQ_RANGE) || flags == 0);
   if (can_match_multiple_values && part_info->has_default_partititon())


More information about the commits mailing list