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

Assertion `precision > 0' failed in decimal_bin_size upon SELECT with GROUP BY and/or ORDER BY

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.7(EOL)
    • 10.5, 10.6, 10.11, 11.4
    • Data types
    • None

    Description

      Note: Patch for MDEV-20495 is already in the trees, so it can't be a duplicate of it, and I can't find any other suitable candidates.

      CREATE TABLE t1 (a DECIMAL(1,0) ZEROFILL DEFAULT 0);
      INSERT INTO t1 VALUES (1),(2);
      SELECT DISTINCT a FROM t1 GROUP BY DEFAULT(a) WITH ROLLUP;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 eb0a10b0

      mysqld: /data/src/10.4/strings/decimal.c:1466: decimal_bin_size: Assertion `precision > 0' failed.
      191004 17:09:37 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f68d064ef12 in __GI___assert_fail (assertion=0x55e20b51e725 "precision > 0", file=0x55e20b51e4a0 "/data/src/5.5-bug/strings/decimal.c", line=1460, function=0x55e20b51e9a0 <__PRETTY_FUNCTION__.10294> "decimal_bin_size") at assert.c:101
      #8  0x000055e20b24bcd4 in decimal_bin_size (precision=0, scale=0) at /data/src/5.5-bug/strings/decimal.c:1460
      #9  0x000055e20abd3f71 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/5.5-bug/sql/my_decimal.h:263
      #10 0x000055e20acf2b07 in Field_new_decimal::Field_new_decimal (this=0x7f68cb459978, len_arg=1, maybe_null_arg=true, name=0x0, dec_arg=0 '\000', unsigned_arg=false) at /data/src/5.5-bug/sql/field.cc:2530
      #11 0x000055e20acf2c61 in Field_new_decimal::create_from_item (item=0x7f68cb580098) at /data/src/5.5-bug/sql/field.cc:2574
      #12 0x000055e20abbad8b in create_tmp_field_from_item (thd=0x7f68cc3f0060, item=0x7f68cb580098, table=0x7f68cb598078, copy_func=0x7f68d20c2288, modify_item=true, convert_blob_length=0) at /data/src/5.5-bug/sql/sql_select.cc:14804
      #13 0x000055e20abbb56d in create_tmp_field (thd=0x7f68cc3f0060, table=0x7f68cb598078, item=0x7f68cb580098, type=Item::FUNC_ITEM, copy_func=0x7f68d20c2288, from_field=0x7f68cb598db8, default_field=0x7f68cb598d98, group=false, modify_item=true, table_cant_handle_bit_fields=false, make_copy_field=false, convert_blob_length=0) at /data/src/5.5-bug/sql/sql_select.cc:15040
      #14 0x000055e20abbc899 in create_tmp_table (thd=0x7f68cc3f0060, param=0x7f68cb548dd0, fields=..., group=0x0, distinct=false, save_sum_fields=true, select_options=2147748609, rows_limit=18446744073709551615, table_alias=0x55e20b289802 "", do_not_open=false, keep_row_order=false) at /data/src/5.5-bug/sql/sql_select.cc:15394
      #15 0x000055e20ab99f20 in JOIN::init_execution (this=0x7f68cb548bc0) at /data/src/5.5-bug/sql/sql_select.cc:1894
      #16 0x000055e20ab9bf04 in JOIN::exec (this=0x7f68cb548bc0) at /data/src/5.5-bug/sql/sql_select.cc:2440
      #17 0x000055e20ab9e3f7 in mysql_select (thd=0x7f68cc3f0060, rref_pointer_array=0x7f68cc3f3d08, tables=0x7f68cb5482b8, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f68cb548ac0, having=0x0, proc_param=0x0, select_options=2147748609, result=0x7f68cb548ba0, unit=0x7f68cc3f3388, select_lex=0x7f68cc3f3a68) at /data/src/5.5-bug/sql/sql_select.cc:3135
      #18 0x000055e20ab949c4 in handle_select (thd=0x7f68cc3f0060, lex=0x7f68cc3f32d8, result=0x7f68cb548ba0, setup_tables_done_option=0) at /data/src/5.5-bug/sql/sql_select.cc:312
      #19 0x000055e20ab6d890 in execute_sqlcom_select (thd=0x7f68cc3f0060, all_tables=0x7f68cb5482b8) at /data/src/5.5-bug/sql/sql_parse.cc:4684
      #20 0x000055e20ab66791 in mysql_execute_command (thd=0x7f68cc3f0060) at /data/src/5.5-bug/sql/sql_parse.cc:2222
      #21 0x000055e20ab70453 in mysql_parse (thd=0x7f68cc3f0060, rawbuf=0x7f68cb548078 "SELECT DISTINCT a FROM t1 GROUP BY DEFAULT(a) WITH ROLLUP", length=57, parser_state=0x7f68d20c3620) at /data/src/5.5-bug/sql/sql_parse.cc:5929
      #22 0x000055e20ab63d0f in dispatch_command (command=COM_QUERY, thd=0x7f68cc3f0060, packet=0x7f68cc2f2061 "SELECT DISTINCT a FROM t1 GROUP BY DEFAULT(a) WITH ROLLUP", packet_length=57) at /data/src/5.5-bug/sql/sql_parse.cc:1067
      #23 0x000055e20ab62f1f in do_command (thd=0x7f68cc3f0060) at /data/src/5.5-bug/sql/sql_parse.cc:793
      #24 0x000055e20ac68a8f in do_handle_one_connection (thd_arg=0x7f68cc3f0060) at /data/src/5.5-bug/sql/sql_connect.cc:1268
      #25 0x000055e20ac687fe in handle_one_connection (arg=0x7f68cc3f0060) at /data/src/5.5-bug/sql/sql_connect.cc:1184
      #26 0x000055e20afed250 in pfs_spawn_thread (arg=0x7f68cc29a080) at /data/src/5.5-bug/storage/perfschema/pfs.cc:1015
      #27 0x00007f68d1cf54a4 in start_thread (arg=0x7f68d20c4700) at pthread_create.c:456
      #28 0x00007f68d070bd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
      

      Reproducible on 5.5-10.4 with at least MyISAM, InnoDB, Aria.
      Couldn't reproduce on 10.5, but see comments for other test cases which also fail on 10.5+.

      Non-debug build produces a warning:

      SELECT DISTINCT a FROM t1 GROUP BY DEFAULT(a) WITH ROLLUP;
      a
      0
      Warnings:
      Warning	1918	Encountered illegal value '' when converting to DECIMAL
      

      I am not sure whether it's expected.

      Attachments

        Issue Links

          Activity

            I don't want to create yet another issue for this assertion, so I'll extend this one in hope that this all has the same root cause.

            CREATE TABLE t1 (d DATE);
            INSERT INTO t1 VALUES ('2020-12-12'),('1900-11-11');
            SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END;
             
            # Cleanup
            DROP TABLE t1;
            

            10.3 75538f94

            mysqld: /data/src/10.3/strings/decimal.c:1484: decimal_bin_size: Assertion `precision > 0' failed.
            210127  1:36:55 [ERROR] mysqld got signal 6 ;
             
            #7  0x00007f74f9138f36 in __GI___assert_fail (assertion=0x5604e833b525 "precision > 0", file=0x5604e833b2a0 "/data/src/10.3/strings/decimal.c", line=1484, function=0x5604e833b790 <__PRETTY_FUNCTION__.14235> "decimal_bin_size") at assert.c:101
            #8  0x00005604e7e3f32f in decimal_bin_size (precision=0, scale=0) at /data/src/10.3/strings/decimal.c:1484
            #9  0x00005604e72c8de9 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.3/sql/my_decimal.h:263
            #10 0x00005604e755b7d6 in Type_handler_decimal_result::sortlength (this=0x5604e868a998 <type_handler_newdecimal>, thd=0x7f74d8000d90, item=0x7f74d8013c78, sortorder=0x7f74d80164c8) at /data/src/10.3/sql/filesort.cc:1914
            #11 0x00005604e755b973 in sortlength (thd=0x7f74d8000d90, sortorder=0x7f74d80164c8, s_length=0, multi_byte_charset=0x7f74f4101faf) at /data/src/10.3/sql/filesort.cc:1960
            #12 0x00005604e755639f in filesort (thd=0x7f74d8000d90, table=0x7f74d8036310, filesort=0x7f74d8015da8, tracker=0x7f74d8016448, join=0x7f74d8013fa0, first_table_bit=1) at /data/src/10.3/sql/filesort.cc:186
            #13 0x00005604e72ba4f5 in create_sort_index (thd=0x7f74d8000d90, join=0x7f74d8013fa0, tab=0x7f74d80152c8, fsort=0x7f74d8015da8) at /data/src/10.3/sql/sql_select.cc:22923
            #14 0x00005604e72b46c2 in st_join_table::sort_table (this=0x7f74d80152c8) at /data/src/10.3/sql/sql_select.cc:20686
            #15 0x00005604e72b429a in join_init_read_record (tab=0x7f74d80152c8) at /data/src/10.3/sql/sql_select.cc:20627
            #16 0x00005604e72b1fd2 in sub_select (join=0x7f74d8013fa0, join_tab=0x7f74d80152c8, end_of_records=false) at /data/src/10.3/sql/sql_select.cc:19708
            #17 0x00005604e72b1507 in do_select (join=0x7f74d8013fa0, procedure=0x0) at /data/src/10.3/sql/sql_select.cc:19251
            #18 0x00005604e72884cf in JOIN::exec_inner (this=0x7f74d8013fa0) at /data/src/10.3/sql/sql_select.cc:4124
            #19 0x00005604e728788e in JOIN::exec (this=0x7f74d8013fa0) at /data/src/10.3/sql/sql_select.cc:3918
            #20 0x00005604e7288bab in mysql_select (thd=0x7f74d8000d90, tables=0x7f74d8012d50, wild_num=1, fields=..., conds=0x0, og_num=1, order=0x7f74d8013e50, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f74d8013f78, unit=0x7f74d8004c58, select_lex=0x7f74d80053e0) at /data/src/10.3/sql/sql_select.cc:4323
            #21 0x00005604e727a13e in handle_select (thd=0x7f74d8000d90, lex=0x7f74d8004b98, result=0x7f74d8013f78, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:370
            #22 0x00005604e7240804 in execute_sqlcom_select (thd=0x7f74d8000d90, all_tables=0x7f74d8012d50) at /data/src/10.3/sql/sql_parse.cc:6316
            #23 0x00005604e7237011 in mysql_execute_command (thd=0x7f74d8000d90) at /data/src/10.3/sql/sql_parse.cc:3847
            #24 0x00005604e7244b88 in mysql_parse (thd=0x7f74d8000d90, rawbuf=0x7f74d8012ab8 "SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", length=104, parser_state=0x7f74f41035c0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7840
            #25 0x00005604e72312ec in dispatch_command (command=COM_QUERY, thd=0x7f74d8000d90, packet=0x7f74d8008f11 "", packet_length=104, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
            #26 0x00005604e722fc8c in do_command (thd=0x7f74d8000d90) at /data/src/10.3/sql/sql_parse.cc:1398
            #27 0x00005604e73ae295 in do_handle_one_connection (connect=0x5604ea3d5070) at /data/src/10.3/sql/sql_connect.cc:1403
            #28 0x00005604e73adff1 in handle_one_connection (arg=0x5604ea3d5070) at /data/src/10.3/sql/sql_connect.cc:1308
            #29 0x00005604e7d7a027 in pfs_spawn_thread (arg=0x5604ea3b8440) at /data/src/10.3/storage/perfschema/pfs.cc:1869
            #30 0x00007f74f9648609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #31 0x00007f74f9224293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            CREATE TABLE t1 (d DATE);
            INSERT INTO t1 VALUES ('2020-12-12'),('1900-11-11');
            SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END;
             
            # Cleanup
            DROP TABLE t1;
            

            10.3 75538f94

            mysqld: /data/src/10.3/strings/decimal.c:1484: decimal_bin_size: Assertion `precision > 0' failed.
            210127  1:38:12 [ERROR] mysqld got signal 6 ;
             
            #7  0x00007f25b4ea2f36 in __GI___assert_fail (assertion=0x5594e9ff9525 "precision > 0", file=0x5594e9ff92a0 "/data/src/10.3/strings/decimal.c", line=1484, function=0x5594e9ff9790 <__PRETTY_FUNCTION__.14235> "decimal_bin_size") at assert.c:101
            #8  0x00005594e9afd32f in decimal_bin_size (precision=0, scale=0) at /data/src/10.3/strings/decimal.c:1484
            #9  0x00005594e8f86de9 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.3/sql/my_decimal.h:263
            #10 0x00005594e91dfda1 in Field_new_decimal::Field_new_decimal (this=0x7f25940acc48, ptr_arg=0x0, len_arg=0, null_ptr_arg=0x5594e9b23233 "", null_bit_arg=0 '\000', unireg_check_arg=Field::NONE, field_name_arg=0x7f2594013e50, dec_arg=0 '\000', zero_arg=false, unsigned_arg=false) at /data/src/10.3/sql/field.cc:3137
            #11 0x00005594e90f9f90 in Type_handler_newdecimal::make_table_field (this=0x5594ea348998 <type_handler_newdecimal>, name=0x7f2594013e50, addr=..., attr=..., table=0x7f25940390a8) at /data/src/10.3/sql/sql_type.cc:2206
            #12 0x00005594e90f9645 in Type_handler::make_and_init_table_field (this=0x5594ea348998 <type_handler_newdecimal>, name=0x7f2594013e50, addr=..., attr=..., table=0x7f25940390a8) at /data/src/10.3/sql/sql_type.cc:2033
            #13 0x00005594e8dde64d in Item::tmp_table_field_from_field_type (this=0x7f2594013e00, table=0x7f25940390a8) at /data/src/10.3/sql/item.h:707
            #14 0x00005594e8ddfb4c in Item::create_tmp_field (this=0x7f2594013e00, group=false, table=0x7f25940390a8) at /data/src/10.3/sql/item.h:1948
            #15 0x00005594e8f686f7 in create_tmp_field_from_item (thd=0x7f2594000d90, item=0x7f2594013e00, table=0x7f25940390a8, copy_func=0x7f25b0052f78, modify_item=true) at /data/src/10.3/sql/sql_select.cc:17117
            #16 0x00005594e8f6907b in create_tmp_field (thd=0x7f2594000d90, table=0x7f25940390a8, item=0x7f2594013e00, type=Item::FUNC_ITEM, copy_func=0x7f25b0052f78, from_field=0x7f259403a1c0, default_field=0x7f259403a1a0, group=true, modify_item=true, table_cant_handle_bit_fields=false, make_copy_field=false) at /data/src/10.3/sql/sql_select.cc:17343
            #17 0x00005594e8f6a5c3 in create_tmp_table (thd=0x7f2594000d90, param=0x7f2594016230, fields=..., group=0x7f25940134f8, distinct=false, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x5594ea20ef00 <empty_clex_str>, do_not_open=true, keep_row_order=false) at /data/src/10.3/sql/sql_select.cc:17723
            #18 0x00005594e8f43b67 in JOIN::create_postjoin_aggr_table (this=0x7f2594014130, tab=0x7f2594015750, table_fields=0x7f2594014450, table_group=0x7f25940134f8, save_sum_fields=false, distinct=false, keep_row_order=false) at /data/src/10.3/sql/sql_select.cc:3432
            #19 0x00005594e8f421b0 in JOIN::make_aggr_tables_info (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:3032
            #20 0x00005594e8f40ba0 in JOIN::optimize_stage2 (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:2679
            #21 0x00005594e8f3e5f0 in JOIN::optimize_inner (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:1985
            #22 0x00005594e8f3c9c0 in JOIN::optimize (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:1501
            #23 0x00005594e8f46b12 in mysql_select (thd=0x7f2594000d90, tables=0x7f2594012d70, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x7f2594013fe0, group=0x7f25940134f8, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f2594014108, unit=0x7f2594004c58, select_lex=0x7f25940053e0) at /data/src/10.3/sql/sql_select.cc:4309
            #24 0x00005594e8f3813e in handle_select (thd=0x7f2594000d90, lex=0x7f2594004b98, result=0x7f2594014108, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:370
            #25 0x00005594e8efe804 in execute_sqlcom_select (thd=0x7f2594000d90, all_tables=0x7f2594012d70) at /data/src/10.3/sql/sql_parse.cc:6316
            #26 0x00005594e8ef5011 in mysql_execute_command (thd=0x7f2594000d90) at /data/src/10.3/sql/sql_parse.cc:3847
            #27 0x00005594e8f02b88 in mysql_parse (thd=0x7f2594000d90, rawbuf=0x7f2594012ab8 "SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", length=115, parser_state=0x7f25b00545c0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7840
            #28 0x00005594e8eef2ec in dispatch_command (command=COM_QUERY, thd=0x7f2594000d90, packet=0x7f2594008f11 "SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", packet_length=115, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
            #29 0x00005594e8eedc8c in do_command (thd=0x7f2594000d90) at /data/src/10.3/sql/sql_parse.cc:1398
            #30 0x00005594e906c295 in do_handle_one_connection (connect=0x5594ec48d070) at /data/src/10.3/sql/sql_connect.cc:1403
            #31 0x00005594e906bff1 in handle_one_connection (arg=0x5594ec48d070) at /data/src/10.3/sql/sql_connect.cc:1308
            #32 0x00005594e9a38027 in pfs_spawn_thread (arg=0x5594ec470440) at /data/src/10.3/storage/perfschema/pfs.cc:1869
            #33 0x00007f25b53b2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #34 0x00007f25b4f8e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Unlike the test case in the description, both ones above don't fail on 10.2, but fail on 10.3+, including 10.5 and 10.6.

            elenst Elena Stepanova added a comment - I don't want to create yet another issue for this assertion, so I'll extend this one in hope that this all has the same root cause. CREATE TABLE t1 (d DATE ); INSERT INTO t1 VALUES ( '2020-12-12' ),( '1900-11-11' ); SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK( 'x' ) DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END ;   # Cleanup DROP TABLE t1; 10.3 75538f94 mysqld: /data/src/10.3/strings/decimal.c:1484: decimal_bin_size: Assertion `precision > 0' failed. 210127 1:36:55 [ERROR] mysqld got signal 6 ;   #7 0x00007f74f9138f36 in __GI___assert_fail (assertion=0x5604e833b525 "precision > 0", file=0x5604e833b2a0 "/data/src/10.3/strings/decimal.c", line=1484, function=0x5604e833b790 <__PRETTY_FUNCTION__.14235> "decimal_bin_size") at assert.c:101 #8 0x00005604e7e3f32f in decimal_bin_size (precision=0, scale=0) at /data/src/10.3/strings/decimal.c:1484 #9 0x00005604e72c8de9 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.3/sql/my_decimal.h:263 #10 0x00005604e755b7d6 in Type_handler_decimal_result::sortlength (this=0x5604e868a998 <type_handler_newdecimal>, thd=0x7f74d8000d90, item=0x7f74d8013c78, sortorder=0x7f74d80164c8) at /data/src/10.3/sql/filesort.cc:1914 #11 0x00005604e755b973 in sortlength (thd=0x7f74d8000d90, sortorder=0x7f74d80164c8, s_length=0, multi_byte_charset=0x7f74f4101faf) at /data/src/10.3/sql/filesort.cc:1960 #12 0x00005604e755639f in filesort (thd=0x7f74d8000d90, table=0x7f74d8036310, filesort=0x7f74d8015da8, tracker=0x7f74d8016448, join=0x7f74d8013fa0, first_table_bit=1) at /data/src/10.3/sql/filesort.cc:186 #13 0x00005604e72ba4f5 in create_sort_index (thd=0x7f74d8000d90, join=0x7f74d8013fa0, tab=0x7f74d80152c8, fsort=0x7f74d8015da8) at /data/src/10.3/sql/sql_select.cc:22923 #14 0x00005604e72b46c2 in st_join_table::sort_table (this=0x7f74d80152c8) at /data/src/10.3/sql/sql_select.cc:20686 #15 0x00005604e72b429a in join_init_read_record (tab=0x7f74d80152c8) at /data/src/10.3/sql/sql_select.cc:20627 #16 0x00005604e72b1fd2 in sub_select (join=0x7f74d8013fa0, join_tab=0x7f74d80152c8, end_of_records=false) at /data/src/10.3/sql/sql_select.cc:19708 #17 0x00005604e72b1507 in do_select (join=0x7f74d8013fa0, procedure=0x0) at /data/src/10.3/sql/sql_select.cc:19251 #18 0x00005604e72884cf in JOIN::exec_inner (this=0x7f74d8013fa0) at /data/src/10.3/sql/sql_select.cc:4124 #19 0x00005604e728788e in JOIN::exec (this=0x7f74d8013fa0) at /data/src/10.3/sql/sql_select.cc:3918 #20 0x00005604e7288bab in mysql_select (thd=0x7f74d8000d90, tables=0x7f74d8012d50, wild_num=1, fields=..., conds=0x0, og_num=1, order=0x7f74d8013e50, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f74d8013f78, unit=0x7f74d8004c58, select_lex=0x7f74d80053e0) at /data/src/10.3/sql/sql_select.cc:4323 #21 0x00005604e727a13e in handle_select (thd=0x7f74d8000d90, lex=0x7f74d8004b98, result=0x7f74d8013f78, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:370 #22 0x00005604e7240804 in execute_sqlcom_select (thd=0x7f74d8000d90, all_tables=0x7f74d8012d50) at /data/src/10.3/sql/sql_parse.cc:6316 #23 0x00005604e7237011 in mysql_execute_command (thd=0x7f74d8000d90) at /data/src/10.3/sql/sql_parse.cc:3847 #24 0x00005604e7244b88 in mysql_parse (thd=0x7f74d8000d90, rawbuf=0x7f74d8012ab8 "SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", length=104, parser_state=0x7f74f41035c0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7840 #25 0x00005604e72312ec in dispatch_command (command=COM_QUERY, thd=0x7f74d8000d90, packet=0x7f74d8008f11 "", packet_length=104, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852 #26 0x00005604e722fc8c in do_command (thd=0x7f74d8000d90) at /data/src/10.3/sql/sql_parse.cc:1398 #27 0x00005604e73ae295 in do_handle_one_connection (connect=0x5604ea3d5070) at /data/src/10.3/sql/sql_connect.cc:1403 #28 0x00005604e73adff1 in handle_one_connection (arg=0x5604ea3d5070) at /data/src/10.3/sql/sql_connect.cc:1308 #29 0x00005604e7d7a027 in pfs_spawn_thread (arg=0x5604ea3b8440) at /data/src/10.3/storage/perfschema/pfs.cc:1869 #30 0x00007f74f9648609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #31 0x00007f74f9224293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 CREATE TABLE t1 (d DATE ); INSERT INTO t1 VALUES ( '2020-12-12' ),( '1900-11-11' ); SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK( 'x' ) DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END ;   # Cleanup DROP TABLE t1; 10.3 75538f94 mysqld: /data/src/10.3/strings/decimal.c:1484: decimal_bin_size: Assertion `precision > 0' failed. 210127 1:38:12 [ERROR] mysqld got signal 6 ;   #7 0x00007f25b4ea2f36 in __GI___assert_fail (assertion=0x5594e9ff9525 "precision > 0", file=0x5594e9ff92a0 "/data/src/10.3/strings/decimal.c", line=1484, function=0x5594e9ff9790 <__PRETTY_FUNCTION__.14235> "decimal_bin_size") at assert.c:101 #8 0x00005594e9afd32f in decimal_bin_size (precision=0, scale=0) at /data/src/10.3/strings/decimal.c:1484 #9 0x00005594e8f86de9 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.3/sql/my_decimal.h:263 #10 0x00005594e91dfda1 in Field_new_decimal::Field_new_decimal (this=0x7f25940acc48, ptr_arg=0x0, len_arg=0, null_ptr_arg=0x5594e9b23233 "", null_bit_arg=0 '\000', unireg_check_arg=Field::NONE, field_name_arg=0x7f2594013e50, dec_arg=0 '\000', zero_arg=false, unsigned_arg=false) at /data/src/10.3/sql/field.cc:3137 #11 0x00005594e90f9f90 in Type_handler_newdecimal::make_table_field (this=0x5594ea348998 <type_handler_newdecimal>, name=0x7f2594013e50, addr=..., attr=..., table=0x7f25940390a8) at /data/src/10.3/sql/sql_type.cc:2206 #12 0x00005594e90f9645 in Type_handler::make_and_init_table_field (this=0x5594ea348998 <type_handler_newdecimal>, name=0x7f2594013e50, addr=..., attr=..., table=0x7f25940390a8) at /data/src/10.3/sql/sql_type.cc:2033 #13 0x00005594e8dde64d in Item::tmp_table_field_from_field_type (this=0x7f2594013e00, table=0x7f25940390a8) at /data/src/10.3/sql/item.h:707 #14 0x00005594e8ddfb4c in Item::create_tmp_field (this=0x7f2594013e00, group=false, table=0x7f25940390a8) at /data/src/10.3/sql/item.h:1948 #15 0x00005594e8f686f7 in create_tmp_field_from_item (thd=0x7f2594000d90, item=0x7f2594013e00, table=0x7f25940390a8, copy_func=0x7f25b0052f78, modify_item=true) at /data/src/10.3/sql/sql_select.cc:17117 #16 0x00005594e8f6907b in create_tmp_field (thd=0x7f2594000d90, table=0x7f25940390a8, item=0x7f2594013e00, type=Item::FUNC_ITEM, copy_func=0x7f25b0052f78, from_field=0x7f259403a1c0, default_field=0x7f259403a1a0, group=true, modify_item=true, table_cant_handle_bit_fields=false, make_copy_field=false) at /data/src/10.3/sql/sql_select.cc:17343 #17 0x00005594e8f6a5c3 in create_tmp_table (thd=0x7f2594000d90, param=0x7f2594016230, fields=..., group=0x7f25940134f8, distinct=false, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x5594ea20ef00 <empty_clex_str>, do_not_open=true, keep_row_order=false) at /data/src/10.3/sql/sql_select.cc:17723 #18 0x00005594e8f43b67 in JOIN::create_postjoin_aggr_table (this=0x7f2594014130, tab=0x7f2594015750, table_fields=0x7f2594014450, table_group=0x7f25940134f8, save_sum_fields=false, distinct=false, keep_row_order=false) at /data/src/10.3/sql/sql_select.cc:3432 #19 0x00005594e8f421b0 in JOIN::make_aggr_tables_info (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:3032 #20 0x00005594e8f40ba0 in JOIN::optimize_stage2 (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:2679 #21 0x00005594e8f3e5f0 in JOIN::optimize_inner (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:1985 #22 0x00005594e8f3c9c0 in JOIN::optimize (this=0x7f2594014130) at /data/src/10.3/sql/sql_select.cc:1501 #23 0x00005594e8f46b12 in mysql_select (thd=0x7f2594000d90, tables=0x7f2594012d70, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x7f2594013fe0, group=0x7f25940134f8, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f2594014108, unit=0x7f2594004c58, select_lex=0x7f25940053e0) at /data/src/10.3/sql/sql_select.cc:4309 #24 0x00005594e8f3813e in handle_select (thd=0x7f2594000d90, lex=0x7f2594004b98, result=0x7f2594014108, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:370 #25 0x00005594e8efe804 in execute_sqlcom_select (thd=0x7f2594000d90, all_tables=0x7f2594012d70) at /data/src/10.3/sql/sql_parse.cc:6316 #26 0x00005594e8ef5011 in mysql_execute_command (thd=0x7f2594000d90) at /data/src/10.3/sql/sql_parse.cc:3847 #27 0x00005594e8f02b88 in mysql_parse (thd=0x7f2594000d90, rawbuf=0x7f2594012ab8 "SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", length=115, parser_state=0x7f25b00545c0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7840 #28 0x00005594e8eef2ec in dispatch_command (command=COM_QUERY, thd=0x7f2594000d90, packet=0x7f2594008f11 "SELECT d FROM t1 GROUP BY d ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END", packet_length=115, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852 #29 0x00005594e8eedc8c in do_command (thd=0x7f2594000d90) at /data/src/10.3/sql/sql_parse.cc:1398 #30 0x00005594e906c295 in do_handle_one_connection (connect=0x5594ec48d070) at /data/src/10.3/sql/sql_connect.cc:1403 #31 0x00005594e906bff1 in handle_one_connection (arg=0x5594ec48d070) at /data/src/10.3/sql/sql_connect.cc:1308 #32 0x00005594e9a38027 in pfs_spawn_thread (arg=0x5594ec470440) at /data/src/10.3/storage/perfschema/pfs.cc:1869 #33 0x00007f25b53b2609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #34 0x00007f25b4f8e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Unlike the test case in the description, both ones above don't fail on 10.2, but fail on 10.3+, including 10.5 and 10.6.
            alice Alice Sherepa added a comment -

            Testcase from the description is not repeatable after

            commit cb4dcf39e7c2428922d68f7cb3472d633b82bfe0
            Author: Alexander Barkov <bar@mariadb.com>
            Date:   Fri Aug 16 22:49:56 2019 +0400
             
                MDEV-20363 Assertion `is_unsigned() == attr.unsigned_flag' failed in Type_handler_longlong::make_table_field
            

            The other 2 cases (from comments) are still reproducible on 10.5-11.8:

            Version: '11.8.0-MariaDB-debug-log' 
            mariadbd: /git/11.8/strings/decimal.c:1563: decimal_bin_size: Assertion `precision > 0' failed.
            250204 15:01:22 [ERROR] //11.8/sql/mariadbd got signal 6 ;
             
            Server version: 11.8.0-MariaDB-debug-log source revision: dfdbec163628271bc5a9b0e9ae33ed24a9fad937
             
            linux/raise.c:51(__GI_raise)[0x7f148821d8eb]
            stdlib/abort.c:81(__GI_abort)[0x7f1488208535]
            intl/loadmsgcat.c:1177(_nl_load_domain)[0x7f148820840f]
            /lib/x86_64-linux-gnu/libc.so.6(+0x301a2)[0x7f14882161a2]
            strings/decimal.c:1564(decimal_bin_size)[0x558e0e91720d]
            sql/my_decimal.h:347(my_decimal_get_binary_size(unsigned short, unsigned short))[0x558e0c9b10a3]
            sql/filesort.cc:2150(Type_handler_decimal_result::sort_length(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x558e0d18e2a3]
            sql/filesort.cc:2228(sortlength(THD*, Sort_keys*, bool*))[0x558e0d18ec92]
            sql/filesort.cc:309(filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long))[0x558e0d17f0be]
            sql/sql_select.cc:27725(create_sort_index(THD*, JOIN*, st_join_table*, Filesort*))[0x558e0c97f83b]
            sql/sql_select.cc:25217(st_join_table::sort_table())[0x558e0c96c2b5]
            sql/sql_select.cc:25137(join_init_read_record(st_join_table*))[0x558e0c96b6b9]
            sql/sql_select.cc:24132(sub_select(JOIN*, st_join_table*, bool))[0x558e0c963daf]
            sql/sql_select.cc:23646(do_select(JOIN*, Procedure*))[0x558e0c961162]
            sql/sql_select.cc:5046(JOIN::exec_inner())[0x558e0c8d8a6b]
            sql/sql_select.cc:4829(JOIN::exec())[0x558e0c8d5e40]
            sql/sql_select.cc:5362(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x558e0c8da4f9]
            sql/sql_select.cc:633(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x558e0c8a852f]
            sql/sql_parse.cc:6191(execute_sqlcom_select(THD*, TABLE_LIST*))[0x558e0c7bee6c]
            sql/sql_parse.cc:3980(mysql_execute_command(THD*, bool))[0x558e0c7aec3c]
            sql/sql_parse.cc:7915(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x558e0c7ca4e7]
            sql/sql_parse.cc:1905(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x558e0c7a08d8]
            sql/sql_parse.cc:1416(do_command(THD*, bool))[0x558e0c79d3ea]
            sql/sql_connect.cc:1415(do_handle_one_connection(CONNECT*, bool))[0x558e0ccd06cc]
            sql/sql_connect.cc:1329(handle_one_connection)[0x558e0ccd021d]
            perfschema/pfs.cc:2200(pfs_spawn_thread)[0x558e0dab9aa6]
            nptl/pthread_create.c:487(start_thread)[0x7f14886d5fa3]
            x86_64/clone.S:97(clone)[0x7f14882df06f]
             
            Connection ID (thread ID): 4
            Status: NOT_KILLED
            Query (0x62d0003484a8): SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END
            

            alice Alice Sherepa added a comment - Testcase from the description is not repeatable after commit cb4dcf39e7c2428922d68f7cb3472d633b82bfe0 Author: Alexander Barkov <bar@mariadb.com> Date: Fri Aug 16 22:49:56 2019 +0400   MDEV-20363 Assertion `is_unsigned() == attr.unsigned_flag' failed in Type_handler_longlong::make_table_field The other 2 cases (from comments) are still reproducible on 10.5-11.8: Version: '11.8.0-MariaDB-debug-log' mariadbd: /git/11.8/strings/decimal.c:1563: decimal_bin_size: Assertion `precision > 0' failed. 250204 15:01:22 [ERROR] //11.8/sql/mariadbd got signal 6 ;   Server version: 11.8.0-MariaDB-debug-log source revision: dfdbec163628271bc5a9b0e9ae33ed24a9fad937   linux/raise.c:51(__GI_raise)[0x7f148821d8eb] stdlib/abort.c:81(__GI_abort)[0x7f1488208535] intl/loadmsgcat.c:1177(_nl_load_domain)[0x7f148820840f] /lib/x86_64-linux-gnu/libc.so.6(+0x301a2)[0x7f14882161a2] strings/decimal.c:1564(decimal_bin_size)[0x558e0e91720d] sql/my_decimal.h:347(my_decimal_get_binary_size(unsigned short, unsigned short))[0x558e0c9b10a3] sql/filesort.cc:2150(Type_handler_decimal_result::sort_length(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x558e0d18e2a3] sql/filesort.cc:2228(sortlength(THD*, Sort_keys*, bool*))[0x558e0d18ec92] sql/filesort.cc:309(filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long))[0x558e0d17f0be] sql/sql_select.cc:27725(create_sort_index(THD*, JOIN*, st_join_table*, Filesort*))[0x558e0c97f83b] sql/sql_select.cc:25217(st_join_table::sort_table())[0x558e0c96c2b5] sql/sql_select.cc:25137(join_init_read_record(st_join_table*))[0x558e0c96b6b9] sql/sql_select.cc:24132(sub_select(JOIN*, st_join_table*, bool))[0x558e0c963daf] sql/sql_select.cc:23646(do_select(JOIN*, Procedure*))[0x558e0c961162] sql/sql_select.cc:5046(JOIN::exec_inner())[0x558e0c8d8a6b] sql/sql_select.cc:4829(JOIN::exec())[0x558e0c8d5e40] sql/sql_select.cc:5362(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x558e0c8da4f9] sql/sql_select.cc:633(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x558e0c8a852f] sql/sql_parse.cc:6191(execute_sqlcom_select(THD*, TABLE_LIST*))[0x558e0c7bee6c] sql/sql_parse.cc:3980(mysql_execute_command(THD*, bool))[0x558e0c7aec3c] sql/sql_parse.cc:7915(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x558e0c7ca4e7] sql/sql_parse.cc:1905(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x558e0c7a08d8] sql/sql_parse.cc:1416(do_command(THD*, bool))[0x558e0c79d3ea] sql/sql_connect.cc:1415(do_handle_one_connection(CONNECT*, bool))[0x558e0ccd06cc] sql/sql_connect.cc:1329(handle_one_connection)[0x558e0ccd021d] perfschema/pfs.cc:2200(pfs_spawn_thread)[0x558e0dab9aa6] nptl/pthread_create.c:487(start_thread)[0x7f14886d5fa3] x86_64/clone.S:97(clone)[0x7f14882df06f]   Connection ID (thread ID): 4 Status: NOT_KILLED Query (0x62d0003484a8): SELECT * FROM t1 ORDER BY CASE 1 WHEN 1 THEN (IS_FREE_LOCK('x') DIV (1 << 2)) WHEN 2 THEN WEEKDAY(d) END

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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