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

Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size

Details

    Description

      10.6.0 1bd4115841ecded24217e5d753ed4d9822b4cffd (Debug)

      mysqld: /test/10.6_dbg/strings/decimal.c:1540: decimal_bin_size: Assertion `scale <= precision' failed.
      

      10.6.0 1bd4115841ecded24217e5d753ed4d9822b4cffd (Debug)

      Core was generated by `/test/MD010421-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
      [Current thread is 1 (Thread 0x14e0f0930700 (LWP 3455778))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
      #1  0x0000560cac9ededb in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
      #2  0x0000560cac18ca65 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:343
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #5  0x000014e0f9d95859 in __GI_abort () at abort.c:79
      #6  0x000014e0f9d95729 in __assert_fail_base (fmt=0x14e0f9f2b588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x560cad0c5400 "scale <= precision", file=0x560cad0c5100 "/test/10.6_dbg/strings/decimal.c", line=1540, function=<optimized out>) at assert.c:92
      #7  0x000014e0f9da6f36 in __GI___assert_fail (assertion=assertion@entry=0x560cad0c5400 "scale <= precision", file=file@entry=0x560cad0c5100 "/test/10.6_dbg/strings/decimal.c", line=line@entry=1540, function=function@entry=0x560cad0c5560 <__PRETTY_FUNCTION__.16163> "decimal_bin_size") at assert.c:101
      #8  0x0000560caca3adaf in decimal_bin_size (precision=precision@entry=65, scale=<optimized out>) at /test/10.6_dbg/strings/decimal.c:1540
      #9  0x0000560cac2b9ea0 in my_decimal_get_binary_size (scale=<optimized out>, precision=65) at /test/10.6_dbg/sql/my_decimal.h:334
      #10 Item_sum_avg::fix_length_and_dec_decimal (this=0x14e09c014e30) at /test/10.6_dbg/sql/item_sum.cc:1961
      #11 0x0000560cac0a3e40 in Type_handler_decimal_result::Item_sum_avg_fix_length_and_dec (this=<optimized out>, item=<optimized out>) at /test/10.6_dbg/sql/sql_type.cc:4916
      #12 0x0000560cac2b0672 in Item_sum_avg::fix_length_and_dec (this=0x14e09c014e30) at /test/10.6_dbg/sql/item.h:1099
      #13 0x0000560cac2b717a in Item_sum_num::fix_fields (this=0x14e09c014e30, thd=0x14e09c000db8, ref=0x14e09c015080) at /test/10.6_dbg/sql/item_sum.cc:1132
      #14 0x0000560cabe3f3f8 in Item::fix_fields_if_needed (ref=0x14e09c015080, thd=0x14e09c000db8, this=0x14e09c014e30) at /test/10.6_dbg/sql/sql_list.h:199
      #15 Item::fix_fields_if_needed_for_scalar (ref=0x14e09c015080, thd=0x14e09c000db8, this=0x14e09c014e30) at /test/10.6_dbg/sql/item.h:992
      #16 setup_fields (thd=0x14e09c000db8, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x14e09c015d98, pre_fix=0x14e09c014600, allow_sum_func=true) at /test/10.6_dbg/sql/sql_base.cc:7657
      #17 0x0000560cabf32a2f in JOIN::prepare (this=this@entry=0x14e09c015a70, tables_init=tables_init@entry=0x0, conds_init=conds_init@entry=0x0, og_num=og_num@entry=0, order_init=order_init@entry=0x0, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14e09c014498, unit_arg=0x14e09c004f90) at /test/10.6_dbg/sql/sql_select.cc:1245
      #18 0x0000560cabf4bbcb in mysql_select (thd=thd@entry=0x14e09c000db8, tables=0x0, fields=@0x14e09c0145e8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14e09c015078, last = 0x14e09c015078, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14e09c015a48, unit=0x14e09c004f90, select_lex=0x14e09c014498) at /test/10.6_dbg/sql/sql_select.cc:4725
      #19 0x0000560cabf4bf03 in handle_select (thd=thd@entry=0x14e09c000db8, lex=lex@entry=0x14e09c004ec8, result=result@entry=0x14e09c015a48, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:419
      #20 0x0000560cabebf758 in execute_sqlcom_select (thd=thd@entry=0x14e09c000db8, all_tables=0x0) at /test/10.6_dbg/sql/sql_parse.cc:6231
      #21 0x0000560cabecc3e3 in mysql_execute_command (thd=thd@entry=0x14e09c000db8) at /test/10.6_dbg/sql/sql_parse.cc:3927
      #22 0x0000560cabeb88d0 in mysql_parse (thd=thd@entry=0x14e09c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14e0f092f410) at /test/10.6_dbg/sql/sql_parse.cc:8004
      #23 0x0000560cabec74d6 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14e09c000db8, packet=packet@entry=0x14e09c00b359 "SELECT AVG(DISTINCT 0.", '0' <repeats 178 times>..., packet_length=packet_length@entry=1099, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1331
      #24 0x0000560cabeca8b1 in do_command (thd=0x14e09c000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1399
      #25 0x0000560cac023b42 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x560caec9a538, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
      #26 0x0000560cac024147 in handle_one_connection (arg=arg@entry=0x560caec9a538) at /test/10.6_dbg/sql/sql_connect.cc:1312
      #27 0x0000560cac4d0bef in pfs_spawn_thread (arg=0x560caebcbeb8) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
      #28 0x000014e0fa2a3609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #29 0x000014e0f9e92293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      10.6.0 1bd4115841ecded24217e5d753ed4d9822b4cffd (Optimized)

      Core was generated by `/test/MD010421-mariadb-10.6.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00005575fdbfe429 in bin2decimal (from=0x1495c4fdc040 "\200", 
          to=to@entry=0x14965c8e1130, precision=<optimized out>, 
          scale=<optimized out>) at /test/10.6_opt/strings/decimal.c:1412
      [Current thread is 1 (Thread 0x14965c8e3700 (LWP 682880))]
      (gdb) bt
      #0  0x00005575fdbfe429 in bin2decimal (from=0x1495c4fdc040 "\200", to=to@entry=0x14965c8e1130, precision=<optimized out>, scale=<optimized out>) at /test/10.6_opt/strings/decimal.c:1412
      #1  0x00005575fd6178b7 in binary2my_decimal (scale=<optimized out>, prec=<optimized out>, d=0x14965c8e1130, bin=<optimized out>, mask=30) at /test/10.6_opt/sql/my_decimal.h:349
      #2  Field_new_decimal::val_decimal (this=<optimized out>, decimal_value=0x14965c8e1130) at /test/10.6_opt/sql/field.cc:3561
      #3  0x00005575fd7099c4 in Item_sum_sum::add_helper (this=this@entry=0x149600011738, perform_removal=perform_removal@entry=false) at /test/10.6_opt/sql/item_sum.cc:1629
      #4  0x00005575fd709c7f in Item_sum_sum::add (this=this@entry=0x149600011738) at /test/10.6_opt/sql/item_sum.cc:1601
      #5  0x00005575fd709ca3 in Item_sum_avg::add (this=0x149600011738) at /test/10.6_opt/sql/item_sum.cc:2025
      #6  0x00005575fd709d67 in Aggregator_distinct::unique_walk_function (this=0x149600012b30, element=<optimized out>) at /test/10.6_opt/sql/item_sum.cc:1763
      #7  0x00005575fd709d83 in item_sum_distinct_walk (element=<optimized out>, num_of_dups=<optimized out>, item=<optimized out>) at /test/10.6_opt/sql/item_sum.cc:728
      #8  0x00005575fdbb0b9a in tree_walk_left_root_right (argument=0x149600012b30, action=0x5575fd709d70 <item_sum_distinct_walk(void*, element_count, void*)>, element=<optimized out>, tree=0x149600013610) at /test/10.6_opt/mysys/tree.c:588
      #9  tree_walk (tree=tree@entry=0x149600013610, action=action@entry=0x5575fd709d70 <item_sum_distinct_walk(void*, element_count, void*)>, argument=argument@entry=0x149600012b30, visit=visit@entry=left_root_right) at /test/10.6_opt/mysys/tree.c:576
      #10 0x00005575fd50a7e1 in Unique::walk (this=0x1496000134e8, table=<optimized out>, action=0x5575fd709d70 <item_sum_distinct_walk(void*, element_count, void*)>, walk_action_arg=walk_action_arg@entry=0x149600012b30) at /test/10.6_opt/sql/uniques.cc:654
      #11 0x00005575fd704093 in Aggregator_distinct::endup (this=0x149600012b30) at /test/10.6_opt/sql/item_sum.cc:1089
      #12 Aggregator_distinct::endup (this=0x149600012b30) at /test/10.6_opt/sql/item_sum.cc:1037
      #13 0x00005575fd704e68 in Item_sum_avg::val_str (this=0x149600011738, str=0x14965c8e14f0) at /test/10.6_opt/sql/item_sum.cc:2086
      #14 0x00005575fd595e48 in Type_handler::Item_send_str (this=<optimized out>, item=<optimized out>, protocol=0x1496000011b8, buf=<optimized out>) at /test/10.6_opt/sql/sql_type.cc:7359
      #15 0x00005575fd365e34 in Protocol::send_result_set_row (this=this@entry=0x1496000011b8, row_items=row_items@entry=0x149600012718) at /test/10.6_opt/sql/protocol.cc:1331
      #16 0x00005575fd3d5027 in select_send::send_data (this=0x149600012338, items=@0x149600012718: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149600012b20, last = 0x149600012b20, elements = 1}, <No data fields>}) at /test/10.6_opt/sql/sql_class.cc:3020
      #17 0x00005575fd47f56c in select_result_sink::send_data_with_check (u=<optimized out>, sent=<optimized out>, items=@0x149600012718: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149600012b20, last = 0x149600012b20, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.6_opt/sql/sql_class.h:5567
      #18 select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x149600012718: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149600012b20, last = 0x149600012b20, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.6_opt/sql/sql_class.h:5557
      #19 end_send_group (join=0x149600012360, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:22125
      #20 0x00005575fd48f1ad in do_select (procedure=<optimized out>, join=0x149600012360) at /test/10.6_opt/sql/sql_select.cc:20263
      #21 JOIN::exec_inner (this=0x149600012360) at /test/10.6_opt/sql/sql_select.cc:4493
      #22 0x00005575fd48f378 in JOIN::exec (this=this@entry=0x149600012360) at /test/10.6_opt/sql/sql_select.cc:4273
      #23 0x00005575fd48d2c8 in mysql_select (thd=0x149600000c58, tables=0x0, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x149600012338, unit=0x149600004c70, select_lex=0x149600010da8) at /test/10.6_opt/sql/sql_select.cc:4749
      #24 0x00005575fd48dcd7 in handle_select (thd=thd@entry=0x149600000c58, lex=lex@entry=0x149600004ba8, result=result@entry=0x149600012338, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_opt/sql/sql_select.cc:419
      #25 0x00005575fd41e5c1 in execute_sqlcom_select (thd=0x149600000c58, all_tables=0x0) at /test/10.6_opt/sql/sql_parse.cc:6231
      #26 0x00005575fd42c069 in mysql_execute_command (thd=0x149600000c58) at /test/10.6_opt/sql/sql_parse.cc:3927
      #27 0x00005575fd419424 in mysql_parse (thd=0x149600000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.6_opt/sql/sql_parse.cc:8004
      #28 0x00005575fd425345 in dispatch_command (command=COM_QUERY, thd=0x149600000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1331
      #29 0x00005575fd427390 in do_command (thd=0x149600000c58, blocking=blocking@entry=true) at /test/10.6_opt/sql/sql_parse.cc:1399
      #30 0x00005575fd529317 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.6_opt/sql/sql_connect.cc:1410
      #31 0x00005575fd52967d in handle_one_connection (arg=arg@entry=0x5575ff5454b8) at /test/10.6_opt/sql/sql_connect.cc:1312
      #32 0x00005575fd8a9a49 in pfs_spawn_thread (arg=0x5575ff4c12b8) at /test/10.6_opt/storage/perfschema/pfs.cc:2201
      #33 0x000014966621c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #34 0x0000149665e0b293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      With thanks ramesh for co-testing.

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar added a comment - - edited

            Also produces various other stacks. UniqueID's seen thus far (across PS and MS):

            SIGSEGV|binary2my_decimal|Field_new_decimal::val_decimal|Item_sum_sum::add_helper|Item_sum_sum::add
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec|Item_sum_num::fix_fields
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec_decimal|Type_handler_decimal_result::Item_sum_avg_fix_length_and_dec
            scale >= 0 && precision > 0 && scale <= precision|SIGABRT|decimal_bin_size_inline|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::resolve_type
            scale >= 0 && precision > 0 && scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec|Item_sum_num::fix_fields
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sort_length|sortlength
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|Item::sortlength
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|sortlength
            

            Roel Roel Van de Paar added a comment - - edited Also produces various other stacks. UniqueID's seen thus far (across PS and MS): SIGSEGV|binary2my_decimal|Field_new_decimal::val_decimal|Item_sum_sum::add_helper|Item_sum_sum::add scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec|Item_sum_num::fix_fields scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec_decimal|Type_handler_decimal_result::Item_sum_avg_fix_length_and_dec scale >= 0 && precision > 0 && scale <= precision|SIGABRT|decimal_bin_size_inline|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::resolve_type scale >= 0 && precision > 0 && scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Item_sum_avg::fix_length_and_dec|Item_sum_num::fix_fields scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sort_length|sortlength scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|Item::sortlength scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|sortlength
            alice Alice Sherepa added a comment -

            Test case from MDEV-26422:

            --source include/have_innodb.inc
            CREATE TABLE t1 engine=innodb AS SELECT NULL AS v1;
            SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ;
            

            10.2 228630f61ac10240c3671

            :0(__GI___assert_fail)[0x7fc0efe70f36]
            strings/decimal.c:1541(decimal_bin_size)[0x55d9b2766d7a]
            sql/my_decimal.h:264(my_decimal_get_binary_size(unsigned int, unsigned int))[0x55d9b1dbe96b]
            sql/filesort.cc:1948(Type_handler_decimal_result::sortlength(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x55d9b1fbae38]
            sql/item.h:945(Item::sortlength(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x55d9b1c5c554]
            sql/filesort.cc:1995(sortlength(THD*, SORT_FIELD*, unsigned int, bool*))[0x55d9b1fbafb9]
            sql/filesort.cc:192(filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long))[0x55d9b1fb5e0b]
            sql/sql_select.cc:22110(create_sort_index(THD*, JOIN*, st_join_table*, Filesort*))[0x55d9b1db0cfd]
            sql/sql_select.cc:19860(st_join_table::sort_table())[0x55d9b1dab307]
            sql/sql_select.cc:19801(join_init_read_record(st_join_table*))[0x55d9b1daaf53]
            sql/sql_select.cc:26913(AGGR_OP::end_send())[0x55d9b1dbe035]
            sql/sql_select.cc:18610(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x55d9b1da897b]
            sql/sql_select.cc:18846(sub_select(JOIN*, st_join_table*, bool))[0x55d9b1da8caf]
            sql/sql_select.cc:18441(do_select(JOIN*, Procedure*))[0x55d9b1da8493]
            sql/sql_select.cc:3651(JOIN::exec_inner())[0x55d9b1d81f4b]
            sql/sql_select.cc:3447(JOIN::exec())[0x55d9b1d813f2]
            sql/sql_select.cc:3851(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55d9b1d825cc]
            sql/sql_select.cc:361(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55d9b1d76720]
            sql/sql_parse.cc:6271(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55d9b1d40d86]
            sql/sql_parse.cc:3582(mysql_execute_command(THD*))[0x55d9b1d378fa]
            sql/sql_parse.cc:7793(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55d9b1d44b42]
            sql/sql_parse.cc:1830(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55d9b1d32d9d]
            sql/sql_parse.cc:1381(do_command(THD*))[0x55d9b1d31898]
            sql/sql_connect.cc:1336(do_handle_one_connection(CONNECT*))[0x55d9b1e8d661]
            sql/sql_connect.cc:1242(handle_one_connection)[0x55d9b1e8d3c6]
            perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55d9b26b6ec4]
            nptl/pthread_create.c:478(start_thread)[0x7fc0f0381609]
            x86_64/clone.S:97(__GI___clone)[0x7fc0eff5c293]
             
            Query (0x7fc098012708): SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) )
            
            

            alice Alice Sherepa added a comment - Test case from MDEV-26422 : --source include/have_innodb.inc CREATE TABLE t1 engine=innodb AS SELECT NULL AS v1; SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ; 10.2 228630f61ac10240c3671 :0(__GI___assert_fail)[0x7fc0efe70f36] strings/decimal.c:1541(decimal_bin_size)[0x55d9b2766d7a] sql/my_decimal.h:264(my_decimal_get_binary_size(unsigned int, unsigned int))[0x55d9b1dbe96b] sql/filesort.cc:1948(Type_handler_decimal_result::sortlength(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x55d9b1fbae38] sql/item.h:945(Item::sortlength(THD*, Type_std_attributes const*, SORT_FIELD_ATTR*) const)[0x55d9b1c5c554] sql/filesort.cc:1995(sortlength(THD*, SORT_FIELD*, unsigned int, bool*))[0x55d9b1fbafb9] sql/filesort.cc:192(filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long))[0x55d9b1fb5e0b] sql/sql_select.cc:22110(create_sort_index(THD*, JOIN*, st_join_table*, Filesort*))[0x55d9b1db0cfd] sql/sql_select.cc:19860(st_join_table::sort_table())[0x55d9b1dab307] sql/sql_select.cc:19801(join_init_read_record(st_join_table*))[0x55d9b1daaf53] sql/sql_select.cc:26913(AGGR_OP::end_send())[0x55d9b1dbe035] sql/sql_select.cc:18610(sub_select_postjoin_aggr(JOIN*, st_join_table*, bool))[0x55d9b1da897b] sql/sql_select.cc:18846(sub_select(JOIN*, st_join_table*, bool))[0x55d9b1da8caf] sql/sql_select.cc:18441(do_select(JOIN*, Procedure*))[0x55d9b1da8493] sql/sql_select.cc:3651(JOIN::exec_inner())[0x55d9b1d81f4b] sql/sql_select.cc:3447(JOIN::exec())[0x55d9b1d813f2] sql/sql_select.cc:3851(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55d9b1d825cc] sql/sql_select.cc:361(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55d9b1d76720] sql/sql_parse.cc:6271(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55d9b1d40d86] sql/sql_parse.cc:3582(mysql_execute_command(THD*))[0x55d9b1d378fa] sql/sql_parse.cc:7793(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55d9b1d44b42] sql/sql_parse.cc:1830(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55d9b1d32d9d] sql/sql_parse.cc:1381(do_command(THD*))[0x55d9b1d31898] sql/sql_connect.cc:1336(do_handle_one_connection(CONNECT*))[0x55d9b1e8d661] sql/sql_connect.cc:1242(handle_one_connection)[0x55d9b1e8d3c6] perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55d9b26b6ec4] nptl/pthread_create.c:478(start_thread)[0x7fc0f0381609] x86_64/clone.S:97(__GI___clone)[0x7fc0eff5c293]   Query (0x7fc098012708): SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) )

            bar Probably problem came to decimal library from SQL layer, if no please assign it back.

            sanja Oleksandr Byelkin added a comment - bar Probably problem came to decimal library from SQL layer, if no please assign it back.
            bar Alexander Barkov added a comment - - edited

            Also crashes with:

            SELECT SUM(DISTINCT 0.000000000000000000000000000000000000001);
            

            and with:

            EXECUTE IMMEDIATE CONCAT('SELECT SUM(DISTINCT 0.',REPEAT('0',39),')');
            

            Note, with a smaller amount of fractional zeros than 39 it works fine.

            bar Alexander Barkov added a comment - - edited Also crashes with: SELECT SUM ( DISTINCT 0.000000000000000000000000000000000000001); and with: EXECUTE IMMEDIATE CONCAT( 'SELECT SUM(DISTINCT 0.' ,REPEAT( '0' ,39), ')' ); Note, with a smaller amount of fractional zeros than 39 it works fine.
            Roel Roel Van de Paar added a comment - - edited

            Additional testcase

            CREATE TABLE t AS SELECT 1.000000000000000000000000000000000 AS a;
            ALTER TABLE t ADD COLUMN b INT;
            SELECT ROUND (a,b) AS c FROM t ORDER BY c;
            

            Leads to:

            10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug)

            mysqld: /test/10.9_dbg/strings/decimal.c:1564: decimal_bin_size: Assertion `scale <= precision' failed.
            

            10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug)

            Core was generated by `/test/MD050422-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGABRT, Aborted.
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            [Current thread is 1 (Thread 0x14d8f0159700 (LWP 4083684))]
            (gdb) bt
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            #1  0x000014d90e5db859 in __GI_abort () at abort.c:79
            #2  0x000014d90e5db729 in __assert_fail_base (fmt=0x14d90e771588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5644f6e86d96 "scale <= precision", file=0x5644f6e86aa8 "/test/10.9_dbg/strings/decimal.c", line=1564, function=<optimized out>) at assert.c:92
            #3  0x000014d90e5ed006 in __GI___assert_fail (assertion=assertion@entry=0x5644f6e86d96 "scale <= precision", file=file@entry=0x5644f6e86aa8 "/test/10.9_dbg/strings/decimal.c", line=line@entry=1564, function=function@entry=0x5644f6e86f00 <__PRETTY_FUNCTION__.17452> "decimal_bin_size") at assert.c:101
            #4  0x00005644f67ab8d3 in decimal_bin_size (precision=<optimized out>, scale=<optimized out>) at /test/10.9_dbg/strings/decimal.c:1564
            #5  0x00005644f5f2d474 in my_decimal_get_binary_size (scale=<optimized out>, precision=<optimized out>) at /test/10.9_dbg/sql/my_decimal.h:346
            #6  Type_handler_decimal_result::sort_length (this=<optimized out>, thd=<optimized out>, item=<optimized out>, sortorder=0x14d8b8017d18) at /test/10.9_dbg/sql/filesort.cc:2196
            #7  0x00005644f5f30373 in sortlength (allow_packing_for_sortkeys=<synthetic pointer>, sort_keys=0x14d8b8017d50, thd=0x14d8b8000db8) at /test/10.9_dbg/sql/filesort.cc:2272
            #8  filesort (thd=thd@entry=0x14d8b8000db8, table=table@entry=0x14d8b80352b8, filesort=filesort@entry=0x14d8b8017750, tracker=0x14d8b8017c88, join=join@entry=0x14d8b80158b8, first_table_bit=<optimized out>) at /test/10.9_dbg/sql/filesort.cc:251
            #9  0x00005644f5c9f7fc in create_sort_index (thd=0x14d8b8000db8, join=0x14d8b80158b8, tab=tab@entry=0x14d8b8016c30, fsort=0x14d8b8017750, fsort@entry=0x0) at /test/10.9_dbg/sql/sql_select.cc:24425
            #10 0x00005644f5c9fbd3 in st_join_table::sort_table (this=this@entry=0x14d8b8016c30) at /test/10.9_dbg/sql/sql_select.cc:22106
            #11 0x00005644f5c9fd39 in join_init_read_record (tab=0x14d8b8016c30) at /test/10.9_dbg/sql/sql_select.cc:22045
            #12 0x00005644f5c87127 in sub_select (join=0x14d8b80158b8, join_tab=0x14d8b8016c30, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:21092
            #13 0x00005644f5cbef98 in do_select (procedure=0x0, join=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:20640
            #14 JOIN::exec_inner (this=this@entry=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:4749
            #15 0x00005644f5cbf544 in JOIN::exec (this=this@entry=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:4527
            #16 0x00005644f5cbd553 in mysql_select (thd=thd@entry=0x14d8b8000db8, tables=0x14d8b8014698, fields=@0x14d8b8014130: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d8b8014648, last = 0x14d8b8014648, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x14d8b80156d0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14d8b8015890, unit=0x14d8b80051c8, select_lex=0x14d8b8013e90) at /test/10.9_dbg/sql/sql_select.cc:5007
            #17 0x00005644f5cbd808 in handle_select (thd=thd@entry=0x14d8b8000db8, lex=lex@entry=0x14d8b80050f0, result=result@entry=0x14d8b8015890, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_dbg/sql/sql_select.cc:543
            #18 0x00005644f5c1cb96 in execute_sqlcom_select (thd=thd@entry=0x14d8b8000db8, all_tables=0x14d8b8014698) at /test/10.9_dbg/sql/sql_parse.cc:6268
            #19 0x00005644f5c29b7e in mysql_execute_command (thd=thd@entry=0x14d8b8000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:3959
            #20 0x00005644f5c15e23 in mysql_parse (thd=thd@entry=0x14d8b8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d8f0158400) at /test/10.9_dbg/sql/sql_parse.cc:8043
            #21 0x00005644f5c24a23 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d8b8000db8, packet=packet@entry=0x14d8b800b889 "", packet_length=packet_length@entry=41, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
            #22 0x00005644f5c27e74 in do_command (thd=0x14d8b8000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1407
            #23 0x00005644f5da4d2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5644f96da1b8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
            #24 0x00005644f5da532f in handle_one_connection (arg=arg@entry=0x5644f96da1b8) at /test/10.9_dbg/sql/sql_connect.cc:1312
            #25 0x00005644f622f7a5 in pfs_spawn_thread (arg=0x5644f961a588) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
            #26 0x000014d90eaec609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #27 0x000014d90e6d8163 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.2.44 (dbg), 10.3.35 (dbg), 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

            Bug (or feature/syntax) confirmed not present in:
            MariaDB: 10.2.44 (opt), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)
            MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)

            New UniqueID's produced with this testcase:

            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sort_length|sortlength
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|Item::sortlength
            scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|sortlength
            

            Roel Roel Van de Paar added a comment - - edited Additional testcase CREATE TABLE t AS SELECT 1.000000000000000000000000000000000 AS a; ALTER TABLE t ADD COLUMN b INT ; SELECT ROUND (a,b) AS c FROM t ORDER BY c; Leads to: 10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug) mysqld: /test/10.9_dbg/strings/decimal.c:1564: decimal_bin_size: Assertion `scale <= precision' failed. 10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug) Core was generated by `/test/MD050422-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 [Current thread is 1 (Thread 0x14d8f0159700 (LWP 4083684))] (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x000014d90e5db859 in __GI_abort () at abort.c:79 #2 0x000014d90e5db729 in __assert_fail_base (fmt=0x14d90e771588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5644f6e86d96 "scale <= precision", file=0x5644f6e86aa8 "/test/10.9_dbg/strings/decimal.c", line=1564, function=<optimized out>) at assert.c:92 #3 0x000014d90e5ed006 in __GI___assert_fail (assertion=assertion@entry=0x5644f6e86d96 "scale <= precision", file=file@entry=0x5644f6e86aa8 "/test/10.9_dbg/strings/decimal.c", line=line@entry=1564, function=function@entry=0x5644f6e86f00 <__PRETTY_FUNCTION__.17452> "decimal_bin_size") at assert.c:101 #4 0x00005644f67ab8d3 in decimal_bin_size (precision=<optimized out>, scale=<optimized out>) at /test/10.9_dbg/strings/decimal.c:1564 #5 0x00005644f5f2d474 in my_decimal_get_binary_size (scale=<optimized out>, precision=<optimized out>) at /test/10.9_dbg/sql/my_decimal.h:346 #6 Type_handler_decimal_result::sort_length (this=<optimized out>, thd=<optimized out>, item=<optimized out>, sortorder=0x14d8b8017d18) at /test/10.9_dbg/sql/filesort.cc:2196 #7 0x00005644f5f30373 in sortlength (allow_packing_for_sortkeys=<synthetic pointer>, sort_keys=0x14d8b8017d50, thd=0x14d8b8000db8) at /test/10.9_dbg/sql/filesort.cc:2272 #8 filesort (thd=thd@entry=0x14d8b8000db8, table=table@entry=0x14d8b80352b8, filesort=filesort@entry=0x14d8b8017750, tracker=0x14d8b8017c88, join=join@entry=0x14d8b80158b8, first_table_bit=<optimized out>) at /test/10.9_dbg/sql/filesort.cc:251 #9 0x00005644f5c9f7fc in create_sort_index (thd=0x14d8b8000db8, join=0x14d8b80158b8, tab=tab@entry=0x14d8b8016c30, fsort=0x14d8b8017750, fsort@entry=0x0) at /test/10.9_dbg/sql/sql_select.cc:24425 #10 0x00005644f5c9fbd3 in st_join_table::sort_table (this=this@entry=0x14d8b8016c30) at /test/10.9_dbg/sql/sql_select.cc:22106 #11 0x00005644f5c9fd39 in join_init_read_record (tab=0x14d8b8016c30) at /test/10.9_dbg/sql/sql_select.cc:22045 #12 0x00005644f5c87127 in sub_select (join=0x14d8b80158b8, join_tab=0x14d8b8016c30, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:21092 #13 0x00005644f5cbef98 in do_select (procedure=0x0, join=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:20640 #14 JOIN::exec_inner (this=this@entry=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:4749 #15 0x00005644f5cbf544 in JOIN::exec (this=this@entry=0x14d8b80158b8) at /test/10.9_dbg/sql/sql_select.cc:4527 #16 0x00005644f5cbd553 in mysql_select (thd=thd@entry=0x14d8b8000db8, tables=0x14d8b8014698, fields=@0x14d8b8014130: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d8b8014648, last = 0x14d8b8014648, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x14d8b80156d0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14d8b8015890, unit=0x14d8b80051c8, select_lex=0x14d8b8013e90) at /test/10.9_dbg/sql/sql_select.cc:5007 #17 0x00005644f5cbd808 in handle_select (thd=thd@entry=0x14d8b8000db8, lex=lex@entry=0x14d8b80050f0, result=result@entry=0x14d8b8015890, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_dbg/sql/sql_select.cc:543 #18 0x00005644f5c1cb96 in execute_sqlcom_select (thd=thd@entry=0x14d8b8000db8, all_tables=0x14d8b8014698) at /test/10.9_dbg/sql/sql_parse.cc:6268 #19 0x00005644f5c29b7e in mysql_execute_command (thd=thd@entry=0x14d8b8000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:3959 #20 0x00005644f5c15e23 in mysql_parse (thd=thd@entry=0x14d8b8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d8f0158400) at /test/10.9_dbg/sql/sql_parse.cc:8043 #21 0x00005644f5c24a23 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d8b8000db8, packet=packet@entry=0x14d8b800b889 "", packet_length=packet_length@entry=41, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362 #22 0x00005644f5c27e74 in do_command (thd=0x14d8b8000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1407 #23 0x00005644f5da4d2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5644f96da1b8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418 #24 0x00005644f5da532f in handle_one_connection (arg=arg@entry=0x5644f96da1b8) at /test/10.9_dbg/sql/sql_connect.cc:1312 #25 0x00005644f622f7a5 in pfs_spawn_thread (arg=0x5644f961a588) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201 #26 0x000014d90eaec609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #27 0x000014d90e6d8163 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.2.44 (dbg), 10.3.35 (dbg), 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg) Bug (or feature/syntax) confirmed not present in: MariaDB: 10.2.44 (opt), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt) MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt) New UniqueID's produced with this testcase: scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sort_length|sortlength scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|Item::sortlength scale <= precision|SIGABRT|decimal_bin_size|my_decimal_get_binary_size|Type_handler_decimal_result::sortlength|sortlength
            holyfoot Alexey Botchkov added a comment - - edited Proposed fix https://github.com/MariaDB/server/commit/ceb640dcc4adb96ce9139107994019b467869047

            holyfoot, this patch is OK to push:

            https://github.com/MariaDB/server/commit/ceb640dcc4adb96ce9139107994019b467869047

            As discussed on slack, a perfect solution would be to:
            1. Fix Field_new_decimal to get an already normalized "precision" and "scale" as a single new structure, say Decimal_precision_and_scale
            2. Fix all Items to properly set their "decimals".
            3. Make Items return Decimal_precision_and_scale which can be passed to Field_new_decimal,
            or the other way around - have a Decimal_precision_and_scale constructor which is initialized from Item.

            Currently N2 is a problem, especially for Item_decimal and Items recursively having Item_decimal.
            So let's fix precision and scale inside Field_new_decimal.

            bar Alexander Barkov added a comment - holyfoot , this patch is OK to push: https://github.com/MariaDB/server/commit/ceb640dcc4adb96ce9139107994019b467869047 As discussed on slack, a perfect solution would be to: 1. Fix Field_new_decimal to get an already normalized "precision" and "scale" as a single new structure, say Decimal_precision_and_scale 2. Fix all Items to properly set their "decimals". 3. Make Items return Decimal_precision_and_scale which can be passed to Field_new_decimal, or the other way around - have a Decimal_precision_and_scale constructor which is initialized from Item. Currently N2 is a problem, especially for Item_decimal and Items recursively having Item_decimal. So let's fix precision and scale inside Field_new_decimal.

            People

              holyfoot Alexey Botchkov
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              10 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.