[MDEV-23221] A subquery causes crash Created: 2020-07-19  Updated: 2021-04-19  Resolved: 2020-07-24

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4
Fix Version/s: 10.1.46, 10.2.33, 10.3.24, 10.4.14, 10.5.5

Type: Bug Priority: Major
Reporter: Sergei Petrunia Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-20557 SQL query with duplicate table aliase... Closed

 Description   

The following example causes a crash:

create or replace database crashTest;
use crashTest;

create or replace table location (
location_code varchar(10),
country_id varchar(10)
);
insert into location values ('HKG', 'HK');
insert into location values ('NYC', 'US');
insert into location values ('LAX', 'US');

create or replace table cntr_leg (
container_id varchar(10),
cntr_activity_type varchar(10),
cntr_dest varchar(10)
);
insert into cntr_leg values ('AAAA1111', 'VSL', 'NYC');
insert into cntr_leg values ('AAAA1111', 'CUV', 'NYC');
insert into cntr_leg values ('BBBB2222', 'VSL', 'LAX');
insert into cntr_leg values ('BBBB2222', 'XYZ', 'LAX');

select
  (select country_id from location where location_code = cl1.cntr_dest) as dest_cntry,
  (select 
     max(container_id) 
   from cntr_leg as cl2 
   where
    cl2.container_id = cl1.container_id and
    cl2.cntr_activity_type = 'CUV' and
    exists (select location_code 
            from location 
            where 
               location_code = cl2.cntr_dest and 
               country_id = dest_cntry)
   ) as CUV
from
  cntr_leg cl1;

Crashes as follows:

  [New Thread 0x7fffd979a700 (LWP 3851)]
  mysqld: /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:953: virtual bool Item_subselect::const_item() const: Assertion `thd' failed.
  
  Thread 34 "mysqld" received signal SIGABRT, Aborted.
  [Switching to Thread 0x7fffd979a700 (LWP 3851)]
  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
  51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) wher
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
  #1  0x00007ffff52258b1 in __GI_abort () at abort.c:79
  #2  0x00007ffff521542a in __assert_fail_base (fmt=0x7ffff539ca38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555556c0b3d6 "thd", file=file@entry=0x555556c0b0a0 "/home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc", line=line@entry=953, function=function@entry=0x555556c0cf80 <Item_subselect::const_item() const::__PRETTY_FUNCTION__> "virtual bool Item_subselect::const_item() const") at assert.c:92
  #3  0x00007ffff52154a2 in __GI___assert_fail (assertion=0x555556c0b3d6 "thd", file=0x555556c0b0a0 "/home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc", line=953, function=0x555556c0cf80 <Item_subselect::const_item() const::__PRETTY_FUNCTION__> "virtual bool Item_subselect::const_item() const") at assert.c:101
  #4  0x00005555561a43bc in Item_subselect::const_item (this=0x7fff680c44e8) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:953
  #5  0x00005555561b836a in Item_in_subselect::const_item (this=0x7fff680c44e8) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.h:642
  #6  0x0000555555cdc65c in Used_tables_and_const_cache::used_tables_and_const_cache_join (this=0x7fff680bce78, item=0x7fff680c44e8) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5020
  #7  0x0000555555cdc6ba in Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (this=0x7fff680bce78, item=0x7fff680c44e8) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5025
  #8  0x0000555555cdc704 in Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (this=0x7fff680bce78, argc=2, argv=0x7fff680bce60) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5036
  #9  0x0000555555cddcb8 in Item_func::update_used_tables (this=0x7fff680bcdd0) at /home/psergey/dev-git/10.4-cl2/sql/item_func.h:160
  #10 0x0000555555cdc6a7 in Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (this=0x7fff68015c00, item=0x7fff680bcdd0) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5024
  #11 0x0000555556124b75 in Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join (this=0x7fff68015c00, list=...) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5049
  #12 0x0000555556129390 in Item_cond::update_used_tables (this=0x7fff68015b58) at /home/psergey/dev-git/10.4-cl2/sql/item_cmpfunc.h:2993
  #13 0x0000555555d3be12 in st_select_lex::update_used_tables (this=0x7fff68014488) at /home/psergey/dev-git/10.4-cl2/sql/sql_lex.cc:4598
  #14 0x0000555555d3b150 in st_select_lex::optimize_unflattened_subqueries (this=0x7fff680124d8, const_only=false) at /home/psergey/dev-git/10.4-cl2/sql/sql_lex.cc:4202
  #15 0x0000555555f5a444 in JOIN::optimize_unflattened_subqueries (this=0x7fff680ba858) at /home/psergey/dev-git/10.4-cl2/sql/opt_subselect.cc:5520
  #16 0x0000555555db99db in JOIN::optimize_stage2 (this=0x7fff680ba858) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:2833
  #17 0x0000555555db7956 in JOIN::optimize_inner (this=0x7fff680ba858) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:2289
  #18 0x0000555555db51a2 in JOIN::optimize (this=0x7fff680ba858) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:1610
  #19 0x0000555555dc064a in mysql_select (thd=0x7fff68000d50, tables=0x7fff680b99a0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fff68018100, unit=0x7fff68004c78, select_lex=0x7fff680124d8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:4673
  #20 0x0000555555db01b5 in handle_select (thd=0x7fff68000d50, lex=0x7fff68004bb8, result=0x7fff68018100, setup_tables_done_option=0) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:410
  #21 0x0000555555d76ae1 in execute_sqlcom_select (thd=0x7fff68000d50, all_tables=0x7fff680b99a0) at /home/psergey/dev-git/10.4-cl2/sql/sql_parse.cc:6358
  #22 0x0000555555d6d10c in mysql_execute_command (thd=0x7fff68000d50) at /home/psergey/dev-git/10.4-cl2/sql/sql_parse.cc:3890
  #23 0x0000555555d7aa7f in mysql_parse (thd=0x7fff68000d50, rawbuf=0x7fff680121a8 "select\n(select country_id from location where location_code = cl1.cntr_dest) as dest_cntry,\n\n(select max(container_id) from cntr_leg as cl2 where\ncl2.container_id = cl1.container_id and\ncl2.cntr_activ"..., length=353, parser_state=0x7fffd9799550, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.4-cl2/sql/sql_parse.cc:7899

Stack trace from the original report :

Server version: 10.4.11-MariaDB
...
Thread pointer: 0xb4fd85a738
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
mysqld.exe!Item_subselect::const_item()[item_subselect.cc:954]
mysqld.exe!Item_in_subselect::const_item()[item_subselect.h:642]
mysqld.exe!Used_tables_and_const_cache::used_tables_and_const_cache_update_and_join()[item.h:4982]
mysqld.exe!Item_cond::update_used_tables()[item_cmpfunc.h:2992]
mysqld.exe!st_select_lex::update_used_tables()[sql_lex.cc:4586]
mysqld.exe!st_select_lex::optimize_unflattened_subqueries()[sql_lex.cc:4190]
mysqld.exe!JOIN::optimize_stage2()[sql_select.cc:2810]
mysqld.exe!JOIN::optimize_inner()[sql_select.cc:2274]
mysqld.exe!JOIN::optimize()[sql_select.cc:1600]
mysqld.exe!mysql_select()[sql_select.cc:4646]
mysqld.exe!handle_select()[sql_select.cc:408]
mysqld.exe!execute_sqlcom_select()[sql_parse.cc:6360]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3899]
mysqld.exe!mysql_parse()[sql_parse.cc:7906]
mysqld.exe!dispatch_command()[sql_parse.cc:1844]
mysqld.exe!do_command()[sql_parse.cc:1359]
mysqld.exe!threadpool_process_request()[threadpool_common.cc:366]
mysqld.exe!tp_callback()[threadpool_common.cc:193]
ntdll.dll!RtlFreeUnicodeString()
ntdll.dll!RtlFreeUnicodeString()
KERNEL32.DLL!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()



 Comments   
Comment by Sergei Petrunia [ 2020-07-19 ]

The failing assert is here:

bool Item_subselect::const_item() const
{
  DBUG_ASSERT(thd);

We get thd==NULL.
It is assigned in Item_subselect constructor.
It is set to a non-NULL value in fix_fields(). However the object for which the
assertion has failed (that is, *this) has fixed=false.

Put a breakpoint in Item_subselect::Item_subselect
Start debugging the query, stop at the 4th breakpoint hit.

(gdb) wher
  #0  Item_subselect::Item_subselect (this=0x7fff6c01fd60, thd_arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:59
  #1  0x00005555561b805d in Item_exists_subselect::Item_exists_subselect (this=0x7fff6c01fd60, thd_arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.h:394
  #2  0x00005555561a63ca in Item_in_subselect::Item_in_subselect (this=0x7fff6c01fd60, thd=0x7fff6c000d50, left_exp=0x7fff6c01fca0, select_lex=0x7fff6c017e68) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:1487
  #3  0x00005555561ad4b5 in Item_exists_subselect::exists2in_processor (this=0x7fff6c019d70, opt_arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:3056
  #4  0x00005555561a3939 in Item_subselect::walk (this=0x7fff6c019d70, processor=&virtual table offset 1024, walk_subquery=false, argument=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item_subselect.cc:712
  #5  0x0000555555cdc27f in Item_args::walk_args (this=0x7fff6c01e158, processor=&virtual table offset 1024, walk_subquery=false, arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item.h:2555
  #6  0x0000555555cdc863 in Item_func_or_sum::walk (this=0x7fff6c01e0d0, processor=&virtual table offset 1024, walk_subquery=false, arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item.h:5147
  #7  0x000055555611c439 in Item_cond::walk (this=0x7fff6c017d30, processor=&virtual table offset 1024, walk_subquery=false, arg=0x7fff6c000d50) at /home/psergey/dev-git/10.4-cl2/sql/item_cmpfunc.cc:4984
  #8  0x0000555555db5e05 in JOIN::optimize_inner (this=0x7fff6c01cbf8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:1845
  #9  0x0000555555db51a2 in JOIN::optimize (this=0x7fff6c01cbf8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:1610
  #10 0x0000555555d3b12f in st_select_lex::optimize_unflattened_subqueries (this=0x7fff6c0146b0, const_only=false) at /home/psergey/dev-git/10.4-cl2/sql/sql_lex.cc:4200
  #11 0x0000555555f5a444 in JOIN::optimize_unflattened_subqueries (this=0x7fff6c01bae8) at /home/psergey/dev-git/10.4-cl2/sql/opt_subselect.cc:5520
  #12 0x0000555555db99db in JOIN::optimize_stage2 (this=0x7fff6c01bae8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:2833
  #13 0x0000555555db7956 in JOIN::optimize_inner (this=0x7fff6c01bae8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:2289
  #14 0x0000555555db51a2 in JOIN::optimize (this=0x7fff6c01bae8) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:1610
  #15 0x0000555555dc064a in mysql_select (thd=0x7fff6c000d50, tables=0x7fff6c01ab60, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fff6c01bac0, unit=0x7fff6c004c78, select_lex=0x7fff6c0146b0) at /home/psergey/dev-git/10.4-cl2/sql/sql_select.cc:4673

Let's continue execution until we're back in Item_exists_subselect::exists2in_processor
Here, we get an error condition here:

    if (optimizer->fix_left(thd))

We exit up to the st_select_lex::optimize_unflattened_subqueries() (frame #10):

        res= inner_join->optimize();
        if (!inner_join->cleaned)
          sl->update_used_tables();

The first line above is the call we've left.
The last line is where we crash. I am not sure if it's spelled explicitly
somewhere but it seems fairly obvious that one must not call update_used_tables()
for items for which fix_fields() call didn't finish successfully.

Comment by Sergei Petrunia [ 2020-07-19 ]

diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index eb22534f4fb..90f9ea70851 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4197,7 +4197,8 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
           sl->options|= SELECT_DESCRIBE;
           inner_join->select_options|= SELECT_DESCRIBE;
         }
-        res= inner_join->optimize();
+        if ((res= inner_join->optimize()))
+          return TRUE;
         if (!inner_join->cleaned)
           sl->update_used_tables();
         sl->update_correlated_cache();

This makes the crash go away.

Comment by Sergei Petrunia [ 2020-07-19 ]

... but now the query returns this error:

ERROR 1235 (42000): This version of MariaDB doesn't yet support 'SUBQUERY in ROW in left expression of IN/ALL/ANY'

which seems incorrect as the query doesn't have the properties described.

Comment by Sergei Petrunia [ 2020-07-20 ]

http://lists.askmonty.org/pipermail/commits/2020-July/014289.html.

sanja, please review. Which version should this go into? EXISTS-to-IN was introduced into 10.0, but 10.0 was EOLed... 10.1?

Comment by Elena Stepanova [ 2020-07-20 ]

Looks like a duplicate of MDEV-20557.

Comment by Oleksandr Byelkin [ 2020-07-21 ]

OK to push

Comment by Sergei Petrunia [ 2020-07-24 ]

The fix will go into 10.1 (and subsequent versions)

Comment by Sergei Petrunia [ 2020-07-24 ]

Attempt to apply the patch to 10.1 causes this:

  mysqld: /home/psergey/dev-git/10.1/sql/item_subselect.cc:6750: void Item_subselect::init_expr_cache_tracker(THD*): Assertion `qw' failed.
  
  Thread 29 "mysqld" received signal SIGABRT, Aborted.

  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
  #1  0x00007ffff5b6a8b1 in __GI_abort () at abort.c:79
  #2  0x00007ffff5b5a42a in __assert_fail_base (fmt=0x7ffff5ce1a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5555564761dc "qw", file=file@entry=0x555556474b80 "/home/psergey/dev-git/10.1/sql/item_subselect.cc", line=line@entry=6750, function=function@entry=0x555556477d80 <Item_subselect::init_expr_cache_tracker(THD*)::__PRETTY_FUNCTION__> "void Item_subselect::init_expr_cache_tracker(THD*)") at assert.c:92
  #3  0x00007ffff5b5a4a2 in __GI___assert_fail (assertion=0x5555564761dc "qw", file=0x555556474b80 "/home/psergey/dev-git/10.1/sql/item_subselect.cc", line=6750, function=0x555556477d80 <Item_subselect::init_expr_cache_tracker(THD*)::__PRETTY_FUNCTION__> "void Item_subselect::init_expr_cache_tracker(THD*)") at assert.c:101
  #4  0x0000555555d33aeb in Item_subselect::init_expr_cache_tracker (this=0x7ffeba022a00, thd=0x7ffeb6b88070) at /home/psergey/dev-git/10.1/sql/item_subselect.cc:6750
  #5  0x0000555555d252b1 in Item_singlerow_subselect::expr_cache_insert_transformer (this=0x7ffeba022a00, tmp_thd=0x7ffeb6b88070, unused=0x0) at /home/psergey/dev-git/10.1/sql/item_subselect.cc:1249
  #6  0x0000555555c9617e in Item::transform (this=0x7ffeba022a00, thd=0x7ffeb6b88070, transformer=&virtual Item::expr_cache_insert_transformer(THD*, unsigned char*), arg=0x0) at /home/psergey/dev-git/10.1/sql/item.cc:745
  #7  0x0000555555ca6df7 in Item_ref::transform (this=0x7ffeba135f20, thd=0x7ffeb6b88070, transformer=&virtual Item::expr_cache_insert_transformer(THD*, unsigned char*), arg=0x0) at /home/psergey/dev-git/10.1/sql/item.cc:7098
  #8  0x0000555555ce5811 in Item_args::transform_args (this=0x7ffeba025f18, thd=0x7ffeb6b88070, transformer=&virtual table offset 1056, arg=0x0) at /home/psergey/dev-git/10.1/sql/item_func.cc:319
  #9  0x0000555555ce58f0 in Item_func::transform (this=0x7ffeba025e90, thd=0x7ffeb6b88070, transformer=&virtual table offset 1056, argument=0x0) at /home/psergey/dev-git/10.1/sql/item_func.cc:355
  #10 0x0000555555cc3a0e in Item_cond::transform (this=0x7ffeba1393f0, thd=0x7ffeb6b88070, transformer=&virtual table offset 1056, arg=0x0) at /home/psergey/dev-git/10.1/sql/item_cmpfunc.cc:4843
  #11 0x0000555555a82ce1 in JOIN::setup_subquery_caches (this=0x7ffeba134cc8) at /home/psergey/dev-git/10.1/sql/sql_select.cc:2263
  #12 0x0000555555a815df in JOIN::optimize_inner (this=0x7ffeba134cc8) at /home/psergey/dev-git/10.1/sql/sql_select.cc:1855
  #13 0x0000555555a7e858 in JOIN::optimize (this=0x7ffeba134cc8) at /home/psergey/dev-git/10.1/sql/sql_select.cc:1059
  #14 0x0000555555a358c5 in st_select_lex::optimize_unflattened_subqueries (this=0x7ffeb6b8c2c0, const_only=false) at /home/psergey/dev-git/10.1/sql/sql_lex.cc:3805
  #15 0x0000555555bd5d9c in JOIN::optimize_unflattened_subqueries (this=0x7ffeba134088) at /home/psergey/dev-git/10.1/sql/opt_subselect.cc:5334
  #16 0x0000555555a81584 in JOIN::optimize_inner (this=0x7ffeba134088) at /home/psergey/dev-git/10.1/sql/sql_select.cc:1849
  #17 0x0000555555a7e858 in JOIN::optimize (this=0x7ffeba134088) at /home/psergey/dev-git/10.1/sql/sql_select.cc:1059
  #18 0x0000555555a8712d in mysql_select (thd=0x7ffeb6b88070, rref_pointer_array=0x7ffeb6b8c568, tables=0x7ffeba0264c0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7ffeba026bf8, unit=0x7ffeb6b8bbb8, select_lex=0x7ffeb6b8c2c0) at /home/psergey/dev-git/10.1/sql/sql_select.cc:3487
  #19 0x0000555555a7c922 in handle_select (thd=0x7ffeb6b88070, lex=0x7ffeb6b8baf8, result=0x7ffeba026bf8, setup_tables_done_option=0) at /home/psergey/dev-git/10.1/sql/sql_select.cc:377
  #20 0x0000555555a4c390 in execute_sqlcom_select (thd=0x7ffeb6b88070, all_tables=0x7ffeba0264c0) at /home/psergey/dev-git/10.1/sql/sql_parse.cc:5682
  #21 0x0000555555a43055 in mysql_execute_command (thd=0x7ffeb6b88070) at /home/psergey/dev-git/10.1/sql/sql_parse.cc:3029
  #22 0x0000555555a4fea8 in mysql_parse (thd=0x7ffeb6b88070, rawbuf=0x7ffeba021088 "select\n  (select country_id from location where location_code = cl1.cntr_dest) as dest_cntry,\n  (select \n     max(container_id) \n   from cntr_leg as cl2 \n   where\n    cl2.container_id = cl1.container_"..., length=447, parser_state=0x7ffff7ed35e0) at /home/psergey/dev-git/10.1/sql/sql_parse.cc:7200

Comment by Sergei Petrunia [ 2020-07-24 ]

Basically, Item_subselect::init_expr_cache_tracker fails, because the Explain Data Structure is not yet created for the query.

On 10.3, we also enter Item_subselect::init_expr_cache_tracker , but the Explain Data Structure is already present as it has been created here:

  #0  create_explain_query (lex=0x7fff60004b58, mem_root=0x7fff60006298) at /home/psergey/dev-git/10.3-cl/sql/sql_explain.cc:2431
  #1  0x0000555555df626f in create_explain_query_if_not_exists (lex=0x7fff60004b58, mem_root=0x7fff60006298) at /home/psergey/dev-git/10.3-cl/sql/sql_explain.cc:2439
  #2  0x0000555555c883a4 in JOIN::optimize_inner (this=0x7fff6001a0b0) at /home/psergey/dev-git/10.3-cl/sql/sql_select.cc:1665
  #3  0x0000555555c87c83 in JOIN::optimize (this=0x7fff6001a0b0) at /home/psergey/dev-git/10.3-cl/sql/sql_select.cc:1497
  #4  0x0000555555c91d54 in mysql_select (thd=0x7fff60000d50, tables=0x7fff60019a58, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fff60019530, unit=0x7fff60004c18, select_lex=0x7fff600053a0) at /home/psergey/dev-git/10.3-cl/sql/sql_select.cc:4301
  #5  0x0000555555c833c9 in handle_select (thd=0x7fff60000d50, lex=0x7fff60004b58, result=0x7fff60019530, setup_tables_done_option=0) at /home/psergey/dev-git/10.3-cl/sql/sql_select.cc:370
  #6  0x0000555555c4acab in execute_sqlcom_select (thd=0x7fff60000d50, all_tables=0x7fff60019a58) at /home/psergey/dev-git/10.3-cl/sql/sql_parse.cc:6294
  #7  0x0000555555c413f4 in mysql_execute_command (thd=0x7fff60000d50) at /home/psergey/dev-git/10.3-cl/sql/sql_parse.cc:3820
  #8  0x0000555555c4efb6 in mysql_parse (thd=0x7fff60000d50, rawbuf=0x7fff600139b8 "select   (select country_id from location where location_code = cl1.cntr_dest) as dest_cntry,   (select       max(container_id)     from cntr_leg as cl2     where     cl2.container_id = cl1.container_"..., length=447, parser_state=0x7fffd981e5c0, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.3-cl/sql/sql_parse.cc:7818

... note that the create_explain_query_if_not_exists() call is inside a

  if (sel->first_cond_optimization)
  {

block.
Indeed, if I run the test query inside a PREPARE; EXECUTE; EXECUTE block, then 10.3 crashes in the same way as 10.1 does.

Generated at Thu Feb 08 09:20:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.