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
-
Activity
Field | Original Value | New Value |
---|---|---|
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:
{code} 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! } {code} Same refers to Item::build_clone(). A possible solution ca be [something like this|https://stackoverflow.com/a/9478895/6150050]. |
Item::get_copy() and build_clone() may sometimes return an instance of a ancestor class instead of a copy/clone. Look at the example:
{code} 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! } {code} Same refers to Item::build_clone(). A possible solution can be something like this: https://stackoverflow.com/a/9478895/6150050. |
Fix Version/s | 10.5 [ 23123 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Assignee | Oleg Smirnov [ JIRAUSER50405 ] | Oleksandr Byelkin [ sanja ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Oleksandr Byelkin [ sanja ] | Oleg Smirnov [ JIRAUSER50405 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Component/s | Server [ 13907 ] | |
Fix Version/s | 10.5.26 [ 29832 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Fix Version/s | 10.6.19 [ 29833 ] | |
Fix Version/s | 10.11.9 [ 29834 ] | |
Fix Version/s | 11.1.6 [ 29835 ] | |
Fix Version/s | 11.2.5 [ 29836 ] | |
Fix Version/s | 11.4.3 [ 29837 ] |
Link |
This issue causes |
Link |
This issue relates to |
sanja, please review the pull request.