← Back to team overview

maria-developers team mailing list archive

MDEV-8306: Questions about substitute_base_with_nest_field_items

 

Hi Varun,

I'm looking at JOIN::substitute_base_with_nest_field_items() and I have these 
questions:

>  /* Substituting SELECT list field items with sort-nest's field items */
>  while ((item= it++))
>  {
>    Item *real_item= item->real_item();
>   if ((new_item= real_item->transform(thd,
>                                        &Item::replace_with_nest_items,
>                                        TRUE,
>                                       (uchar *) nest_info)) != real_item)
>    {
>      new_item->name= item->name;
>      thd->change_item_tree(it.ref(), new_item);

Why thd->change_item_tree() call is present for select list elements but 
but not for other kinds of items?

>  /* Substituting WHERE clause's field items with sort-nest's field items */
>  if (conds)
>  {
>    conds= conds->transform(thd, &Item::replace_with_nest_items, TRUE,
>                            (uchar *) nest_info);
>    conds->update_used_tables();
>  }

As far as I understand, the items from the WHERE clause can be attached both
outside and inside the nest.

Moreover, if the WHERE clause has this form

 (condA(t1) AND condB(t2) OR (condC(t1) AND condD(t2)) 

and the join order is t1,t2, then make_cond_for_table() will attach
condA(t1) to both t1 and t2.

How is this handled?

(My first attempt to construct an example for this was not successful due to
MDEV-22360 checks. But I am not convinced that we can rely on MDEV-22360 's 
check to avoid such cases. And even if we could, I don't think it would have
been a good idea)

BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://petrunia.net




Follow ups

References