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

Types mismatch when cloning items causes debug assertion

    XMLWordPrintable

Details

    Description

      Test case

      CREATE VIEW t AS SELECT 1 AS a;
      SELECT a FROM t WHERE CASE WHEN a THEN DEFAULT (a) END=0;
      

      Leads to

      10.5.26 c038b3c05ed90041333dc869e3435c301210a3c4 (Debug)

      mariadbd: /test/10.5_dbg/sql/item.h:1677: Item* Item::get_copy(THD*) const: Assertion `typeid(*copy) == typeid(*this)' failed.
      

      10.5.26 c038b3c05ed90041333dc869e3435c301210a3c4 (Debug)

      Core was generated by `/test/MD300724-mariadb-10.5.26-linux-x86_64-dbg/bin/mariadbd --no-defaults --ma'.
      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 0x14673409f700 (LWP 1132966))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x0000146734fa3859 in __GI_abort () at abort.c:79
      #2  0x0000146734fa3729 in __assert_fail_base (fmt=0x146735139588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5634bcbfc6d0 "typeid(*copy) == typeid(*this)", file=0x5634bcbfc308 "/test/10.5_dbg/sql/item.h", line=1677, function=<optimized out>) at assert.c:92
      #3  0x0000146734fb4fd6 in __GI___assert_fail (assertion=assertion@entry=0x5634bcbfc6d0 "typeid(*copy) == typeid(*this)", file=file@entry=0x5634bcbfc308 "/test/10.5_dbg/sql/item.h", line=line@entry=1677, function=function@entry=0x5634bcbfc6a8 "Item* Item::get_copy(THD*) const") at assert.c:101
      #4  0x00005634bbe2dbf6 in Item::get_copy (thd=<optimized out>, this=0x1466b8013e98) at /usr/include/c++/9/typeinfo:122
      #5  Item_field::do_build_clone (this=0x1466b8013e98, thd=<optimized out>) at /test/10.5_dbg/sql/item.h:3701
      #6  0x00005634bc1d448e in Item::build_clone (thd=0x1466b8000d48, this=0x1466b8013e98) at /test/10.5_dbg/sql/item.h:1691
      #7  Item_func_or_sum::do_build_clone (this=0x1466b8014018, thd=0x1466b8000d48) at /test/10.5_dbg/sql/item.cc:2731
      #8  0x00005634bc1d448e in Item::build_clone (thd=0x1466b8000d48, this=0x1466b8014018) at /test/10.5_dbg/sql/item.h:1691
      #9  Item_func_or_sum::do_build_clone (this=0x1466b80141b8, thd=0x1466b8000d48) at /test/10.5_dbg/sql/item.cc:2731
      #10 0x00005634bc21c1b5 in Item_bool_rowready_func2::do_build_clone (this=<optimized out>, thd=<optimized out>) at /test/10.5_dbg/sql/item_cmpfunc.h:584
      #11 0x00005634bc1e426a in Item::build_clone (thd=0x1466b8000d48, this=0x1466b80141b8) at /test/10.5_dbg/sql/item.h:1691
      #12 Item::build_pushable_cond (this=this@entry=0x1466b80141b8, thd=thd@entry=0x1466b8000d48, checker=<optimized out>, arg=0x1466b801d5f0 "\001") at /test/10.5_dbg/sql/item.cc:7798
      #13 0x00005634bbe91751 in pushdown_cond_for_derived (thd=0x1466b8000d48, cond=0x1466b80141b8, derived=derived@entry=0x1466b80134f0) at /test/10.5_dbg/sql/sql_derived.cc:1526
      #14 0x00005634bbf6235e in JOIN::optimize_inner (this=this@entry=0x1466b8017d48) at /test/10.5_dbg/sql/sql_select.cc:2229
      #15 0x00005634bbf62e67 in JOIN::optimize (this=this@entry=0x1466b8017d48) at /test/10.5_dbg/sql/sql_select.cc:1765
      #16 0x00005634bbf62f3f in mysql_select (thd=thd@entry=0x1466b8000d48, tables=0x1466b80134f0, fields=@0x1466b8012ff8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1466b80134a8, last = 0x1466b80134a8, elements = 1}, <No data fields>}, conds=0x1466b80141b8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1466b8017d20, unit=0x1466b8004ef8, select_lex=0x1466b8012e90) at /test/10.5_dbg/sql/sql_select.cc:4897
      #17 0x00005634bbf63a95 in handle_select (thd=thd@entry=0x1466b8000d48, lex=lex@entry=0x1466b8004e30, result=result@entry=0x1466b8017d20, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:449
      #18 0x00005634bbedbf50 in execute_sqlcom_select (thd=thd@entry=0x1466b8000d48, all_tables=0x1466b80134f0) at /test/10.5_dbg/sql/sql_parse.cc:6425
      #19 0x00005634bbee8fc6 in mysql_execute_command (thd=thd@entry=0x1466b8000d48) at /test/10.5_dbg/sql/sql_parse.cc:4030
      #20 0x00005634bbed528c in mysql_parse (thd=thd@entry=0x1466b8000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14673409e2c0, 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:8223
      #21 0x00005634bbee3fd1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1466b8000d48, packet=packet@entry=0x1466b800aa19 "SELECT a FROM t WHERE CASE WHEN a THEN DEFAULT (a) END=0", 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_class.h:1329
      #22 0x00005634bbee6d0a in do_command (thd=0x1466b8000d48) at /test/10.5_dbg/sql/sql_parse.cc:1376
      #23 0x00005634bc033c16 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5634befebc18, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1417
      #24 0x00005634bc0342b4 in handle_one_connection (arg=arg@entry=0x5634befebc18) at /test/10.5_dbg/sql/sql_connect.cc:1319
      #25 0x00005634bc4b418d in pfs_spawn_thread (arg=0x5634befce988) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #26 0x00001467354b4609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #27 0x00001467350a0133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.5.26 (dbg), 10.6.19 (dbg), 10.11.9 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.26 (opt), 10.6.19 (opt), 10.11.9 (opt), 11.1.6 (dbg), 11.1.6 (opt), 11.2.5 (dbg), 11.2.5 (opt), 11.4.3 (dbg), 11.4.3 (opt), 11.5.2 (dbg), 11.5.2 (opt), 11.6.0 (dbg), 11.6.0 (opt)

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.