List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:November 28 2007 12:02am
Subject:bk commit into 5.1 tree (sergefp:1.2656) BUG#32772
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of psergey. When psergey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-28 03:02:05+03:00, sergefp@stripped +3 -0
  BUG#32772: partition crash 1: enum column
  The bug was that for ordered index scans, ha_partition::index_init() did
  not put index columns into table->read_set if the underlying storage 
  engine did not have HA_PARTIAL_COLUMN_READ flag. 
  This was causing assertion failure when handle_ordered_index_scan() tried
  to sort the records according to index order.
  
  Fixed by making ha_partition::index_init() put index columns into table->read_set
  for all ordered scans. 

  mysql-test/r/partition.result@stripped, 2007-11-28 03:02:02+03:00, sergefp@stripped +13 -0
    BUG#32772: partition crash 1: enum column
    - Testcase

  mysql-test/t/partition.test@stripped, 2007-11-28 03:02:02+03:00, sergefp@stripped +20 -0
    BUG#32772: partition crash 1: enum column
    - Testcase

  sql/ha_partition.cc@stripped, 2007-11-28 03:02:02+03:00, sergefp@stripped +9 -6
    BUG#32772: partition crash 1: enum column
    - Make ha_partition::index_init() include index columns in the read_set
      whenever an ordered scan is initialized, no matter if
      HA_PARTIAL_COLUMN_READ is set or not.

diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result	2007-11-14 16:28:17 +03:00
+++ b/mysql-test/r/partition.result	2007-11-28 03:02:02 +03:00
@@ -1290,4 +1290,17 @@ create table t1
 partition by key(s1) partitions 3;
 insert into t1 values (null,null);
 drop table t1;
+create table t1 (
+c0 int,
+c1 bigint,
+c2 set('sweet'),
+key (c2,c1,c0), 
+key(c0)
+) engine=myisam partition by hash (month(c0)) partitions 5;
+insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019;
+insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644;
+select c1 from t1 group by (select c0 from t1 limit 1);
+c1
+-6862346
+drop table t1;
 End of 5.1 tests
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test	2007-11-14 16:28:18 +03:00
+++ b/mysql-test/t/partition.test	2007-11-28 03:02:02 +03:00
@@ -1531,4 +1531,24 @@ while ($cnt)
 --enable_query_log
 
 drop table t1;
+
+#
+# BUG#32272: partition crash 1: enum column
+#
+create table t1 (
+  c0 int,
+  c1 bigint,
+  c2 set('sweet'),
+  key (c2,c1,c0), 
+  key(c0)
+) engine=myisam partition by hash (month(c0)) partitions 5;
+
+--disable_warnings
+insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019;
+insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644;
+--enable_warnings
+# This must not fail assert:
+select c1 from t1 group by (select c0 from t1 limit 1);
+drop table t1;
+
 --echo End of 5.1 tests
diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
--- a/sql/ha_partition.cc	2007-11-20 05:02:43 +03:00
+++ b/sql/ha_partition.cc	2007-11-28 03:02:02 +03:00
@@ -3413,14 +3413,17 @@ int ha_partition::index_init(uint inx, b
   */
   if (m_lock_type == F_WRLCK)
     bitmap_union(table->read_set, &m_part_info->full_part_field_set);
-  else if (sorted && m_table_flags & HA_PARTIAL_COLUMN_READ)
+  else if (sorted)
   {
     /*
-      An ordered scan is requested and necessary fields aren't in read_set.
-      This may happen e.g. with SELECT COUNT(*) FROM t1. We must ensure
-      that all fields of current key are included into read_set, as
-      partitioning requires them for sorting
-      (see ha_partition::handle_ordered_index_scan).
+      An ordered scan is requested. We must make sure all fields of the 
+      used index are in the read set, as partitioning requires them for
+      sorting (see ha_partition::handle_ordered_index_scan).
+
+      The SQL layer may request an ordered index scan without having index
+      fields in the read set when
+       - it needs to do an ordered scan over an index prefix.
+       - it evaluates ORDER BY with SELECT COUNT(*) FROM t1.
 
       TODO: handle COUNT(*) queries via unordered scan.
     */
Thread
bk commit into 5.1 tree (sergefp:1.2656) BUG#32772Sergey Petrunia28 Nov