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

Assertion `!field->is_null()' failed in my_decimal::my_decimal on SELECT

    XMLWordPrintable

    Details

      Description

      Looks a lot like MDEV-23438 but there are some differences, and this is post-patch it seems.

      CREATE TABLE t (a DECIMAL(10) PRIMARY KEY) ENGINE=InnoDB;
      SELECT (SELECT SUM(t.a) FROM t x WHERE t.a = x.a) FROM t;
      

      Leads to:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      mysqld: /test/10.5_dbg/sql/my_decimal.cc:382: my_decimal::my_decimal(Field*): Assertion `!field->is_null()' failed.
      

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      Core was generated by `/test/MD150920-mariadb-10.5.6-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:57
      [Current thread is 1 (Thread 0x15521321c700 (LWP 1350655))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x00005578a556085a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
      #2  0x00005578a4d273a9 in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #5  0x00001552114b28b1 in __GI_abort () at abort.c:79
      #6  0x00001552114a242a in __assert_fail_base (fmt=0x155211629a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5578a58acf90 "!field->is_null()", file=file@entry=0x5578a58acfd0 "/test/10.5_dbg/sql/my_decimal.cc", line=line@entry=382, function=function@entry=0x5578a58ad0d0 <my_decimal::my_decimal(Field*)::__PRETTY_FUNCTION__> "my_decimal::my_decimal(Field*)") at assert.c:92
      #7  0x00001552114a24a2 in __GI___assert_fail (assertion=assertion@entry=0x5578a58acf90 "!field->is_null()", file=file@entry=0x5578a58acfd0 "/test/10.5_dbg/sql/my_decimal.cc", line=line@entry=382, function=function@entry=0x5578a58ad0d0 <my_decimal::my_decimal(Field*)::__PRETTY_FUNCTION__> "my_decimal::my_decimal(Field*)") at assert.c:101
      #8  0x00005578a4ea67d8 in my_decimal::my_decimal (this=0x155213219890, field=0x1551eec525f0) at /test/10.5_dbg/sql/my_decimal.cc:382
      #9  0x00005578a4d1dc8a in Field::do_field_decimal (copy=0x1551eec79d70) at /test/10.5_dbg/sql/field_conv.cc:416
      #10 0x00005578a4af66bc in store_key_field::copy_inner (this=0x1551eec79d48) at /test/10.5_dbg/sql/sql_select.h:1971
      #11 0x00005578a4acae7d in store_key::copy (this=<optimized out>) at /test/10.5_dbg/sql/sql_select.h:1912
      #12 cp_buffer_from_ref (thd=thd@entry=0x1551eec15088, table=table@entry=0x1551eec52a88, ref=ref@entry=0x1551eed4e410) at /test/10.5_dbg/sql/sql_select.cc:24274
      #13 0x00005578a4acb63e in cmp_buffer_with_ref (tab_ref=0x1551eed4e410, table=0x1551eec52a88, thd=0x1551eec15088) at /test/10.5_dbg/sql/sql_select.cc:24256
      #14 join_read_key2 (thd=0x1551eec15088, tab=0x1551eed4e1f0, table=0x1551eec52a88, table_ref=0x1551eed4e410) at /test/10.5_dbg/sql/sql_select.cc:21295
      #15 0x00005578a4acb836 in join_read_key (tab=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:21262
      #16 0x00005578a4abb1dd in sub_select (join=0x1551eec77bb8, join_tab=0x1551eed4e1f0, end_of_records=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:20634
      #17 0x00005578a4af5476 in do_select (procedure=0x0, join=0x1551eec77bb8) at /test/10.5_dbg/sql/sql_select.cc:20171
      #18 JOIN::exec_inner (this=this@entry=0x1551eec77bb8) at /test/10.5_dbg/sql/sql_select.cc:4455
      #19 0x00005578a4af5a91 in JOIN::exec (this=0x1551eec77bb8) at /test/10.5_dbg/sql/sql_select.cc:4236
      #20 0x00005578a4e168fa in subselect_single_select_engine::exec (this=0x1551eec763c8) at /test/10.5_dbg/sql/item_subselect.cc:3989
      #21 0x00005578a4e15c75 in Item_subselect::exec (this=0x1551eec76220) at /test/10.5_dbg/sql/item_subselect.cc:782
      #22 0x00005578a4e143bd in Item_singlerow_subselect::val_decimal (this=0x1551eec76220, decimal_value=0x1551eed4f358) at /test/10.5_dbg/sql/item_subselect.cc:1428
      #23 0x00005578a4985bcd in Item::val_decimal_result (this=<optimized out>, val=<optimized out>) at /test/10.5_dbg/sql/item.h:1568
      #24 0x00005578a4d4708a in Item_cache_decimal::cache_value (this=0x1551eed4f2a8) at /test/10.5_dbg/sql/item.cc:10137
      #25 0x00005578a4d6c15f in Item_cache_wrapper::cache (this=this@entry=0x1551eed4f1e0) at /test/10.5_dbg/sql/item.cc:8678
      #26 0x00005578a4d5eeb9 in Item_cache_wrapper::val_str (this=0x1551eed4f1e0, str=0x155213219fc0) at /test/10.5_dbg/sql/item.cc:8786
      #27 0x00005578a4c61eaa in Type_handler::Item_send_str (this=<optimized out>, item=0x1551eed4f1e0, protocol=0x1551eec15650, buf=<optimized out>) at /test/10.5_dbg/sql/sql_type.cc:7343
      #28 0x00005578a4bb35a5 in Type_handler_decimal_result::Item_send (this=<optimized out>, item=<optimized out>, protocol=<optimized out>, buf=<optimized out>) at /test/10.5_dbg/sql/sql_type.h:4864
      #29 0x00005578a4d4693b in Item::send (buffer=0x155213219f90, protocol=0x1551eec15650, this=0x1551eed4f1e0) at /test/10.5_dbg/sql/item.h:1060
      #30 Item_cache_wrapper::send (this=0x1551eed4f1e0, protocol=0x1551eec15650, buffer=0x155213219f90) at /test/10.5_dbg/sql/item.cc:8584
      #31 0x00005578a4982d8f in Protocol::send_result_set_row (this=this@entry=0x1551eec15650, row_items=row_items@entry=0x1551eec778c0) at /test/10.5_dbg/sql/protocol.cc:1083
      #32 0x00005578a4a15a76 in select_send::send_data (this=0x1551eec774e0, items=@0x1551eec778c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1551eed4f5a8, last = 0x1551eed4f5a8, elements = 1}, <No data fields>}) at /test/10.5_dbg/sql/sql_class.cc:3024
      #33 0x00005578a4acfc8a in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x1551eec778c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1551eed4f5a8, last = 0x1551eed4f5a8, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.5_dbg/sql/sql_class.h:5310
      #34 end_send_group (join=0x1551eec77508, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:21979
      #35 0x00005578a4abb0a1 in sub_select (join=0x1551eec77508, join_tab=0x1551eec79120, end_of_records=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:20582
      #36 0x00005578a4af5728 in do_select (procedure=<optimized out>, join=0x1551eec77508) at /test/10.5_dbg/sql/sql_select.cc:20173
      #37 JOIN::exec_inner (this=this@entry=0x1551eec77508) at /test/10.5_dbg/sql/sql_select.cc:4455
      #38 0x00005578a4af5a91 in JOIN::exec (this=this@entry=0x1551eec77508) at /test/10.5_dbg/sql/sql_select.cc:4236
      #39 0x00005578a4af3d8d in mysql_select (thd=thd@entry=0x1551eec15088, tables=<optimized out>, fields=@0x1551eec742c8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1551eec76408, last = 0x1551eec76408, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1551eec774e0, unit=0x1551eec19220, select_lex=0x1551eec74178) at /test/10.5_dbg/sql/sql_select.cc:4663
      #40 0x00005578a4af40bc in handle_select (thd=thd@entry=0x1551eec15088, lex=lex@entry=0x1551eec19158, result=result@entry=0x1551eec774e0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417
      #41 0x00005578a4a7b348 in execute_sqlcom_select (thd=thd@entry=0x1551eec15088, all_tables=0x1551eec76480) at /test/10.5_dbg/sql/sql_parse.cc:6210
      #42 0x00005578a4a7441c in mysql_execute_command (thd=thd@entry=0x1551eec15088) at /test/10.5_dbg/sql/sql_parse.cc:3932
      #43 0x00005578a4a81324 in mysql_parse (thd=thd@entry=0x1551eec15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15521321b350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
      #44 0x00005578a4a6dd54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1551eec15088, packet=packet@entry=0x1551eec67089 "", packet_length=packet_length@entry=56, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
      #45 0x00005578a4a6c53e in do_command (thd=0x1551eec15088) at /test/10.5_dbg/sql/sql_parse.cc:1348
      #46 0x00005578a4bcb893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1551f20d43a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
      #47 0x00005578a4bcbfb7 in handle_one_connection (arg=arg@entry=0x1551f20d43a8) at /test/10.5_dbg/sql/sql_connect.cc:1312
      #48 0x00005578a50365c2 in pfs_spawn_thread (arg=0x155210046508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #49 0x00001552121956db in start_thread (arg=0x15521321c700) at pthread_create.c:463
      #50 0x0000155211593a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.15 (dbg), 10.5.6 (dbg)

      Bug confirmed not present in:
      MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.3.25 (dbg), 10.3.25 (opt), 10.4.15 (opt), 10.5.6 (opt), 10.6.0 (dbg), 10.6.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

      Result for MyISAM, Aria, MEMORY:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      10.5.6>CREATE TABLE t (a DECIMAL(10) PRIMARY KEY) ENGINE=MyISAM;
      Query OK, 0 rows affected (0.004 sec)
       
      10.5.6>SELECT (SELECT SUM(t.a) FROM t x WHERE t.a = x.a) FROM t;
      +--------------------------------------------+
      | (SELECT SUM(t.a) FROM t x WHERE t.a = x.a) |
      +--------------------------------------------+
      |                                       NULL |
      +--------------------------------------------+
      1 row in set (0.002 sec)
      

      It's also a regression:

      10.3.25 7e07e38cf687ccd7fa3bd3a35c1eb7e4b307ca5f (Debug)

      10.3.25>CREATE TABLE t (a DECIMAL(10) PRIMARY KEY) ENGINE=InnoDB;
      Query OK, 0 rows affected (0.021 sec)
       
      10.3.25>SELECT (SELECT SUM(t.a) FROM t x WHERE t.a = x.a) FROM t;
      +--------------------------------------------+
      | (SELECT SUM(t.a) FROM t x WHERE t.a = x.a) |
      +--------------------------------------------+
      |                                       NULL |
      +--------------------------------------------+
      1 row in set (0.007 sec)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.