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

MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0.

Details

    Description

      MDB crashes trying to execute CTAS with decimal column which precision is 0.

      MariaDB [test]> create table t42(d decimal(5,5));
      Query OK, 0 rows affected (0.015 sec)
       
      MariaDB [test]> insert into t42 values (0.55555);
      Query OK, 1 row affected (0.004 sec)
       
      MariaDB [test]> select * from t42;
      +---------+
      | d       |
      +---------+
      | 0.55555 |
      +---------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> select truncate(d,0) from t42;
      +---------------+
      | truncate(d,0) |
      +---------------+
      |             0 |
      +---------------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> create table t43 as select truncate(d,0) from t42;
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova added a comment - - edited

            mariadbd: /data/src/10.5/strings/decimal.c:1466: decimal_bin_size: Assertion `precision > 0' failed.
            200508 13:48:53 [ERROR] mysqld got signal 6 ;
             
            #7  0x00007fec1ac8ef12 in __GI___assert_fail (assertion=0x55a7e71ae485 "precision > 0", file=0x55a7e71ae200 "/data/src/10.5/strings/decimal.c", line=1466, function=0x55a7e71ae700 <__PRETTY_FUNCTION__.12119> "decimal_bin_size") at assert.c:101
            #8  0x000055a7e6b40df9 in decimal_bin_size (precision=0, scale=0) at /data/src/10.5/strings/decimal.c:1466
            #9  0x000055a7e5ecf98d in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.5/sql/my_decimal.h:324
            #10 0x000055a7e6154b51 in Field_new_decimal::Field_new_decimal (this=0x7fec04016170, ptr_arg=0x0, len_arg=0, null_ptr_arg=0x55a7e6baed3e "", null_bit_arg=1 '\001', unireg_check_arg=Field::NONE, field_name_arg=0x7fec04014800, dec_arg=0 '\000', zero_arg=false, unsigned_arg=false) at /data/src/10.5/sql/field.cc:3248
            #11 0x000055a7e6072adb in Type_handler_newdecimal::make_table_field (this=0x55a7e79d2bc0 <type_handler_newdecimal>, root=0x7fec040065d8, name=0x7fec04014800, addr=..., attr=..., share=0x7fec1582afd0) at /data/src/10.5/sql/sql_type.cc:3528
            #12 0x000055a7e60725ab in Type_handler::make_and_init_table_field (this=0x55a7e79d2bc0 <type_handler_newdecimal>, root=0x7fec040065d8, name=0x7fec04014800, addr=..., attr=..., table=0x7fec1582a210) at /data/src/10.5/sql/sql_type.cc:3415
            #13 0x000055a7e5d0d786 in Item::tmp_table_field_from_field_type (this=0x7fec040147a8, root=0x7fec040065d8, table=0x7fec1582a210) at /data/src/10.5/sql/item.h:817
            #14 0x000055a7e5da3523 in Item_func::create_field_for_create_select (this=0x7fec040147a8, root=0x7fec040065d8, table=0x7fec1582a210) at /data/src/10.5/sql/item_func.h:192
            #15 0x000055a7e5df206d in select_create::create_table_from_items (this=0x7fec04015a00, thd=0x7fec04000b18, items=0x7fec1582b5c0, lock=0x7fec1582b5b0, hooks=0x7fec1582b600) at /data/src/10.5/sql/sql_insert.cc:4387
            #16 0x000055a7e5df2bf3 in select_create::prepare (this=0x7fec04015a00, _values=..., u=0x7fec04004b28) at /data/src/10.5/sql/sql_insert.cc:4653
            #17 0x000055a7e5e7f6e0 in JOIN::prepare (this=0x7fec04015b00, tables_init=0x7fec040148f0, 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=0x7fec04014150, unit_arg=0x7fec04004b28) at /data/src/10.5/sql/sql_select.cc:1485
            #18 0x000055a7e5e8b194 in mysql_select (thd=0x7fec04000b18, tables=0x7fec040148f0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201171004160, result=0x7fec04015a00, unit=0x7fec04004b28, select_lex=0x7fec04014150) at /data/src/10.5/sql/sql_select.cc:4633
            #19 0x000055a7e5e7ae4e in handle_select (thd=0x7fec04000b18, lex=0x7fec04004a60, result=0x7fec04015a00, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:429
            #20 0x000055a7e5f3d7ef in Sql_cmd_create_table_like::execute (this=0x7fec04013a18, thd=0x7fec04000b18) at /data/src/10.5/sql/sql_table.cc:11835
            #21 0x000055a7e5e3ef56 in mysql_execute_command (thd=0x7fec04000b18) at /data/src/10.5/sql/sql_parse.cc:5912
            #22 0x000055a7e5e452da in mysql_parse (thd=0x7fec04000b18, rawbuf=0x7fec04013950 "create table t43 as select truncate(d,0) from t42", length=49, parser_state=0x7fec1582c520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7957
            #23 0x000055a7e5e315e2 in dispatch_command (command=COM_QUERY, thd=0x7fec04000b18, packet=0x7fec041b0349 "create table t43 as select truncate(d,0) from t42", packet_length=49, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1840
            #24 0x000055a7e5e2fd74 in do_command (thd=0x7fec04000b18) at /data/src/10.5/sql/sql_parse.cc:1359
            #25 0x000055a7e5fd33aa in do_handle_one_connection (connect=0x55a7e9ce4818, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1422
            #26 0x000055a7e5fd30d9 in handle_one_connection (arg=0x55a7e9cd42a8) at /data/src/10.5/sql/sql_connect.cc:1319
            #27 0x000055a7e650897a in pfs_spawn_thread (arg=0x55a7e9c6e0f8) at /data/src/10.5/storage/perfschema/pfs.cc:2201
            #28 0x00007fec1cc174a4 in start_thread (arg=0x7fec1582d700) at pthread_create.c:456
            #29 0x00007fec1ad4bd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
            

            Which makes it another one of ~ half a dozen precision > 0 bugs currently open in JIRA.

            elenst Elena Stepanova added a comment - - edited mariadbd: /data/src/10.5/strings/decimal.c:1466: decimal_bin_size: Assertion `precision > 0' failed. 200508 13:48:53 [ERROR] mysqld got signal 6 ;   #7 0x00007fec1ac8ef12 in __GI___assert_fail (assertion=0x55a7e71ae485 "precision > 0", file=0x55a7e71ae200 "/data/src/10.5/strings/decimal.c", line=1466, function=0x55a7e71ae700 <__PRETTY_FUNCTION__.12119> "decimal_bin_size") at assert.c:101 #8 0x000055a7e6b40df9 in decimal_bin_size (precision=0, scale=0) at /data/src/10.5/strings/decimal.c:1466 #9 0x000055a7e5ecf98d in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.5/sql/my_decimal.h:324 #10 0x000055a7e6154b51 in Field_new_decimal::Field_new_decimal (this=0x7fec04016170, ptr_arg=0x0, len_arg=0, null_ptr_arg=0x55a7e6baed3e "", null_bit_arg=1 '\001', unireg_check_arg=Field::NONE, field_name_arg=0x7fec04014800, dec_arg=0 '\000', zero_arg=false, unsigned_arg=false) at /data/src/10.5/sql/field.cc:3248 #11 0x000055a7e6072adb in Type_handler_newdecimal::make_table_field (this=0x55a7e79d2bc0 <type_handler_newdecimal>, root=0x7fec040065d8, name=0x7fec04014800, addr=..., attr=..., share=0x7fec1582afd0) at /data/src/10.5/sql/sql_type.cc:3528 #12 0x000055a7e60725ab in Type_handler::make_and_init_table_field (this=0x55a7e79d2bc0 <type_handler_newdecimal>, root=0x7fec040065d8, name=0x7fec04014800, addr=..., attr=..., table=0x7fec1582a210) at /data/src/10.5/sql/sql_type.cc:3415 #13 0x000055a7e5d0d786 in Item::tmp_table_field_from_field_type (this=0x7fec040147a8, root=0x7fec040065d8, table=0x7fec1582a210) at /data/src/10.5/sql/item.h:817 #14 0x000055a7e5da3523 in Item_func::create_field_for_create_select (this=0x7fec040147a8, root=0x7fec040065d8, table=0x7fec1582a210) at /data/src/10.5/sql/item_func.h:192 #15 0x000055a7e5df206d in select_create::create_table_from_items (this=0x7fec04015a00, thd=0x7fec04000b18, items=0x7fec1582b5c0, lock=0x7fec1582b5b0, hooks=0x7fec1582b600) at /data/src/10.5/sql/sql_insert.cc:4387 #16 0x000055a7e5df2bf3 in select_create::prepare (this=0x7fec04015a00, _values=..., u=0x7fec04004b28) at /data/src/10.5/sql/sql_insert.cc:4653 #17 0x000055a7e5e7f6e0 in JOIN::prepare (this=0x7fec04015b00, tables_init=0x7fec040148f0, 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=0x7fec04014150, unit_arg=0x7fec04004b28) at /data/src/10.5/sql/sql_select.cc:1485 #18 0x000055a7e5e8b194 in mysql_select (thd=0x7fec04000b18, tables=0x7fec040148f0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201171004160, result=0x7fec04015a00, unit=0x7fec04004b28, select_lex=0x7fec04014150) at /data/src/10.5/sql/sql_select.cc:4633 #19 0x000055a7e5e7ae4e in handle_select (thd=0x7fec04000b18, lex=0x7fec04004a60, result=0x7fec04015a00, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:429 #20 0x000055a7e5f3d7ef in Sql_cmd_create_table_like::execute (this=0x7fec04013a18, thd=0x7fec04000b18) at /data/src/10.5/sql/sql_table.cc:11835 #21 0x000055a7e5e3ef56 in mysql_execute_command (thd=0x7fec04000b18) at /data/src/10.5/sql/sql_parse.cc:5912 #22 0x000055a7e5e452da in mysql_parse (thd=0x7fec04000b18, rawbuf=0x7fec04013950 "create table t43 as select truncate(d,0) from t42", length=49, parser_state=0x7fec1582c520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7957 #23 0x000055a7e5e315e2 in dispatch_command (command=COM_QUERY, thd=0x7fec04000b18, packet=0x7fec041b0349 "create table t43 as select truncate(d,0) from t42", packet_length=49, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1840 #24 0x000055a7e5e2fd74 in do_command (thd=0x7fec04000b18) at /data/src/10.5/sql/sql_parse.cc:1359 #25 0x000055a7e5fd33aa in do_handle_one_connection (connect=0x55a7e9ce4818, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1422 #26 0x000055a7e5fd30d9 in handle_one_connection (arg=0x55a7e9cd42a8) at /data/src/10.5/sql/sql_connect.cc:1319 #27 0x000055a7e650897a in pfs_spawn_thread (arg=0x55a7e9c6e0f8) at /data/src/10.5/storage/perfschema/pfs.cc:2201 #28 0x00007fec1cc174a4 in start_thread (arg=0x7fec1582d700) at pthread_create.c:456 #29 0x00007fec1ad4bd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 Which makes it another one of ~ half a dozen precision > 0 bugs currently open in JIRA.
            bar Alexander Barkov added a comment - - edited

            This script reproduces the problem in all versions between 10.0 and 10.5:

            CREATE OR REPLACE TABLE t1(d decimal(5,5));
            INSERT INTO t1 VALUES (0.55555);
            SELECT TRUNCATE(d,0) FROM t1;
            CREATE OR REPLACE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
            

            bar Alexander Barkov added a comment - - edited This script reproduces the problem in all versions between 10.0 and 10.5: CREATE OR REPLACE TABLE t1(d decimal (5,5)); INSERT INTO t1 VALUES (0.55555); SELECT TRUNCATE (d,0) FROM t1; CREATE OR REPLACE TABLE t2 AS SELECT TRUNCATE (d,0) FROM t1;

            People

              bar Alexander Barkov
              drrtuy Roman
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.