[MDEV-16829] Odd code in Item_subselect::is_expensive Created: 2018-07-26  Updated: 2022-11-10  Resolved: 2022-11-10

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.0
Fix Version/s: N/A

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

Issue Links:
Relates
relates to MDEV-6439 Server crashes in Explain_union::prin... Closed

 Description   

Item_subselect::is_expensive() has this code:

  for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
  {
    JOIN *cur_join= sl->join;
    if (!cur_join)
      continue;
 
    /*
      Subqueries whose result is known after optimization are not expensive.
      Such subqueries have all tables optimized away, thus have no join plan.
    */
    if (cur_join->optimized &&
        (cur_join->zero_result_cause || !cur_join->tables_list))
      return false;

The loop walks through parts of UNION. If we find a SELECT that has non-NULL
join->zero_result_cause, we have is_expensive()=FALSE.
What about cases like

 (SELECT FROM t1 WHERE 1=2 
  UNION
  SELECT sum(col) FROM very_big_table
 )

Item_subselect::is_expensive() will return FALSE for it, which is wrong.



 Comments   
Comment by Elena Stepanova [ 2022-10-08 ]

psergei, please update affected/fix versions or close if it's no longer relevant

Comment by Elena Stepanova [ 2022-11-10 ]

The code looks at least somewhat different in 10.10, although I can't tell of course whether the alleged issue was fixed or not.
Closing anyway as there seems to be no interest from the reporter.

Generated at Thu Feb 08 08:31:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.