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

Add class Load_data_outvar and avoid using Item::STRING_ITEM for Item_user_var_as_out_param detection

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.3.6
    • OTHER
    • None

    Description

      This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

      Under terms of MDEV-14630 we're going to replace data-type dependent constants STRING_ITEM, INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to an universal constant LITERAL_ITEM.

      In order to do it easier, we'll clean up the code in sql_load.cc not to use Item::STRING_ITEM for Item_user_var_as_out_param detection.

      Under terms of this task we'll do the following:

      • Introduce a new class:

        class Load_data_outvar
        {
        public:
          virtual ~Load_data_outvar() {}
          virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
          virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                           const Load_data_param *param)= 0;
          virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
          virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
          virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
          virtual uint load_data_field_length() const= 0;
        };
        

      • Derive Item_field and Item_user_var_as_out_param from Load_data_outvar.
      • Move Item_field- and Item_user_var_as_out_param specific pieces of the code in sql_load.cc into virtual implementations of these Load_data_outvar derived classes.

      Code blocks like this (they repeat multiple times):

            Item *real_item= item->real_item();
       
            if (item->type() == Item::STRING_ITEM)
            {
              ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                              read_info.read_charset);
            }
            else if (!real_item)
            {
              my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
              DBUG_RETURN(1);
            }
            else
            {
              ...
              field->store((char *) tag->value.ptr(), tag->value.length(), cs);
              ...
            }
      

      will be simplified to one line:

        item->load_data_set_value(...)
      

      Additionally, replacing dangerous tests for Item::STRING_ITEM and dangerous casts to Item_user_var_as_out_param to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for LOAD DATA but crashes/fails for LOAD XML.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants {STRING|INT|REAL|DECIMAL|DATE}_ITEM and replace them to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants STRING_ITEM, |INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            bar Alexander Barkov made changes -
            Description This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants STRING_ITEM, |INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants {{STRING_ITEM}}, {{|INT_ITEM}}, {{REAL_ITEM}}, {{DECIMAL_ITEM}}, {{DATE_ITEM}} to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            bar Alexander Barkov made changes -
            Description This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants {{STRING_ITEM}}, {{|INT_ITEM}}, {{REAL_ITEM}}, {{DECIMAL_ITEM}}, {{DATE_ITEM}} to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            This task is a self-contained change which is going to simplify MDEV-12927 and MDEV-14630.

            Under terms of {{MDEV-14630}} we're going to replace data-type dependent constants {{STRING_ITEM}}, {{INT_ITEM}}, {{REAL_ITEM}}, {{DECIMAL_ITEM}}, {{DATE_ITEM}} to an universal constant {{LITERAL_ITEM}}.

            In order to do it easier, we'll clean up the code in {{sql_load.cc}} not to use {{Item::STRING_ITEM}} for {{Item_user_var_as_out_param}} detection.

            Under terms of this task we'll do the following:
            - Introduce a new class:
            {code:cpp}
            class Load_data_outvar
            {
            public:
              virtual ~Load_data_outvar() {}
              virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0;
              virtual bool load_data_set_value(THD *thd, const char *pos, uint length,
                                               const Load_data_param *param)= 0;
              virtual bool load_data_set_no_data(THD *thd, const Load_data_param *param)= 0
              virtual void load_data_print_for_log_event(THD *thd, class String *to) const=0;
              virtual bool load_data_add_outvar(THD *thd, Load_data_param *param) const= 0;
              virtual uint load_data_field_length() const= 0;
            };
            {code}

            - Derive {{Item_field}} and {{Item_user_var_as_out_param}} from {{Load_data_outvar}}.
            - Move {{Item_field}}- and {{Item_user_var_as_out_param}} specific pieces of the code in {{sql_load.cc}} into virtual implementations of these {{Load_data_outvar}} derived classes.

            Code blocks like this (they repeat multiple times):
            {code:cpp}
                  Item *real_item= item->real_item();

                  if (item->type() == Item::STRING_ITEM)
                  {
                    ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
                                                                    read_info.read_charset);
                  }
                  else if (!real_item)
                  {
                    my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
                    DBUG_RETURN(1);
                  }
                  else
                  {
                    ...
                    field->store((char *) tag->value.ptr(), tag->value.length(), cs);
                    ...
                  }
            {code}
            will be simplified to one line:
            {code:cpp}
              item->load_data_set_value(...)
            {code}

            Additionally, replacing dangerous tests for {{Item::STRING_ITEM}} and dangerous casts to {{Item_user_var_as_out_param}} to virtual calls will remove potential bugs like MDEV-12696, when the code works fine for {{LOAD DATA}} but crashes/fails for {{LOAD XML}}.
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2018-03-20 13:53:27.0 2018-03-20 13:53:27.02
            bar Alexander Barkov made changes -
            Component/s OTHER [ 10125 ]
            Fix Version/s 10.3.6 [ 23003 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]

            Backported to 10.2.23, as a part of MDEV-18045.

            bar Alexander Barkov added a comment - Backported to 10.2.23, as a part of MDEV-18045 .
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 86086 ] MariaDB v4 [ 133497 ]

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.