Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4511

Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.2, 5.5.31, 5.3.12
    • 5.5.39, 10.0.13, 5.3.13
    • None
    • None

    Description

      strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed

      1442	int decimal_bin_size(int precision, int scale)
      1443	{
      1444	  int intg=precision-scale,
      1445	      intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
      1446	      intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
      1447	
      1448	  DBUG_ASSERT(scale >= 0);
      1449	  DBUG_ASSERT(precision > 0);
      1450	  DBUG_ASSERT(scale <= precision);
      1451	  return intg0*sizeof(dec1)+dig2bytes[intg0x]+
      1452	         frac0*sizeof(dec1)+dig2bytes[frac0x];

      #4  0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
      #5  0x00007f0c09239b8b in __GI_abort () at abort.c:91
      #6  0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
      #7  0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
      #8  0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
      #9  0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
      #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
      #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
      #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
      #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
      #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
      #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
      #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
      #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
      #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
      #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
      #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
      #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
      #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
      #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      bzr version-info

      revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
      date: 2013-05-09 23:25:57 +0200
      build-date: 2013-05-11 17:48:44 +0400
      revno: 3756
      branch-nick: 5.5

      Test case:

      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;

      Setting to Minor because the query is rather silly

      Another test case that crashes the server:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;

      So does this one:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;

      So does this one:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;

      So does this one:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;

      More crashing tests:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
      SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);

      Attachments

        Activity

          elenst Elena Stepanova created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.4 [ 13101 ]
          Fix Version/s 10.0.3 [ 12900 ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          Another test case that crashes the server:
          {code:sql}
           DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          _Setting to Minor because the query is rather silly_
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          Another test case that crashes the server:
          {code:sql}
           DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          _Setting to Minor because the query is rather silly_
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          _Setting to Minor because the query is rather silly_
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          _Setting to Minor because the query is rather silly_
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.33 [ 13300 ]
          Fix Version/s 5.5.32 [ 13000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.5 [ 13201 ]
          Fix Version/s 10.0.4 [ 13101 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.34 [ 13500 ]
          Fix Version/s 5.5.33 [ 13300 ]
          bar Alexander Barkov made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.34 [ 13700 ]
          Fix Version/s 5.5.33a [ 13500 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.6 [ 13202 ]
          Fix Version/s 10.0.5 [ 13201 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.7 [ 14100 ]
          Fix Version/s 10.0.6 [ 13202 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.35 [ 14000 ]
          Fix Version/s 5.5.34 [ 13700 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.8 [ 14200 ]
          Fix Version/s 10.0.7 [ 14100 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.36 [ 14600 ]
          Fix Version/s 5.5.35 [ 14000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.9 [ 14400 ]
          Fix Version/s 10.0.8 [ 14200 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.37 [ 15000 ]
          Fix Version/s 5.5.36 [ 14600 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.10 [ 14500 ]
          Fix Version/s 10.0.9 [ 14400 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.11 [ 15200 ]
          Fix Version/s 10.0.10 [ 14500 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.38 [ 15400 ]
          Fix Version/s 5.5.37 [ 15000 ]
          bar Alexander Barkov made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]
          bar Alexander Barkov made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          bar Alexander Barkov made changes -
          Status Stalled [ 10000 ] In Progress [ 3 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.12 [ 15201 ]
          Fix Version/s 10.0.11 [ 15200 ]
          serg Sergei Golubchik made changes -
          Rank Ranked higher
          bar Alexander Barkov made changes -
          Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code:sql}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code:sql}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          More crashing tests:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          More crashing tests:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          More crashing tests:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
          {code}
          bar Alexander Barkov made changes -
          Description {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          More crashing tests:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
          {code}
          {noformat}
          strings/decimal.c:1450: decimal_bin_size: Assertion `scale <= precision' failed
          {noformat}
          {noformat}
          1442 int decimal_bin_size(int precision, int scale)
          1443 {
          1444 int intg=precision-scale,
          1445 intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
          1446 intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
          1447
          1448 DBUG_ASSERT(scale >= 0);
          1449 DBUG_ASSERT(precision > 0);
          1450 DBUG_ASSERT(scale <= precision);
          1451 return intg0*sizeof(dec1)+dig2bytes[intg0x]+
          1452 frac0*sizeof(dec1)+dig2bytes[frac0x];
          {noformat}
          {noformat}
          #4 0x00007f0c09236425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
          #5 0x00007f0c09239b8b in __GI_abort () at abort.c:91
          #6 0x00007f0c0922f0ee in __assert_fail_base (fmt=<optimized out>, assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=<optimized out>, function=<optimized out>) at assert.c:94
          #7 0x00007f0c0922f192 in __GI___assert_fail (assertion=0xfa1873 "scale <= precision", file=0xfa15e0 "/home/elenst/bzr/5.5/strings/decimal.c", line=1450, function=0xfa1a60 "decimal_bin_size") at assert.c:103
          #8 0x0000000000cf36d8 in decimal_bin_size (precision=19, scale=30) at /home/elenst/bzr/5.5/strings/decimal.c:1450
          #9 0x0000000000679cf3 in my_decimal_get_binary_size (precision=19, scale=30) at /home/elenst/bzr/5.5/sql/my_decimal.h:263
          #10 0x0000000000670aa7 in calc_group_buffer (join=0x7f0bf4008240, group=0x7f0bf4008148) at /home/elenst/bzr/5.5/sql/sql_select.cc:20358
          #11 0x0000000000641c12 in JOIN::optimize (this=0x7f0bf4008240) at /home/elenst/bzr/5.5/sql/sql_select.cc:1564
          #12 0x0000000000646f55 in mysql_select (thd=0x3d8a0b0, rref_pointer_array=0x3d8d0b8, tables=0x7f0bf4007700, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0bf4008148, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0bf4008220, unit=0x3d8c788, select_lex=0x3d8ce60) at /home/elenst/bzr/5.5/sql/sql_select.cc:3040
          #13 0x000000000063db9e in handle_select (thd=0x3d8a0b0, lex=0x3d8c6d8, result=0x7f0bf4008220, setup_tables_done_option=0) at /home/elenst/bzr/5.5/sql/sql_select.cc:318
          #14 0x000000000061691d in execute_sqlcom_select (thd=0x3d8a0b0, all_tables=0x7f0bf4007700) at /home/elenst/bzr/5.5/sql/sql_parse.cc:4642
          #15 0x000000000060f36c in mysql_execute_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:2196
          #16 0x00000000006191bc in mysql_parse (thd=0x3d8a0b0, rawbuf=0x7f0bf40074c8 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", length=57, parser_state=0x7f0bfe912500) at /home/elenst/bzr/5.5/sql/sql_parse.cc:5760
          #17 0x000000000060c8ac in dispatch_command (command=COM_QUERY, thd=0x3d8a0b0, packet=0x3e7eae1 "SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1", packet_length=57) at /home/elenst/bzr/5.5/sql/sql_parse.cc:1068
          #18 0x000000000060baed in do_command (thd=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_parse.cc:794
          #19 0x0000000000711fdd in do_handle_one_connection (thd_arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1266
          #20 0x00000000007119c4 in handle_one_connection (arg=0x3d8a0b0) at /home/elenst/bzr/5.5/sql/sql_connect.cc:1181
          #21 0x000000000096004c in pfs_spawn_thread (arg=0x3e17390) at /home/elenst/bzr/5.5/storage/perfschema/pfs.cc:1015
          #22 0x00007f0c09fffe9a in start_thread (arg=0x7f0bfe913700) at pthread_create.c:308
          #23 0x00007f0c092f3cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
          {noformat}
          bzr version-info
          {noformat}
          revision-id: wlad@montyprogram.com-20130509212557-5cdelkdvf7t61062
          date: 2013-05-09 23:25:57 +0200
          build-date: 2013-05-11 17:48:44 +0400
          revno: 3756
          branch-nick: 5.5
          {noformat}

          Test case:
          {code:sql}
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY TIMEDIFF( '2004-06-12', a ) * 1;
          {code}

          _Setting to Minor because the query is rather silly_

          Another test case that crashes the server:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
          {code}

          So does this one:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
          {code}

          More crashing tests:
          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
          {code}

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
          {code}

          {code}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
          INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
          SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);
          {code}
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.39 [ 15800 ]
          Fix Version/s 5.5.38 [ 15400 ]
          serg Sergei Golubchik made changes -
          Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 27375 ] MariaDB v2 [ 44156 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.13 [ 16000 ]
          Fix Version/s 10.0.12 [ 15201 ]
          serg Sergei Golubchik made changes -
          Status Stalled [ 10000 ] In Review [ 10002 ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          bar Alexander Barkov made changes -
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.13 [ 16300 ]
          Fix Version/s 5.5 [ 15800 ]
          Fix Version/s 10.0 [ 16000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.39 [ 16301 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 44156 ] MariaDB v3 [ 64332 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 64332 ] MariaDB v4 [ 146687 ]

          People

            bar Alexander Barkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.