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

Assertion `(*select_ref)->is_fixed()' failed in resolve_ref_in_select_and_group

Details

    Description

      USE test;
      CREATE TABLE t1(a CHAR BINARY);
      SELECT(SELECT a FROM (SELECT 1 FROM t1)e ORDER BY (@f:=a)) FROM t1 GROUP BY a;
      

      Leads to:

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      mysqld: /test/10.5_dbg/sql/item.cc:5315: Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*): Assertion `(*select_ref)->is_fixed()' failed.                                              
      

      10.5.4 8569dac1ec9f6853a0b2f3ea9bcbda67644ead24

      Core was generated by `/test/MD260520-mariadb-10.5.4-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 0x14e965e0c700 (LWP 125805))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthre
      ad_kill.c:57                                                                                          
      #1  0x000055e6ca243d7a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
      #2  0x000055e6c99e9385 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  0x000014e964550801 in __GI_abort () at abort.c:79
      #6  0x000014e96454039a in __assert_fail_base (fmt=0x14e9646c77d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55e6ca55d795 "(*select_ref)->is_fixed()", file=file@entry=0x55e6ca55d128 "/test/10.5_dbg/sql/item.cc", line=line@entry=5315, function=function@entry=0x55e6ca55b040 <resolve_ref_in_select_and_group(THD*, Item_ident*, st_select_lex*)::__PRETTY_FUNCTION__> "Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*)") at assert.c:92                              
      #7  0x000014e964540412 in __GI___assert_fail (assertion=assertion@entry=0x55e6ca55d795 "(*select_ref)->is_fixed()", file=file@entry=0x55e6ca55d128 "/test/10.5_dbg/sql/item.cc", line=line@entry=5315, function=function@entry=0x55e6ca55b040 <resolve_ref_in_select_and_group(THD*, Item_ident*, st_select_lex*)::__PRETTY_FUNCTION__> "Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*)") at assert.c:101                                                                                             
      #8  0x000055e6c9a20c24 in resolve_ref_in_select_and_group (thd=thd@entry=0x14e943815088, ref=ref@entry=0x14e943879de8, select=<optimized out>) at /test/10.5_dbg/sql/item.cc:5315                           
      #9  0x000055e6c9a20e83 in Item_ref::fix_fields (this=0x14e943879de8, thd=0x14e943815088, reference=0x14e965e09e68) at /test/10.5_dbg/sql/item.cc:7764                                                       
      #10 0x000055e6c9a22c5b in Item_field::fix_fields (this=0x14e943876f68, thd=0x14e943815088, reference=0x14e943877140) at /test/10.5_dbg/sql/item.cc:5851                                                     
      #11 0x000055e6c9a69abd in Item::fix_fields_if_needed (ref=0x14e943877140, thd=0x14e943815088, this=0x14e943876f68) at /test/10.5_dbg/sql/item.h:978                                                         
      #12 Item_func::fix_fields (this=this@entry=0x14e9438770a8, thd=thd@entry=0x14e943815088, ref=ref@entry=0x14e943877248) at /test/10.5_dbg/sql/item_func.cc:352                                               
      #13 0x000055e6c9a7e67d in Item_func_set_user_var::fix_fields (this=0x14e9438770a8, thd=0x14e943815088, ref=0x14e943877248) at /test/10.5_dbg/sql/item_func.cc:4496                                          
      #14 0x000055e6c979e306 in Item::fix_fields_if_needed (ref=0x14e943877248, thd=0x14e943815088, this=0x14e9438770a8) at /test/10.5_dbg/sql/item.h:978
      #15 Item::fix_fields_if_needed_for_scalar (ref=0x14e943877248, thd=0x14e943815088, this=0x14e9438770a8) at /test/10.5_dbg/sql/item.h:982                                                                    
      #16 Item::fix_fields_if_needed_for_order_by (ref=0x14e943877248, thd=0x14e943815088, this=0x14e9438770a8) at /test/10.5_dbg/sql/item.h:990                                                                  
      #17 find_order_in_list (thd=thd@entry=0x14e943815088, ref_pointer_array=..., tables=tables@entry=0x14e943876068, order=order@entry=0x14e943877238, fields=..., all_fields=..., is_group_field=false, add_to_all_fields=true, from_window_spec=false) at /test/10.5_dbg/sql/sql_select.cc:24454                    
      #18 0x000055e6c979e599 in setup_order (thd=thd@entry=0x14e943815088, ref_pointer_array=..., tables=tables@entry=0x14e943876068, fields=..., all_fields=..., order=0x14e943877238, from_window_spec=false) at /test/10.5_dbg/sql/sql_select.cc:24498                                                               
      #19 0x000055e6c97adf9f in setup_without_group (reserved=0x14e94387491c, hidden_group_fields=0x14e943879137, win_funcs=..., win_specs=..., group=0x0, order=0x14e943877238, conds=0x14e943879260, all_fields=..., fields=..., leaves=..., tables=0x14e943876068, ref_pointer_array=..., thd=0x14e943815088) at /test/10.5_dbg/sql/sql_select.cc:709                                                                      
      #20 JOIN::prepare (this=0x14e943878e50, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14e943874610, unit_arg=0x14e943876758) at /test/10.5_dbg/sql/sql_select.cc:1246                                                                    
      #21 0x000055e6c9ad8b25 in subselect_single_select_engine::prepare (this=0x14e943877468, thd=0x14e943815088) at /test/10.5_dbg/sql/item_subselect.cc:3725                                                    
      #22 0x000055e6c9ad7c79 in Item_subselect::fix_fields (this=0x14e9438772c0, thd_param=<optimized out>, ref=0x14e9438774b0) at /test/10.5_dbg/sql/item_subselect.cc:285                                       
      #23 0x000055e6c96c40cd in Item::fix_fields_if_needed (ref=0x14e9438774b0, thd=0x14e943815088, this=0x14e9438772c0) at /test/10.5_dbg/sql/item.h:978                                                         
      #24 Item::fix_fields_if_needed_for_scalar (ref=0x14e9438774b0, thd=0x14e943815088, this=0x14e9438772c0) at /test/10.5_dbg/sql/item.h:982                                                                    
      #25 setup_fields (thd=0x14e943815088, ref_pointer_array=..., fields=..., column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x14e943878a78, pre_fix=0x14e943874308, allow_sum_func=true) at /test/10.5_dbg/sql/sql_base.cc:7525                                                 
      #26 0x000055e6c97adcd5 in JOIN::prepare (this=this@entry=0x14e943878750, tables_init=tables_init@entry=0x14e943877528, conds_init=conds_init@entry=0x0, og_num=og_num@entry=1, order_init=order_init@entry=0x0, skip_order_by=skip_order_by@entry=false, group_init=0x14e943877d58, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14e9438741a0, unit_arg=0x14e9438190a0) at /test/10.5_dbg/sql/sql_select.cc:1241                                                                                                    
      #27 0x000055e6c97bb273 in mysql_select (thd=thd@entry=0x14e943815088, tables=0x14e943877528, fields=..., conds=0x0, og_num=1, order=0x0, group=0x14e943877d58, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14e943878728, unit=0x14e9438190a0, select_lex=0x14e9438741a0) at /test/10.5_dbg/sql/sql_select.cc:4634                                                                                   
      #28 0x000055e6c97bb675 in handle_select (thd=thd@entry=0x14e943815088, lex=lex@entry=0x14e943818fd8, result=result@entry=0x14e943878728, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417                                                                       
      #29 0x000055e6c97460bf in execute_sqlcom_select (thd=thd@entry=0x14e943815088, all_tables=0x14e943877528) at /test/10.5_dbg/sql/sql_parse.cc:6207                                                           
      #30 0x000055e6c973f1f4 in mysql_execute_command (thd=thd@entry=0x14e943815088) at /test/10.5_dbg/sql/sql_parse.cc:3939                                                                                      
      #31 0x000055e6c974c02e in mysql_parse (thd=thd@entry=0x14e943815088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14e965e0b3d0, 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:7991  
                   #32 0x000055e6c9738b42 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14e943815088, packet=packet@entry=0x14e943867089 "SELECT(SELECT a FROM (SELECT 1 FROM t1)e ORDER BY (@f:=a)) FROM t1 GROUP BY a", packet_length=packet_length@entry=77, 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:1874                        
      #33 0x000055e6c973731c in do_command (thd=0x14e943815088) at /test/10.5_dbg/sql/sql_parse.cc:1355
      #34 0x000055e6c989173f in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14e9450453a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1411                  
      #35 0x000055e6c9891e5b in handle_one_connection (arg=arg@entry=0x14e9450453a8) at /test/10.5_dbg/sql/sql_connect.cc:1313                                                                                    
      #36 0x000055e6c9cf114e in pfs_spawn_thread (arg=0x14e963845888) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201                                                                                            
      #37 0x000014e9652336db in start_thread (arg=0x14e965e0c700) at pthread_create.c:463
      #38 0x000014e96463188f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.1.46 (dbg), 10.2.33 (dbg), 10.3.24 (dbg), 10.4.14 (dbg), 10.5.4 (dbg)
      MySQL: 5.5.62 (dbg)

      Bug confirmed not present in:
      MariaDB: 10.1.46 (opt), 10.2.33 (opt), 10.3.24 (opt), 10.4.14 (opt), 10.5.4 (opt)
      MySQL: 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)

      Attachments

        Issue Links

          Activity

            CREATE TABLE t0 (a INT,PRIMARY KEY(a));
            SELECT (SELECT a FROM (SELECT 0 FROM t0) e ORDER BY (@f:=a)) FROM t0 GROUP BY a;
            

            Leads to:

            10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

            mysqld: /test/10.8_dbg/sql/item.cc:5517: Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*): Assertion `(*select_ref)->fixed()' failed.
            

            10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

            Core was generated by `/test/MD121121-mariadb-10.8.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 0x14964868b700 (LWP 85041))]
            (gdb) bt
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            #1  0x000014964c26a859 in __GI_abort () at abort.c:79
            #2  0x000014964c26a729 in __assert_fail_base (fmt=0x14964c400588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56499692cd89 "(*select_ref)->fixed()", file=0x56499692cb7c "/test/10.8_dbg/sql/item.cc", line=5517, function=<optimized out>) at assert.c:92
            #3  0x000014964c27bf36 in __GI___assert_fail (assertion=assertion@entry=0x56499692cd89 "(*select_ref)->fixed()", file=file@entry=0x56499692cb7c "/test/10.8_dbg/sql/item.cc", line=line@entry=5517, function=function@entry=0x56499692e0e0 "Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*)") at assert.c:101
            #4  0x0000564995de6a26 in resolve_ref_in_select_and_group (thd=thd@entry=0x149600000db8, ref=ref@entry=0x149600026fa8, select=<optimized out>) at /test/10.8_dbg/sql/item.h:1069
            #5  0x0000564995dfd011 in Item_ref::fix_fields (this=0x149600026fa8, thd=0x149600000db8, reference=0x1496486890b8) at /test/10.8_dbg/sql/item.cc:7997
            #6  0x0000564995dfc715 in Item_field::fix_fields (this=0x149600016c70, thd=0x149600000db8, reference=0x149600016e00) at /test/10.8_dbg/sql/item.cc:6072
            #7  0x0000564995e50f2e in Item::fix_fields_if_needed (ref=0x149600016e00, thd=0x149600000db8, this=<optimized out>) at /test/10.8_dbg/sql/item.h:1144
            #8  Item_func::fix_fields (this=this@entry=0x149600016d88, thd=thd@entry=0x149600000db8, ref=ref@entry=0x149600016f08) at /test/10.8_dbg/sql/item_func.cc:347
            #9  0x0000564995e6c540 in Item_func_set_user_var::fix_fields (this=0x149600016d88, thd=0x149600000db8, ref=0x149600016f08) at /test/10.8_dbg/sql/item_func.cc:4714
            #10 0x0000564995b0d7b2 in Item::fix_fields_if_needed (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1156
            #11 Item::fix_fields_if_needed_for_scalar (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1148
            #12 Item::fix_fields_if_needed_for_order_by (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1156
            #13 find_order_in_list (thd=thd@entry=0x149600000db8, ref_pointer_array=<optimized out>, tables=tables@entry=0x149600015d68, order=order@entry=0x149600016ef8, fields=@0x1496000145e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, is_group_field=false, add_to_all_fields=true, from_window_spec=false) at /test/10.8_dbg/sql/sql_select.cc:24987
            #14 0x0000564995b3c3a3 in setup_order (thd=thd@entry=0x149600000db8, ref_pointer_array=<optimized out>, tables=tables@entry=0x149600015d68, fields=@0x1496000145e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, order=0x149600016ef8, from_window_spec=false) at /test/10.8_dbg/sql/sql_select.cc:25034
            #15 0x0000564995b40c7e in setup_without_group (reserved=<optimized out>, hidden_group_fields=0x1496000262c7, win_funcs=<optimized out>, win_specs=<optimized out>, group=<optimized out>, order=<optimized out>, conds=0x149600026400, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, fields=<optimized out>, leaves=<optimized out>, tables=<optimized out>, ref_pointer_array=<optimized out>, thd=<optimized out>) at /test/10.8_dbg/sql/sql_select.cc:849
            #16 JOIN::prepare (this=0x149600025fb0, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=<optimized out>, having_init=<optimized out>, proc_param_init=<optimized out>, select_lex_arg=<optimized out>, unit_arg=<optimized out>) at /test/10.8_dbg/sql/sql_select.cc:1403
            #17 0x0000564995ede0df in subselect_single_select_engine::prepare (this=0x149600017108, thd=0x149600000db8) at /test/10.8_dbg/sql/sql_lex.h:1363
            #18 0x0000564995edd503 in Item_subselect::fix_fields (this=0x149600016f80, thd_param=<optimized out>, ref=0x149600017150) at /test/10.8_dbg/sql/item_subselect.cc:295
            #19 0x0000564995a3230c in Item::fix_fields_if_needed (ref=0x149600017150, thd=0x149600000db8, this=0x149600016f80) at /test/10.8_dbg/sql/item.h:1148
            #20 Item::fix_fields_if_needed_for_scalar (ref=0x149600017150, thd=0x149600000db8, this=0x149600016f80) at /test/10.8_dbg/sql/item.h:1148
            #21 setup_fields (thd=0x149600000db8, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x149600025d50, pre_fix=0x149600014180, allow_sum_func=true) at /test/10.8_dbg/sql/sql_base.cc:7716
            #22 0x0000564995b408ab in JOIN::prepare (this=this@entry=0x1496000259e8, tables_init=tables_init@entry=0x149600017230, conds_init=conds_init@entry=0x0, og_num=og_num@entry=1, order_init=order_init@entry=0x0, skip_order_by=skip_order_by@entry=false, group_init=0x149600017a48, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x149600013ec8, unit_arg=0x1496000051c0) at /test/10.8_dbg/sql/sql_select.cc:1397
            #23 0x0000564995b59acf in mysql_select (thd=thd@entry=0x149600000db8, tables=0x149600017230, fields=@0x149600014168: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149600017148, last = 0x149600017148, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x149600017a48, having=0x0, proc_param=0x0, select_options=2147748608, result=0x149600017bf8, unit=0x1496000051c0, select_lex=0x149600013ec8) at /test/10.8_dbg/sql/sql_select.cc:4968
            #24 0x0000564995b59df6 in handle_select (thd=thd@entry=0x149600000db8, lex=lex@entry=0x1496000050e8, result=result@entry=0x149600017bf8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.8_dbg/sql/sql_select.cc:545
            #25 0x0000564995ab8abc in execute_sqlcom_select (thd=thd@entry=0x149600000db8, all_tables=0x149600017230) at /test/10.8_dbg/sql/sql_parse.cc:6253
            #26 0x0000564995ac59e3 in mysql_execute_command (thd=thd@entry=0x149600000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.8_dbg/sql/sql_parse.cc:3944
            #27 0x0000564995ab1cad in mysql_parse (thd=thd@entry=0x149600000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14964868a400) at /test/10.8_dbg/sql/sql_parse.cc:8028
            #28 0x0000564995ac0949 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x149600000db8, packet=packet@entry=0x14960000b879 "SELECT (SELECT a FROM (SELECT 0 FROM t0) e ORDER BY (@f:=a)) FROM t0 GROUP BY a", packet_length=packet_length@entry=79, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1360
            #29 0x0000564995ac3d83 in do_command (thd=0x149600000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402
            #30 0x0000564995c3de2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x564999718f38, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418
            #31 0x0000564995c3e42f in handle_one_connection (arg=arg@entry=0x564999718f38) at /test/10.8_dbg/sql/sql_connect.cc:1312
            #32 0x00005649960be4ce in pfs_spawn_thread (arg=0x56499962d568) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201
            #33 0x000014964c779609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #34 0x000014964c367293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.2.42 (dbg), 10.3.33 (dbg), 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.0 (dbg)
            MySQL: 5.5.62 (dbg)

            Bug (or feature/syntax) confirmed not present in:
            MariaDB: 10.2.42 (opt), 10.3.33 (opt), 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.0 (opt)
            MySQL: 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

            Roel Roel Van de Paar added a comment - CREATE TABLE t0 (a INT , PRIMARY KEY (a)); SELECT ( SELECT a FROM ( SELECT 0 FROM t0) e ORDER BY (@f:=a)) FROM t0 GROUP BY a; Leads to: 10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug) mysqld: /test/10.8_dbg/sql/item.cc:5517: Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*): Assertion `(*select_ref)->fixed()' failed. 10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug) Core was generated by `/test/MD121121-mariadb-10.8.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 0x14964868b700 (LWP 85041))] (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x000014964c26a859 in __GI_abort () at abort.c:79 #2 0x000014964c26a729 in __assert_fail_base (fmt=0x14964c400588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56499692cd89 "(*select_ref)->fixed()", file=0x56499692cb7c "/test/10.8_dbg/sql/item.cc", line=5517, function=<optimized out>) at assert.c:92 #3 0x000014964c27bf36 in __GI___assert_fail (assertion=assertion@entry=0x56499692cd89 "(*select_ref)->fixed()", file=file@entry=0x56499692cb7c "/test/10.8_dbg/sql/item.cc", line=line@entry=5517, function=function@entry=0x56499692e0e0 "Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*)") at assert.c:101 #4 0x0000564995de6a26 in resolve_ref_in_select_and_group (thd=thd@entry=0x149600000db8, ref=ref@entry=0x149600026fa8, select=<optimized out>) at /test/10.8_dbg/sql/item.h:1069 #5 0x0000564995dfd011 in Item_ref::fix_fields (this=0x149600026fa8, thd=0x149600000db8, reference=0x1496486890b8) at /test/10.8_dbg/sql/item.cc:7997 #6 0x0000564995dfc715 in Item_field::fix_fields (this=0x149600016c70, thd=0x149600000db8, reference=0x149600016e00) at /test/10.8_dbg/sql/item.cc:6072 #7 0x0000564995e50f2e in Item::fix_fields_if_needed (ref=0x149600016e00, thd=0x149600000db8, this=<optimized out>) at /test/10.8_dbg/sql/item.h:1144 #8 Item_func::fix_fields (this=this@entry=0x149600016d88, thd=thd@entry=0x149600000db8, ref=ref@entry=0x149600016f08) at /test/10.8_dbg/sql/item_func.cc:347 #9 0x0000564995e6c540 in Item_func_set_user_var::fix_fields (this=0x149600016d88, thd=0x149600000db8, ref=0x149600016f08) at /test/10.8_dbg/sql/item_func.cc:4714 #10 0x0000564995b0d7b2 in Item::fix_fields_if_needed (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1156 #11 Item::fix_fields_if_needed_for_scalar (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1148 #12 Item::fix_fields_if_needed_for_order_by (ref=<optimized out>, thd=0x149600000db8, this=0x149600016d88) at /test/10.8_dbg/sql/item.h:1156 #13 find_order_in_list (thd=thd@entry=0x149600000db8, ref_pointer_array=<optimized out>, tables=tables@entry=0x149600015d68, order=order@entry=0x149600016ef8, fields=@0x1496000145e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, is_group_field=false, add_to_all_fields=true, from_window_spec=false) at /test/10.8_dbg/sql/sql_select.cc:24987 #14 0x0000564995b3c3a3 in setup_order (thd=thd@entry=0x149600000db8, ref_pointer_array=<optimized out>, tables=tables@entry=0x149600015d68, fields=@0x1496000145e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, order=0x149600016ef8, from_window_spec=false) at /test/10.8_dbg/sql/sql_select.cc:25034 #15 0x0000564995b40c7e in setup_without_group (reserved=<optimized out>, hidden_group_fields=0x1496000262c7, win_funcs=<optimized out>, win_specs=<optimized out>, group=<optimized out>, order=<optimized out>, conds=0x149600026400, all_fields=@0x149600026318: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1496000148d8, last = 0x1496000148d8, elements = 1}, <No data fields>}, fields=<optimized out>, leaves=<optimized out>, tables=<optimized out>, ref_pointer_array=<optimized out>, thd=<optimized out>) at /test/10.8_dbg/sql/sql_select.cc:849 #16 JOIN::prepare (this=0x149600025fb0, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=<optimized out>, having_init=<optimized out>, proc_param_init=<optimized out>, select_lex_arg=<optimized out>, unit_arg=<optimized out>) at /test/10.8_dbg/sql/sql_select.cc:1403 #17 0x0000564995ede0df in subselect_single_select_engine::prepare (this=0x149600017108, thd=0x149600000db8) at /test/10.8_dbg/sql/sql_lex.h:1363 #18 0x0000564995edd503 in Item_subselect::fix_fields (this=0x149600016f80, thd_param=<optimized out>, ref=0x149600017150) at /test/10.8_dbg/sql/item_subselect.cc:295 #19 0x0000564995a3230c in Item::fix_fields_if_needed (ref=0x149600017150, thd=0x149600000db8, this=0x149600016f80) at /test/10.8_dbg/sql/item.h:1148 #20 Item::fix_fields_if_needed_for_scalar (ref=0x149600017150, thd=0x149600000db8, this=0x149600016f80) at /test/10.8_dbg/sql/item.h:1148 #21 setup_fields (thd=0x149600000db8, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x149600025d50, pre_fix=0x149600014180, allow_sum_func=true) at /test/10.8_dbg/sql/sql_base.cc:7716 #22 0x0000564995b408ab in JOIN::prepare (this=this@entry=0x1496000259e8, tables_init=tables_init@entry=0x149600017230, conds_init=conds_init@entry=0x0, og_num=og_num@entry=1, order_init=order_init@entry=0x0, skip_order_by=skip_order_by@entry=false, group_init=0x149600017a48, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x149600013ec8, unit_arg=0x1496000051c0) at /test/10.8_dbg/sql/sql_select.cc:1397 #23 0x0000564995b59acf in mysql_select (thd=thd@entry=0x149600000db8, tables=0x149600017230, fields=@0x149600014168: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149600017148, last = 0x149600017148, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x149600017a48, having=0x0, proc_param=0x0, select_options=2147748608, result=0x149600017bf8, unit=0x1496000051c0, select_lex=0x149600013ec8) at /test/10.8_dbg/sql/sql_select.cc:4968 #24 0x0000564995b59df6 in handle_select (thd=thd@entry=0x149600000db8, lex=lex@entry=0x1496000050e8, result=result@entry=0x149600017bf8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.8_dbg/sql/sql_select.cc:545 #25 0x0000564995ab8abc in execute_sqlcom_select (thd=thd@entry=0x149600000db8, all_tables=0x149600017230) at /test/10.8_dbg/sql/sql_parse.cc:6253 #26 0x0000564995ac59e3 in mysql_execute_command (thd=thd@entry=0x149600000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.8_dbg/sql/sql_parse.cc:3944 #27 0x0000564995ab1cad in mysql_parse (thd=thd@entry=0x149600000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14964868a400) at /test/10.8_dbg/sql/sql_parse.cc:8028 #28 0x0000564995ac0949 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x149600000db8, packet=packet@entry=0x14960000b879 "SELECT (SELECT a FROM (SELECT 0 FROM t0) e ORDER BY (@f:=a)) FROM t0 GROUP BY a", packet_length=packet_length@entry=79, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1360 #29 0x0000564995ac3d83 in do_command (thd=0x149600000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402 #30 0x0000564995c3de2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x564999718f38, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418 #31 0x0000564995c3e42f in handle_one_connection (arg=arg@entry=0x564999718f38) at /test/10.8_dbg/sql/sql_connect.cc:1312 #32 0x00005649960be4ce in pfs_spawn_thread (arg=0x56499962d568) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201 #33 0x000014964c779609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #34 0x000014964c367293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.2.42 (dbg), 10.3.33 (dbg), 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.0 (dbg) MySQL: 5.5.62 (dbg) Bug (or feature/syntax) confirmed not present in: MariaDB: 10.2.42 (opt), 10.3.33 (opt), 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.0 (opt) MySQL: 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

            Looks like an issue in Name Resolution.

            psergei Sergei Petrunia added a comment - Looks like an issue in Name Resolution.

            CREATE TABLE t(a INT KEY);
            SELECT(SELECT a FROM (SELECT 1)e ORDER BY (@f:=a)) FROM t GROUP BY a;
            

            Can produce the following addtional stacks on UBASAN Clang builds:

            (*select_ref)->fixed()|SIGABRT|resolve_ref_in_select_and_group|Item_ref::fix_fields|Item_field::fix_fields|Item_func::fix_fields
            (*select_ref)->is_fixed()|SIGABRT|resolve_ref_in_select_and_group|Item_ref::fix_fields|Item_field::fix_fields|Item_func::fix_fields
            

            Roel Roel Van de Paar added a comment - CREATE TABLE t(a INT KEY ); SELECT ( SELECT a FROM ( SELECT 1)e ORDER BY (@f:=a)) FROM t GROUP BY a; Can produce the following addtional stacks on UBASAN Clang builds: (*select_ref)->fixed()|SIGABRT|resolve_ref_in_select_and_group|Item_ref::fix_fields|Item_field::fix_fields|Item_func::fix_fields (*select_ref)->is_fixed()|SIGABRT|resolve_ref_in_select_and_group|Item_ref::fix_fields|Item_field::fix_fields|Item_func::fix_fields
            alice Alice Sherepa added a comment -

            please check also test, derived from MDEV-36428:
            in case it's different (involves window functions) - move to MDEV-28506

            CREATE TABLE t ( a int ) ;
            SELECT EXISTS (SELECT a AS B , sum(a) over (partition BY a ORDER BY a + a ^ -1 )) FROM t GROUP BY a ;
            

            Version: '10.5.29-MariaDB-debug-log'  
             
            mariadbd: /10.5/src/sql/item.cc:5681: Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*): Assertion `(*select_ref)->is_fixed()' failed.
            250331 10:58:31 [ERROR] /10.5/bld/sql/mariadbd got signal 6 ;
             
            Server version: 10.5.29-MariaDB-debug-log source revision: 2469963f052b4dcb11ecfc0fcf5a38881c426df0
             
            /lib/x86_64-linux-gnu/libc.so.6(+0x33fd6)[0x7f0f77407fd6]
            sql/item.cc:5682(resolve_ref_in_select_and_group(THD*, Item_ident*, st_select_lex*))[0x55a18e301950]
            sql/item.cc:8177(Item_ref::fix_fields(THD*, Item**))[0x55a18e314a30]
            sql/item.cc:6224(Item_field::fix_fields(THD*, Item**))[0x55a18e305fab]
            sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313]
            sql/item_func.cc:365(Item_func::fix_fields(THD*, Item**))[0x55a18e3df118]
            sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313]
            sql/item.h:1009(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x55a18d72634d]
            sql/item.h:1018(Item::fix_fields_if_needed_for_order_by(THD*, Item**))[0x55a18db94509]
            sql/sql_select.cc:25398(find_order_in_list(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, st_order*, List<Item>&, List<Item>&, bool, bool, bool))[0x55a18db65d71]
            sql/sql_select.cc:25445(setup_order(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, st_order*, bool))[0x55a18db66312]
            sql/sql_window.cc:247(setup_windows(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, List<Window_spec>&, List<Item_window_func>&))[0x55a18e078ba8]
            sql/sql_select.cc:788(setup_without_group(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<TABLE_LIST>&, List<Item>&, List<Item>&, Item**, st_order*, st_order*, List<Window_spec>&, List<Item_window_func>&, bool*))[0x55a18daa1ff7]
            sql/sql_select.cc:1380(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x55a18daa9b70]
            sql/item_subselect.cc:3883(subselect_single_select_engine::prepare(THD*))[0x55a18e4f2d1a]
            sql/item_subselect.cc:293(Item_subselect::fix_fields(THD*, Item**))[0x55a18e4ca873]
            sql/item_subselect.cc:3459(Item_exists_subselect::fix_fields(THD*, Item**))[0x55a18e4eeb58]
            sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313]
            sql/item.h:1009(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x55a18d72634d]
            sql/sql_base.cc:7693(setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool))[0x55a18d85c88f]
            sql/sql_select.cc:1375(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x55a18daa9848]
            sql/sql_select.cc:4897(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55a18dad025c]
            sql/sql_select.cc:449(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55a18da9f944]
            sql/sql_parse.cc:6452(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55a18da006c7]
            sql/sql_parse.cc:4043(mysql_execute_command(THD*))[0x55a18d9eeadc]
            sql/sql_parse.cc:8252(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55a18da0ba95]
            sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55a18d9e02e2]
            sql/sql_parse.cc:1375(do_command(THD*))[0x55a18d9dcbbc]
            sql/sql_connect.cc:1386(do_handle_one_connection(CONNECT*, bool))[0x55a18de537b6]
            sql/sql_connect.cc:1300(handle_one_connection)[0x55a18de53310]
            perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55a18eb13846]
            nptl/pthread_create.c:478(start_thread)[0x7f0f779b8609]
             
            Status: NOT_KILLED
            Query (0x62b0000852a8): SELECT EXISTS (SELECT a AS B , sum(a) over (partition BY a ORDER BY a + a ^ -1 )) FROM t GROUP BY a
            

            alice Alice Sherepa added a comment - please check also test, derived from MDEV-36428 : in case it's different (involves window functions) - move to MDEV-28506 CREATE TABLE t ( a int ) ; SELECT EXISTS ( SELECT a AS B , sum (a) over (partition BY a ORDER BY a + a ^ -1 )) FROM t GROUP BY a ; Version: '10.5.29-MariaDB-debug-log'   mariadbd: /10.5/src/sql/item.cc:5681: Item** resolve_ref_in_select_and_group(THD*, Item_ident*, SELECT_LEX*): Assertion `(*select_ref)->is_fixed()' failed. 250331 10:58:31 [ERROR] /10.5/bld/sql/mariadbd got signal 6 ;   Server version: 10.5.29-MariaDB-debug-log source revision: 2469963f052b4dcb11ecfc0fcf5a38881c426df0   /lib/x86_64-linux-gnu/libc.so.6(+0x33fd6)[0x7f0f77407fd6] sql/item.cc:5682(resolve_ref_in_select_and_group(THD*, Item_ident*, st_select_lex*))[0x55a18e301950] sql/item.cc:8177(Item_ref::fix_fields(THD*, Item**))[0x55a18e314a30] sql/item.cc:6224(Item_field::fix_fields(THD*, Item**))[0x55a18e305fab] sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313] sql/item_func.cc:365(Item_func::fix_fields(THD*, Item**))[0x55a18e3df118] sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313] sql/item.h:1009(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x55a18d72634d] sql/item.h:1018(Item::fix_fields_if_needed_for_order_by(THD*, Item**))[0x55a18db94509] sql/sql_select.cc:25398(find_order_in_list(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, st_order*, List<Item>&, List<Item>&, bool, bool, bool))[0x55a18db65d71] sql/sql_select.cc:25445(setup_order(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, st_order*, bool))[0x55a18db66312] sql/sql_window.cc:247(setup_windows(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, List<Window_spec>&, List<Item_window_func>&))[0x55a18e078ba8] sql/sql_select.cc:788(setup_without_group(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<TABLE_LIST>&, List<Item>&, List<Item>&, Item**, st_order*, st_order*, List<Window_spec>&, List<Item_window_func>&, bool*))[0x55a18daa1ff7] sql/sql_select.cc:1380(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x55a18daa9b70] sql/item_subselect.cc:3883(subselect_single_select_engine::prepare(THD*))[0x55a18e4f2d1a] sql/item_subselect.cc:293(Item_subselect::fix_fields(THD*, Item**))[0x55a18e4ca873] sql/item_subselect.cc:3459(Item_exists_subselect::fix_fields(THD*, Item**))[0x55a18e4eeb58] sql/item.h:1005(Item::fix_fields_if_needed(THD*, Item**))[0x55a18d726313] sql/item.h:1009(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x55a18d72634d] sql/sql_base.cc:7693(setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool))[0x55a18d85c88f] sql/sql_select.cc:1375(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x55a18daa9848] sql/sql_select.cc:4897(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55a18dad025c] sql/sql_select.cc:449(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55a18da9f944] sql/sql_parse.cc:6452(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55a18da006c7] sql/sql_parse.cc:4043(mysql_execute_command(THD*))[0x55a18d9eeadc] sql/sql_parse.cc:8252(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55a18da0ba95] sql/sql_parse.cc:1894(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55a18d9e02e2] sql/sql_parse.cc:1375(do_command(THD*))[0x55a18d9dcbbc] sql/sql_connect.cc:1386(do_handle_one_connection(CONNECT*, bool))[0x55a18de537b6] sql/sql_connect.cc:1300(handle_one_connection)[0x55a18de53310] perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55a18eb13846] nptl/pthread_create.c:478(start_thread)[0x7f0f779b8609]   Status: NOT_KILLED Query (0x62b0000852a8): SELECT EXISTS (SELECT a AS B , sum(a) over (partition BY a ORDER BY a + a ^ -1 )) FROM t GROUP BY a

            People

              sanja Oleksandr Byelkin
              Roel Roel Van de Paar
              Votes:
              1 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.