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

    XMLWordPrintable

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

            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.