MySQL 8.0.40
Source Code Documentation
replace_item.cc File Reference

Functions

static ItemFindReplacementItem (Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
 Check what field the given item will be materialized into under the given temporary table parameters. More...
 
ItemFindReplacementOrReplaceMaterializedItems (THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
 
void ReplaceMaterializedItems (THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
 Like FindReplacementOrReplaceMaterializedItems, but only search below the item, ie. More...
 

Function Documentation

◆ FindReplacementItem()

static Item * FindReplacementItem ( Item item,
const Func_ptr_array items_to_copy,
bool  need_exact_match 
)
static

Check what field the given item will be materialized into under the given temporary table parameters.

If the item is materialized (ie., found in items_to_copy), we return a canonical Item_field for that field; ie., the same every time. This means that you can do the same replacement in a SELECT list and then in items_to_copy itself, and still have them match. This is used in particular when updating Temp_table_param itself, in FinalizePlanForQueryBlock().

Normally, we want to search for only the same item, up to references (need_exact_match=true). However, in ORDER BY specifications of windows, we can sometimes have the same field referred to by different Item_field, and the callers may need to set need_exact_match=false, which compares using Item::eq() instead. This also disables the behavior of checking and propagating Item::hidden.

◆ FindReplacementOrReplaceMaterializedItems()

Item * FindReplacementOrReplaceMaterializedItems ( THD thd,
Item item,
const Func_ptr_array items_to_copy,
bool  need_exact_match 
)

◆ ReplaceMaterializedItems()

void ReplaceMaterializedItems ( THD thd,
Item item,
const Func_ptr_array items_to_copy,
bool  need_exact_match 
)

Like FindReplacementOrReplaceMaterializedItems, but only search below the item, ie.

ignore point 2 above. This can be useful if doing self-replacement, ie., we are replacing source items in items_to_copy and don't want to replace an item with its own output.