[Commits] Rev 4236: MDEV-6322: The PARTITION engine can return wrong query results in file:///home/psergey/dev2/5.5/

Sergey Petrunya psergey at askmonty.org
Wed Jul 23 21:48:34 EEST 2014


At file:///home/psergey/dev2/5.5/

------------------------------------------------------------
revno: 4236
revision-id: psergey at askmonty.org-20140723184831-by62prbxjevqmxnl
parent: psergey at askmonty.org-20140723155329-jnadou3d9hvg9viy
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5
timestamp: Wed 2014-07-23 22:48:31 +0400
message:
  MDEV-6322: The PARTITION engine can return wrong query results
  MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
  MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
  MDEV-6240: Wrong "Impossible where" with LIST partitioning
  - Backprot the fix from MySQL Bug#71095.
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2014-03-11 15:45:08 +0000
+++ b/mysql-test/r/partition.result	2014-07-23 18:48:31 +0000
@@ -2521,3 +2521,47 @@ id	id2	dob	address	city	hours_worked_per
 16	16	1949-11-07	address16	city16	40	52
 50	50	1923-09-08	address50	city50	40	52
 drop table t1;
+#
+# MDEV-6322: The PARTITION engine can return wrong query results
+#
+CREATE TABLE t1 (
+CustomerID varchar(5) DEFAULT NULL,
+CompanyName varchar(40) DEFAULT NULL,
+ContactName varchar(30) DEFAULT NULL,
+ContactTitle varchar(30) DEFAULT NULL,
+Address varchar(60) DEFAULT NULL,
+City varchar(15) DEFAULT NULL,
+Region varchar(15) DEFAULT NULL,
+PostalCode varchar(10) DEFAULT NULL,
+Country varchar(15) NOT NULL,
+Phone varchar(24) DEFAULT NULL,
+Fax varchar(24) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST  COLUMNS(Country)
+(PARTITION p1 VALUES IN ('Germany','Austria','Switzerland','Poland'),
+PARTITION p2 VALUES IN ('USA','Canada','Mexico'),
+PARTITION p3 VALUES IN ('Spain','Portugal','Italy'),
+PARTITION p4 VALUES IN ('UK','Ireland'),
+PARTITION p5 VALUES IN ('France','Belgium'),
+PARTITION p6 VALUES IN ('Sweden','Finland','Denmark','Norway'),
+PARTITION p7 VALUES IN ('Venezuela','Argentina','Brazil')
+);
+INSERT INTO t1 (CustomerID, City, Country) VALUES 
+('ANATR','México D.F','Mexico'),
+('ANTON','México D.F','Mexico'),
+('BOTTM','Tsawassen','Canada'),
+('CENTC','México D.F','Mexico'),
+('GREAL','Eugene','USA'),
+('HUNGC','Elgin','USA'),
+('LAUGB','Vancouver','Canada'),
+('LAZYK','Walla Walla','USA'),
+('LETSS','San Francisco','USA'),
+('LONEP','Portland','USA');
+SELECT * FROM t1 WHERE Country = 'USA';
+CustomerID	CompanyName	ContactName	ContactTitle	Address	City	Region	PostalCode	Country	Phone	Fax
+GREAL	NULL	NULL	NULL	NULL	Eugene	NULL	NULL	USA	NULL	NULL
+HUNGC	NULL	NULL	NULL	NULL	Elgin	NULL	NULL	USA	NULL	NULL
+LAZYK	NULL	NULL	NULL	NULL	Walla Walla	NULL	NULL	USA	NULL	NULL
+LETSS	NULL	NULL	NULL	NULL	San Francisco	NULL	NULL	USA	NULL	NULL
+LONEP	NULL	NULL	NULL	NULL	Portland	NULL	NULL	USA	NULL	NULL
+DROP TABLE t1;

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2014-03-11 15:45:08 +0000
+++ b/mysql-test/r/partition_innodb.result	2014-07-23 18:48:31 +0000
@@ -678,4 +678,32 @@ count(*)
 802
 drop table t3;
 drop table t1,t2;
+#
+# MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+#
+create table t1(c1 int, c2 int, c3 int, c4 int,
+primary key(c1,c2)) engine=InnoDB
+partition by list columns(c2)
+(partition p1 values in (1,2) engine=InnoDB,
+partition p2 values in (3,4) engine=InnoDB);
+insert into t1 values (1,1,1,1),(2,3,1,1);
+select * from t1 where c1=2 and c2=3;
+c1	c2	c3	c4
+2	3	1	1
+drop table t1;
+#
+# MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
+#  also MDEV-6240: Wrong "Impossible where" with LIST partitioning
+#
+CREATE TABLE t1 ( d DATE) ENGINE = InnoDB
+PARTITION BY LIST COLUMNS (d)
+(
+PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
+PARTITION p1 VALUES IN ('1981-01-01')
+);
+INSERT INTO t1 (d) VALUES ('1991-01-01');
+SELECT *  FROM t1 WHERE d = '1991-01-01';
+d
+1991-01-01
+DROP TABLE t1;
 set global default_storage_engine=default;

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2014-03-11 15:45:08 +0000
+++ b/mysql-test/t/partition.test	2014-07-23 18:48:31 +0000
@@ -2780,3 +2780,45 @@ select * from t1 where hours_worked_per_
 select * from t1 IGNORE INDEX(dob, weeks_worked_last_year, hours_worked_per_week) where hours_worked_per_week = 40 and weeks_worked_last_year = 52 and dob < '1949-11-21';
 
 drop table t1;
+
+--echo #
+--echo # MDEV-6322: The PARTITION engine can return wrong query results
+--echo #
+CREATE TABLE t1 (
+  CustomerID varchar(5) DEFAULT NULL,
+  CompanyName varchar(40) DEFAULT NULL,
+  ContactName varchar(30) DEFAULT NULL,
+  ContactTitle varchar(30) DEFAULT NULL,
+  Address varchar(60) DEFAULT NULL,
+  City varchar(15) DEFAULT NULL,
+  Region varchar(15) DEFAULT NULL,
+  PostalCode varchar(10) DEFAULT NULL,
+  Country varchar(15) NOT NULL,
+  Phone varchar(24) DEFAULT NULL,
+  Fax varchar(24) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY LIST  COLUMNS(Country)
+(PARTITION p1 VALUES IN ('Germany','Austria','Switzerland','Poland'),
+ PARTITION p2 VALUES IN ('USA','Canada','Mexico'),
+ PARTITION p3 VALUES IN ('Spain','Portugal','Italy'),
+ PARTITION p4 VALUES IN ('UK','Ireland'),
+ PARTITION p5 VALUES IN ('France','Belgium'),
+ PARTITION p6 VALUES IN ('Sweden','Finland','Denmark','Norway'),
+  PARTITION p7 VALUES IN ('Venezuela','Argentina','Brazil')
+);
+
+INSERT INTO t1 (CustomerID, City, Country) VALUES 
+('ANATR','México D.F','Mexico'),
+('ANTON','México D.F','Mexico'),
+('BOTTM','Tsawassen','Canada'),
+('CENTC','México D.F','Mexico'),
+('GREAL','Eugene','USA'),
+('HUNGC','Elgin','USA'),
+('LAUGB','Vancouver','Canada'),
+('LAZYK','Walla Walla','USA'),
+('LETSS','San Francisco','USA'),
+('LONEP','Portland','USA');
+
+SELECT * FROM t1 WHERE Country = 'USA';
+DROP TABLE t1;
+

=== modified file 'mysql-test/t/partition_innodb.test'
--- a/mysql-test/t/partition_innodb.test	2014-03-11 15:45:08 +0000
+++ b/mysql-test/t/partition_innodb.test	2014-07-23 18:48:31 +0000
@@ -763,5 +763,32 @@ drop table t3;
 
 drop table t1,t2;
 
+--echo #
+--echo # MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
+--echo #
+create table t1(c1 int, c2 int, c3 int, c4 int,
+primary key(c1,c2)) engine=InnoDB
+partition by list columns(c2)
+(partition p1 values in (1,2) engine=InnoDB,
+partition p2 values in (3,4) engine=InnoDB);
+
+insert into t1 values (1,1,1,1),(2,3,1,1);
+select * from t1 where c1=2 and c2=3;
+drop table t1;
+
+--echo #
+--echo # MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
+--echo #  also MDEV-6240: Wrong "Impossible where" with LIST partitioning
+--echo #
+CREATE TABLE t1 ( d DATE) ENGINE = InnoDB
+PARTITION BY LIST COLUMNS (d)
+(
+  PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
+  PARTITION p1 VALUES IN ('1981-01-01')
+);
+
+INSERT INTO t1 (d) VALUES ('1991-01-01');
+SELECT *  FROM t1 WHERE d = '1991-01-01';
+DROP TABLE t1;
 
 set global default_storage_engine=default;

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2014-03-17 12:04:28 +0000
+++ b/sql/sql_partition.cc	2014-07-23 18:48:31 +0000
@@ -3261,11 +3261,16 @@ uint32 get_partition_id_cols_list_for_en
                                            nparts, left_endpoint,
                                            include_endpoint)));
 
-  if (!left_endpoint)
+  if (!left_endpoint && list_index < part_info->num_list_values)
   {
-    /* Set the end after this list tuple if not already after the last. */
-    if (list_index < part_info->num_parts)
-      list_index++;
+    /*
+      Set the end after this list tuple if it is not already after the last
+      and it matches.  ???
+    */
+    int cmp = cmp_rec_and_tuple_prune(list_col_array + list_index*num_columns,
+                                      nparts, left_endpoint, include_endpoint);
+    if (cmp >= 0)
+       list_index++;
   }
 
   DBUG_RETURN(list_index);



More information about the commits mailing list