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

Assertion `precision > 0' failed in decimal_bin_size

    XMLWordPrintable

    Details

    • Sprint:
      10.1.21

      Description

      SELECT * FROM ( SELECT IFNULL(CONVERT(NULL, UNSIGNED), NULL) ) sq;
      

      Stack trace from 10.1 ed4a6f12b3

      mysqld: /data/src/10.1/strings/decimal.c:1458: decimal_bin_size: Assertion `precision > 0' failed.
      161011 15:06:49 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f7631c4b312 in __GI___assert_fail (assertion=0x7f763509f2c5 "precision > 0", file=0x7f763509f040 "/data/src/10.1/strings/decimal.c", line=1458, function=0x7f763509f530 <__PRETTY_FUNCTION__.11134> "decimal_bin_size") at assert.c:101
      #8  0x00007f7634d30743 in decimal_bin_size (precision=0, scale=0) at /data/src/10.1/strings/decimal.c:1458
      #9  0x00007f76344d18e8 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.1/sql/my_decimal.h:263
      #10 0x00007f76346600a2 in Field_new_decimal::Field_new_decimal (this=0x7f762afd3688, len_arg=0, maybe_null_arg=true, name=0x7f7629044678 "IFNULL(CONVERT(NULL, UNSIGNED), NULL)", dec_arg=0 '\000', unsigned_arg=false) at /data/src/10.1/sql/field.cc:2936
      #11 0x00007f76346601eb in Field_new_decimal::create_from_item (mem_root=0x7f76291d4b10, item=0x7f7629044598) at /data/src/10.1/sql/field.cc:2981
      #12 0x00007f76344b6ebd in Item::create_tmp_field (this=0x7f7629044598, group=false, table=0x7f76291d4088, convert_int_length=9) at /data/src/10.1/sql/sql_select.cc:15883
      #13 0x00007f76343a07c9 in Item::create_tmp_field (this=0x7f7629044598, group=false, table=0x7f76291d4088) at /data/src/10.1/sql/item.h:1639
      #14 0x00007f76344b6f69 in create_tmp_field_from_item (thd=0x7f762affa070, item=0x7f7629044598, table=0x7f76291d4088, copy_func=0x7f7635363d48, modify_item=false) at /data/src/10.1/sql/sql_select.cc:15925
      #15 0x00007f76344b7665 in create_tmp_field (thd=0x7f762affa070, table=0x7f76291d4088, item=0x7f7629044598, type=Item::FUNC_ITEM, copy_func=0x7f7635363d48, from_field=0x7f76291d5120, default_field=0x7f76291d5110, group=false, modify_item=false, table_cant_handle_bit_fields=false, make_copy_field=false) at /data/src/10.1/sql/sql_select.cc:16142
      #16 0x00007f76344b8a3e in create_tmp_table (thd=0x7f762affa070, param=0x7f76290459e8, fields=..., group=0x0, distinct=false, save_sum_fields=true, select_options=2416188160, rows_limit=18446744073709551615, table_alias=0x7f7629044d50 "sq", do_not_open=true, keep_row_order=false) at /data/src/10.1/sql/sql_select.cc:16516
      #17 0x00007f7634529463 in select_union::create_result_table (this=0x7f76290459c8, thd_arg=0x7f762affa070, column_types=0x7f76290442d0, is_union_distinct=false, options=2416188160, alias=0x7f7629044d50 "sq", bit_fields_as_long=false, create_table=false, keep_row_order=false) at /data/src/10.1/sql/sql_union.cc:159
      #18 0x00007f76344293ba in mysql_derived_prepare (thd=0x7f762affa070, lex=0x7f762affd9f0, derived=0x7f7629044d90) at /data/src/10.1/sql/sql_derived.cc:696
      #19 0x00007f7634428669 in mysql_handle_single_derived (lex=0x7f762affd9f0, derived=0x7f7629044d90, phases=2) at /data/src/10.1/sql/sql_derived.cc:195
      #20 0x00007f763454de20 in TABLE_LIST::handle_derived (this=0x7f7629044d90, lex=0x7f762affd9f0, phases=2) at /data/src/10.1/sql/table.cc:7128
      #21 0x00007f763444685e in st_select_lex::handle_derived (this=0x7f762affe1b8, lex=0x7f762affd9f0, phases=2) at /data/src/10.1/sql/sql_lex.cc:3823
      #22 0x00007f763448e7a3 in JOIN::prepare (this=0x7f7629045450, rref_pointer_array=0x7f762affe430, tables_init=0x7f7629044d90, wild_num=1, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f762affe1b8, unit_arg=0x7f762affdab8) at /data/src/10.1/sql/sql_select.cc:711
      #23 0x00007f7634498283 in mysql_select (thd=0x7f762affa070, rref_pointer_array=0x7f762affe430, tables=0x7f7629044d90, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f7629045430, unit=0x7f762affdab8, select_lex=0x7f762affe1b8) at /data/src/10.1/sql/sql_select.cc:3416
      #24 0x00007f763448de2a in handle_select (thd=0x7f762affa070, lex=0x7f762affd9f0, result=0x7f7629045430, setup_tables_done_option=0) at /data/src/10.1/sql/sql_select.cc:384
      #25 0x00007f763445e027 in execute_sqlcom_select (thd=0x7f762affa070, all_tables=0x7f7629044d90) at /data/src/10.1/sql/sql_parse.cc:5895
      #26 0x00007f7634453f34 in mysql_execute_command (thd=0x7f762affa070) at /data/src/10.1/sql/sql_parse.cc:2961
      #27 0x00007f7634461780 in mysql_parse (thd=0x7f762affa070, rawbuf=0x7f7629043088 "SELECT * FROM ( SELECT IFNULL(CONVERT(NULL, UNSIGNED), NULL) ) sq", length=65, parser_state=0x7f76353655e0) at /data/src/10.1/sql/sql_parse.cc:7318
      #28 0x00007f7634450189 in dispatch_command (command=COM_QUERY, thd=0x7f762affa070, packet=0x7f762c93e071 "SELECT * FROM ( SELECT IFNULL(CONVERT(NULL, UNSIGNED), NULL) ) sq", packet_length=65) at /data/src/10.1/sql/sql_parse.cc:1487
      #29 0x00007f763444eec0 in do_command (thd=0x7f762affa070) at /data/src/10.1/sql/sql_parse.cc:1108
      #30 0x00007f7634584d9b in do_handle_one_connection (thd_arg=0x7f762affa070) at /data/src/10.1/sql/sql_connect.cc:1350
      #31 0x00007f7634584aff in handle_one_connection (arg=0x7f762affa070) at /data/src/10.1/sql/sql_connect.cc:1262
      #32 0x00007f76348677f8 in pfs_spawn_thread (arg=0x7f7631427ef0) at /data/src/10.1/storage/perfschema/pfs.cc:1860
      #33 0x00007f7633b4d0a4 in start_thread (arg=0x7f7635366b00) at pthread_create.c:309
      #34 0x00007f7631d0587d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
      

      A similar crash happens on these queries:

      CREATE TABLE t1 AS SELECT IFNULL(CONVERT(NULL, UNSIGNED), NULL);
      CREATE TABLE t1 AS SELECT COALESCE(CONVERT(NULL, UNSIGNED), NULL);
      CREATE TABLE t1 AS SELECT CASE WHEN TRUE THEN CONVERT(NULL, UNSIGNED) ELSE NULL END;
      

      And on this query:

      CREATE TABLE t1 AS SELECT IFNULL(CONVERT(NULL,SIGNED),CONVERT(NULL,UNSIGNED)) AS a;
      

      A related problem:

      CREATE OR REPLACE TABLE t1 AS SELECT CONVERT(NULL,SIGNED) AS a;
      SHOW FIELDS IN t1;
      

      +-------+--------+------+-----+---------+-------+
      | Field | Type   | Null | Key | Default | Extra |
      +-------+--------+------+-----+---------+-------+
      | a     | int(0) | YES  |     | NULL    |       |
      +-------+--------+------+-----+---------+-------+
      

      int(0) is not an expected data type. It should be int(1).

      A related problem:

      CREATE OR REPLACE TABLE t1 AS SELECT CONCAT(CONVERT(NULL,SIGNED)) AS a;
      SHOW FIELDS IN t1;
      

      +-------+---------+------+-----+---------+-------+
      | Field | Type    | Null | Key | Default | Extra |
      +-------+---------+------+-----+---------+-------+
      | a     | char(0) | YES  |     | NULL    |       |
      +-------+---------+------+-----+---------+-------+
      

      char(0) is not an expected data type. It should be char(1).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: