MySQL 9.1.0
Source Code Documentation
replace_item.h File Reference

Go to the source code of this file.

Typedefs

using Func_ptr_array = Mem_root_array< Func_ptr >
 

Functions

ItemFindReplacementOrReplaceMaterializedItems (THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match, Func_ptr_array *agg_items_to_copy=nullptr)
 
void ReplaceMaterializedItems (THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match, bool window_frame_buffer=false)
 Like FindReplacementOrReplaceMaterializedItems, but only search below the item, ie. More...
 
ItemReplaceSetVarItem (THD *thd, Item *item, Item *new_item)
 Replace "@var:=<expr>" with "@var:=<tmp_table_column>" rather than "<tmp_table_column>". More...
 

Typedef Documentation

◆ Func_ptr_array

Function Documentation

◆ FindReplacementOrReplaceMaterializedItems()

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

◆ ReplaceMaterializedItems()

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

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.

◆ ReplaceSetVarItem()

Item * ReplaceSetVarItem ( THD thd,
Item item,
Item new_item 
)

Replace "@var:=<expr>" with "@var:=<tmp_table_column>" rather than "<tmp_table_column>".

If a join field such as "@var:=expr" points to a temp table field, the var assignment won't happen because there is no re-evaluation of the materialized field. . So, rather than returning the temp table field, return a new Item_func_set_user_var item that points to temp table field, so that "@var" gets updated.

(It's another thing that the temp table field itself is an Item_func_set_user_var field, i.e. of the form "@var:=<expr>", which means the var assignment redundantly happens for each temp table record while initializing the table; but this function does not fix that)

TODO: remove this function cf. deprecated setting of variable in expressions when it is finally disallowed.