Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-34490

get_copy() and build_clone() may return an instance of a ancestor class instead of a copy/clone

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

          Activity

            oleg.smirnov Oleg Smirnov created issue -
            oleg.smirnov Oleg Smirnov made changes -
            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.
            oleg.smirnov Oleg Smirnov made changes -
            Fix Version/s 10.5 [ 23123 ]
            oleg.smirnov Oleg Smirnov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            oleg.smirnov Oleg Smirnov added a comment -

            sanja, please review the pull request.

            oleg.smirnov Oleg Smirnov added a comment - sanja , please review the pull request .
            oleg.smirnov Oleg Smirnov made changes -
            Assignee Oleg Smirnov [ JIRAUSER50405 ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]

            OK to push after removing only format changes.

            sanja Oleksandr Byelkin added a comment - OK to push after removing only format changes.
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Oleg Smirnov [ JIRAUSER50405 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            oleg.smirnov Oleg Smirnov added a comment -

            Pushed to 10.5 (commit.

            oleg.smirnov Oleg Smirnov added a comment - Pushed to 10.5 ( commit .
            oleg.smirnov Oleg Smirnov made changes -
            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 ]
            JIraAutomate JiraAutomate made changes -
            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 ]
            oleg.smirnov Oleg Smirnov made changes -
            alice Alice Sherepa made changes -

            People

              oleg.smirnov Oleg Smirnov
              oleg.smirnov Oleg Smirnov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.