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

MDEV-31466-fix column count issue with union in derived table

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (c1 INT,c2 INT) ENGINE=MyISAM;
      SELECT * FROM (SELECT * FROM t UNION SELECT * FROM t) AS d (d1);
      

      And other similar testcases with 'AS d (d1,d2)' with 3 c1/2/3 cols etc., lead to:

      bb-11.7-MDEV-34931-MDEV-31466-fix CS 11.7.0 39ada42448240ffa30f840107b9a7a29e5f2d2ae (Optimized)

      Core was generated by `/test/MDEV-34931-MDEV-31466-fix_MD170924-mariadb-11.7.0-linux-x86_64-opt/bin/ma'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00005583d5ee4f87 in st_select_lex_unit::rename_types_list (this=0x146164019500, newnames=<optimized out>)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_list.h:431
      431	    return current->info;
      [Current thread is 1 (LWP 1971592)]
      (gdb) bt
      #0  0x00005583d5ee4f87 in st_select_lex_unit::rename_types_list (this=0x146164019500, newnames=<optimized out>)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_list.h:431
      #1  st_select_lex_unit::prepare (this=this@entry=0x146164019500, derived_arg=derived_arg@entry=0x14616401b008, sel_result=sel_result@entry=0x146164021e88, additional_options=<optimized out>, additional_options@entry=0)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_union.cc:1976
      #2  0x00005583d5db681e in mysql_derived_prepare (thd=0x146164000c68, lex=<optimized out>, derived=0x14616401b008)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_derived.cc:840
      #3  0x00005583d5db556f in mysql_handle_single_derived (lex=lex@entry=0x146164004eb8, derived=derived@entry=0x14616401b008, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_derived.cc:200
      #4  0x00005583d5f11cae in TABLE_LIST::handle_derived (this=this@entry=0x14616401b008, lex=lex@entry=0x146164004eb8, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/table.cc:9888
      #5  0x00005583d5dd4df7 in LEX::handle_list_of_derived (this=0x146164004eb8, table_list=<optimized out>, phases=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_lex.h:4517
      #6  st_select_lex::handle_derived (this=<optimized out>, lex=0x146164004eb8, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_lex.cc:5126
      #7  0x00005583d5e70221 in JOIN::prepare (this=this@entry=0x1461640216d8, tables_init=tables_init@entry=0x14616401b008, 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=0x146164018188, unit_arg=0x146164004f98)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_select.cc:1451
      #8  0x00005583d5e84d4d in mysql_select (thd=thd@entry=0x146164000c68, tables=0x14616401b008, fields=@0x146164018440: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x146164018770, last = 0x146164018770, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x1461640216b0, unit=0x146164004f98, select_lex=0x146164018188)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_select.cc:5320
      #9  0x00005583d5e850f4 in handle_select (thd=thd@entry=0x146164000c68, lex=lex@entry=0x146164004eb8, result=result@entry=0x1461640216b0, setup_tables_done_option=setup_tables_done_option@entry=0)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_select.cc:628
      #10 0x00005583d5df2882 in execute_sqlcom_select (thd=thd@entry=0x146164000c68, all_tables=0x14616401b008)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_parse.cc:6154
      #11 0x00005583d5e018c1 in mysql_execute_command (thd=thd@entry=0x146164000c68, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_parse.cc:3954
      #12 0x00005583d5e02d49 in mysql_parse (thd=0x146164000c68, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_parse.cc:7876
      #13 0x00005583d5e04e6b in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x146164000c68, packet=packet@entry=0x146164008879 "SELECT * FROM (SELECT * FROM t UNION SELECT * FROM t) AS d (d1)", packet_length=packet_length@entry=63, blocking=blocking@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_parse.cc:1991
      #14 0x00005583d5e0744d in do_command (thd=0x146164000c68, blocking=blocking@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_parse.cc:1405
      #15 0x00005583d5f411b3 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5583d9aeb2a8, put_in_cache=put_in_cache@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_connect.cc:1448
      #16 0x00005583d5f41545 in handle_one_connection (arg=arg@entry=0x5583d9aeb2a8)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/sql/sql_connect.cc:1350
      #17 0x00005583d630c73f in pfs_spawn_thread (arg=0x5583d9a92fb8)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_opt/storage/perfschema/pfs.cc:2198
      #18 0x00001461c689ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x00001461c6929c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      bb-11.7-MDEV-34931-MDEV-31466-fix CS 11.7.0 39ada42448240ffa30f840107b9a7a29e5f2d2ae (Debug)

      Core was generated by `/test/MDEV-34931-MDEV-31466-fix_MD170924-mariadb-11.7.0-linux-x86_64-dbg/bin/ma'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x000055c193816c30 in st_select_lex_unit::rename_types_list (this=0x14dddc01bfd0, newnames=<optimized out>)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_list.h:431
      431	    return current->info;
      [Current thread is 1 (LWP 2331182)]
      (gdb) bt
      #0  0x000055c193816c30 in st_select_lex_unit::rename_types_list (this=0x14dddc01bfd0, newnames=<optimized out>)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_list.h:431
      #1  st_select_lex_unit::prepare (this=this@entry=0x14dddc01bfd0, derived_arg=derived_arg@entry=0x14dddc01dad8, sel_result=0x14dddc02b398, additional_options=<optimized out>, additional_options@entry=0)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_union.cc:1976
      #2  0x000055c1936b304a in mysql_derived_prepare (thd=0x14dddc000d58, lex=<optimized out>, derived=0x14dddc01dad8)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_derived.cc:840
      #3  0x000055c1936b13f6 in mysql_handle_single_derived (lex=lex@entry=0x14dddc005170, derived=derived@entry=0x14dddc01dad8, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_derived.cc:200
      #4  0x000055c19384144d in TABLE_LIST::handle_derived (this=this@entry=0x14dddc01dad8, lex=lex@entry=0x14dddc005170, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/table.cc:9888
      #5  0x000055c1936d2803 in LEX::handle_list_of_derived (this=0x14dddc005170, table_list=<optimized out>, phases=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_lex.h:4517
      #6  st_select_lex::handle_derived (this=<optimized out>, lex=0x14dddc005170, phases=phases@entry=2)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_lex.cc:5126
      #7  0x000055c193782223 in JOIN::prepare (this=this@entry=0x14dddc02abd8, tables_init=tables_init@entry=0x14dddc01dad8, 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=0x14dddc01ac58, unit_arg=0x14dddc005250)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_select.cc:1451
      #8  0x000055c193798b9d in mysql_select (thd=thd@entry=0x14dddc000d58, tables=0x14dddc01dad8, fields=@0x14dddc01af10: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dddc01b240, last = 0x14dddc01b240, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x14dddc02abb0, unit=0x14dddc005250, select_lex=0x14dddc01ac58)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_select.cc:5320
      #9  0x000055c193798dc7 in handle_select (thd=thd@entry=0x14dddc000d58, lex=lex@entry=0x14dddc005170, result=result@entry=0x14dddc02abb0, setup_tables_done_option=setup_tables_done_option@entry=0)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_select.cc:628
      #10 0x000055c1936f65ac in execute_sqlcom_select (thd=thd@entry=0x14dddc000d58, all_tables=0x14dddc01dad8)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_parse.cc:6154
      #11 0x000055c193702f4a in mysql_execute_command (thd=thd@entry=0x14dddc000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_parse.cc:3954
      #12 0x000055c193709853 in mysql_parse (thd=thd@entry=0x14dddc000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14de39dfe250)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_parse.cc:7876
      #13 0x000055c19370bce1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14dddc000d58, packet=packet@entry=0x14dddc00b349 "SELECT * FROM (SELECT * FROM t UNION SELECT * FROM t) AS d (d1)", packet_length=packet_length@entry=63, blocking=blocking@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_class.h:256
      #14 0x000055c19370e064 in do_command (thd=0x14dddc000d58, blocking=blocking@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_parse.cc:1405
      #15 0x000055c193881348 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55c1979517f8, put_in_cache=put_in_cache@entry=true)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_connect.cc:1448
      #16 0x000055c193881654 in handle_one_connection (arg=arg@entry=0x55c1979517f8)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/sql/sql_connect.cc:1350
      #17 0x000055c193cd9748 in pfs_spawn_thread (arg=0x55c1978d0d28)at /test/bb-11.7-MDEV-34931-MDEV-31466-fix_dbg/storage/perfschema/pfs.cc:2198
      #18 0x000014de3ce9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x000014de3cf29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Not present in trunk (invalid syntax).

      Attachments

        Issue Links

          Activity

            People

              Johnston Rex Johnston
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.