Details
Description
Item::get_copy() and build_clone() may sometimes return an instance of a ancestor class instead of a copy/clone. Look at the example:
class Item
|
{
|
virtual Item *get_copy(THD *thd)=0;
|
}
|
|
class Item_func
|
{
|
Item *get_copy(THD *thd) override
|
{ return get_item_copy<Item_func>(thd, this); }
|
}
|
|
classs Item_func_descendant : public Item_func
|
{
|
// get_copy() not defined, there's no complains from the compiler
|
// once it's defined in Item_func
|
}
|
|
{
|
Item* instance_of_item_func_descendant;
|
Item* copy= instance_of_item_func_descendant->get_copy(thd);
|
typeid(copy) == "Item_func" although "Item_func_descendant" expected!
|
}
|
Same refers to Item::build_clone(). A possible solution can be something like this: https://stackoverflow.com/a/9478895/6150050.
Attachments
Issue Links
- causes
-
MDEV-34634 Types mismatch when cloning items causes debug assertion
- Closed
- relates to
-
MDEV-34681 Assertion `typeid(*copy) == typeid(*this)' failed in Item::get_copy
- Closed