MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:April 21 2010 10:32pm
Subject:bzr commit into mysql-trunk-bugfixing branch (mattias.jonsson:3016)
Bug#52815
View as plain text  
#At file:///Users/mattiasj/clones/bzrroot/b52815-mysql-trunk-bf/ based on revid:alfranio.correia@stripped

 3016 Mattias Jonsson	2010-04-21
      Bug#52815: LIST COLUMNS doesn't insert rows in correct
                 partition if muliple columns used
      
      Problem was that range scanning through the sorted array of
      the column list values did not use a correct index calculation.
      
      Fixed by also taking the number of columns in the calculation.
     @ mysql-test/r/partition_column.result
        Bug#52815: LIST COLUMNS doesn't insert rows in correct
                   partition if muliple columns used
        
        Added test result for bug.
     @ mysql-test/t/partition_column.test
        Bug#52815: LIST COLUMNS doesn't insert rows in correct
                   partition if muliple columns used
        
        Added test for bug.
     @ sql/sql_partition.cc
        Bug#52815: LIST COLUMNS doesn't insert rows in correct
                   partition if muliple columns used
        
        list_col_array is a matrix of field values, so one must also
        use the number of columns to calculate the correct partition
        id.

    modified:
      mysql-test/r/partition_column.result
      mysql-test/t/partition_column.test
      sql/sql_partition.cc
=== modified file 'mysql-test/r/partition_column.result'
--- a/mysql-test/r/partition_column.result	2010-03-04 10:24:39 +0000
+++ b/mysql-test/r/partition_column.result	2010-04-21 22:32:27 +0000
@@ -1,4 +1,44 @@
 drop table if exists t1;
+#
+# Bug#52815: LIST COLUMNS doesn't insert rows in correct partition
+#            if muliple columns used
+CREATE TABLE t1 (
+id INT NOT NULL,
+name VARCHAR(255),
+department VARCHAR(10),
+country VARCHAR(255)
+) PARTITION BY LIST COLUMNS (department, country) (
+PARTITION first_office VALUES IN (('dep1', 'Russia'), ('dep1', 'Croatia')),
+PARTITION second_office VALUES IN (('dep2', 'Russia'))
+);
+INSERT INTO t1 VALUES(1, 'Ann', 'dep1', 'Russia');
+INSERT INTO t1 VALUES(2, 'Bob', 'dep1', 'Croatia');
+INSERT INTO t1 VALUES(3, 'Cecil', 'dep2', 'Russia');
+INSERT INTO t1 VALUES(3, 'Dan', 'dep2', 'Croatia');
+ERROR HY000: Table has no partition for value from column_list
+SELECT PARTITION_NAME,TABLE_ROWS
+FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1';
+PARTITION_NAME	TABLE_ROWS
+first_office	2
+second_office	1
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) NOT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `department` varchar(10) DEFAULT NULL,
+  `country` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50500 PARTITION BY LIST  COLUMNS(department,country)
+(PARTITION first_office VALUES IN (('dep1','Russia'),('dep1','Croatia')) ENGINE = MyISAM,
+ PARTITION second_office VALUES IN (('dep2','Russia')) ENGINE = MyISAM) */
+SELECT * FROM t1 WHERE department = 'dep2' and country = 'Croatia';
+id	name	department	country
+SELECT * FROM t1 WHERE department = 'dep1' and country = 'Croatia';
+id	name	department	country
+2	Bob	dep1	Croatia
+DROP TABLE t1;
 CREATE TABLE t1 (a DECIMAL)
 PARTITION BY RANGE COLUMNS (a)
 (PARTITION p0 VALUES LESS THAN (0));
@@ -298,11 +338,11 @@ select * from t1 where a > 8;
 a	b
 select * from t1 where a not between 8 and 8;
 a	b
+1	NULL
 2	NULL
+1	1
 2	2
 3	NULL
-1	NULL
-1	1
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/t/partition_column.test'
--- a/mysql-test/t/partition_column.test	2010-03-04 10:24:39 +0000
+++ b/mysql-test/t/partition_column.test	2010-04-21 22:32:27 +0000
@@ -8,6 +8,32 @@
 drop table if exists t1;
 --enable_warnings
 
+--echo #
+--echo # Bug#52815: LIST COLUMNS doesn't insert rows in correct partition
+--echo #            if muliple columns used
+CREATE TABLE t1 (
+id INT NOT NULL,
+name VARCHAR(255),
+department VARCHAR(10),
+country VARCHAR(255)
+) PARTITION BY LIST COLUMNS (department, country) (
+PARTITION first_office VALUES IN (('dep1', 'Russia'), ('dep1', 'Croatia')),
+PARTITION second_office VALUES IN (('dep2', 'Russia'))
+);
+
+INSERT INTO t1 VALUES(1, 'Ann', 'dep1', 'Russia');
+INSERT INTO t1 VALUES(2, 'Bob', 'dep1', 'Croatia');
+INSERT INTO t1 VALUES(3, 'Cecil', 'dep2', 'Russia');
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO t1 VALUES(3, 'Dan', 'dep2', 'Croatia');
+SELECT PARTITION_NAME,TABLE_ROWS
+FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1';
+SHOW CREATE TABLE t1;
+SELECT * FROM t1 WHERE department = 'dep2' and country = 'Croatia';
+SELECT * FROM t1 WHERE department = 'dep1' and country = 'Croatia';
+DROP TABLE t1;
+
 #
 # Bug#51347: assertion with show create table + partition by columns
 # on decimal column

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_partition.cc	2010-04-21 22:32:27 +0000
@@ -3096,7 +3096,7 @@ int get_partition_id_list_col(partition_
     }
     else
     {
-      *part_id= (uint32)list_col_array[list_index].partition_id;
+      *part_id= (uint32)list_col_array[list_index*num_columns].partition_id;
       DBUG_RETURN(0);
     }
   }
@@ -7701,7 +7701,7 @@ uint32 get_next_partition_id_range(PARTI
   DESCRIPTION
     This implementation of PARTITION_ITERATOR::get_next() is special for 
     LIST partitioning: it enumerates partition ids in
-    part_info->list_array[i] (list_col_array[i] for COLUMNS LIST
+    part_info->list_array[i] (list_col_array[i*cols] for COLUMNS LIST
     partitioning) where i runs over [min_idx, max_idx] interval.
     The function conforms to partition_iter_func type.
 
@@ -7727,9 +7727,12 @@ uint32 get_next_partition_id_list(PARTIT
   {
     partition_info *part_info= part_iter->part_info;
     uint32 num_part= part_iter->part_nums.cur++;
-    return part_info->column_list ?
-           part_info->list_col_array[num_part].partition_id :
-           part_info->list_array[num_part].partition_id;
+    if (part_info->column_list)
+    {
+      uint num_columns= part_info->part_field_list.elements;
+      return part_info->list_col_array[num_part*num_columns].partition_id;
+    }
+    return part_info->list_array[num_part].partition_id;
   }
 }
 


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-trunk-bugfixing branch (mattias.jonsson:3016)Bug#52815Mattias Jonsson22 Apr