Bug #32772 partition crash 1: enum column and double
Submitted: 27 Nov 2007 14:36 Modified: 14 Dec 2007 16:45
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.1.23-debug OS:Any
Assigned to: Sergey Petrunya CPU Architecture:Any

[27 Nov 2007 14:36] Shane Bester
Description:
without partitioning the crash didn't occur. Seems enum related, even though the enum column is not the partitioned column, and the select doesn't even touch the enum field :-/

Version: '5.1.23-rc-debug'  socket: ''  port: 3306  Source distribution
Assertion failed: !table || (!table->read_set || bitmap_is_set(table->read_set, field_index)), file .\field.cc, line 8264

mysqld.exe!_NMSG_WRITE
mysqld.exe!abort
mysqld.exe!_wassert
mysqld.exe!Field_enum::val_int
mysqld.exe!Field_enum::cmp
mysqld.exe!Field::cmp_max
mysqld.exe!key_rec_cmp
mysqld.exe!_downheap
mysqld.exe!queue_fix
mysqld.exe!ha_partition::handle_ordered_index_scan
mysqld.exe!ha_partition::common_first_last
mysqld.exe!ha_partition::index_first
mysqld.exe!join_read_first
mysqld.exe!sub_select
mysqld.exe!do_select
mysqld.exe!JOIN::exec
mysqld.exe!mysql_select
mysqld.exe!handle_select
mysqld.exe!execute_sqlcom_select
mysqld.exe!mysql_execute_command
mysqld.exe!mysql_parse
mysqld.exe!dispatch_command
mysqld.exe!do_command
mysqld.exe!handle_one_connection
mysqld.exe!pthread_start
mysqld.exe!_callthreadstart
mysqld.exe!_threadstart
kernel32.dll!FlsSetValue

How to repeat:
drop table if exists `t1`;
create table `t1` (`c0` int,`c1` bigint,`c2` set('sweet'),key (`c2`,`c1`,`c0`),key(`c0`)) engine=myisam /*!50100 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);
[27 Nov 2007 14:36] MySQL Verification Team
somebody please verify with 5.1BK
[27 Nov 2007 14:41] MySQL Verification Team
Shane,
It is your source the last one?. I can't repeat with release server and
source 3 days older:

mysql> create table `t1` (`c0` int,`c1` bigint,`c2` set('sweet'),key (`c2`,`c1`,`c0`),key(`c0`))
    -> engine=myisam /*!50100 partition by hash (month(`c0`)) partitions 5*/;
Query OK, 0 rows affected (0.17 sec)

mysql> insert ignore into `t1` set `c0` = -6502262, `c1` = 3992917, `c2` = 35019;
Query OK, 1 row affected, 2 warnings (0.08 sec)

mysql> insert ignore into `t1` set `c0` = 241221, `c1` = -6862346, `c2` = 56644;
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select `c1` from `t1` group by (select `c0` from `t1` limit 1);
+----------+
| c1       |
+----------+
| -6862346 |
+----------+
1 row in set (0.05 sec)

mysql> select version();
+------------------+
| version()        |
+------------------+
| 5.1.23-rc-nt-log |
+------------------+
1 row in set (0.00 sec)

mysql>
[27 Nov 2007 14:46] MySQL Verification Team
miguel please check if full debug build will crash?
[27 Nov 2007 14:52] MySQL Verification Team
Same source and full debug on Linux, crashes:

[miguel@skybr 5.1]$ bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.23-rc-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> drop table if exists `t1`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table `t1` (`c0` int,`c1` bigint,`c2` set('sweet'),key (`c2`,`c1`,`c0`),key(`c0`))
    -> engine=myisam /*!50100 partition by hash (month(`c0`)) partitions 5*/;
Query OK, 0 rows affected (0.04 sec)

mysql> insert ignore into `t1` set `c0` = -6502262, `c1` = 3992917, `c2` = 35019;
Query OK, 1 row affected, 2 warnings (0.00 sec)

mysql> insert ignore into `t1` set `c0` = 241221, `c1` = -6862346, `c2` = 56644;
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select `c1` from `t1` group by (select `c0` from `t1` limit 1);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[28 Nov 2007 0:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38660

ChangeSet@1.2656, 2007-11-28 03:02:05+03:00, sergefp@mysql.com +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.
[28 Nov 2007 14:31] MySQL Verification Team
another slightly different testcase for the crash in Field_double:cmp

drop table if exists `t1`;
create table `t1` (`c0` int,`c1` bigint, `c2` double (2,0) zerofill ,key (`c2`,`c1`,`c0`),key(`c0`)) engine=myisam /*!50100 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);
[14 Dec 2007 8:18] Bugs System
Pushed into 5.1.23-rc
[14 Dec 2007 8:21] Bugs System
Pushed into 6.0.5-alpha
[14 Dec 2007 16:45] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented in 5.1.23 and 6.0.5 changelogs as follows:
      
        A query of the form SELECT
          col1 FROM
          table GROUP BY (SELECT
          col2 FROM
          table LIMIT 1); against a
        partitioned table having a
        SET column crashed the server.