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

Split Column_definition::create_length_to_internal_length() to virtual methods in Type_handler

Details

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

    Description

      This code is not friendly to pluggable data types:

      void Column_definition::create_length_to_internal_length(void)
      {
        switch (real_field_type()) {
        case MYSQL_TYPE_TINY_BLOB:
        ...
        }
      }
      

      As of MDEV creation time, the only place where create_length_to_internal_length() is used (see bb-10.2-ext and 10.3 branches) is a loop inside mysql_prepare_create_table():

      /* Check if we have used the same field name before */
      for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
      {
      ...
          if (!(sql_field->flags & NOT_NULL_FLAG))
            null_fields--;
          sql_field->flags=             dup_field->flags;
          sql_field->create_length_to_internal_length();
          sql_field->interval=          dup_field->interval;
          sql_field->vcol_info=         dup_field->vcol_info;
      ...
      }
      

      This code is responsible for queries like this:

      CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
      

      I.e. t1.a is queried, but its data type is redefined.

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

      • Introduce a new virtual method in Type_handler:

        virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                       const Column_definition *dup,
                                                       const handler *file,
                                                       const Schema_specification_st *)
                                                       const;
        

      • Move the entire redefinition code (responsible for copying members from dup_field to sql_field):
      • Data type independent code will go into a shared method Column_definition::redefine_stage1_common()
      • Data type specific code will go to relevant virtual implementations of Column_definition_redefine_stage1. Every implementation will include a call for redefine_stage1_common() followed by data specific code. For example, the method responsible for handling DECIMAL, will look like:

        bool Type_handler_newdecimal::
               Column_definition_redefine_stage1(Column_definition *def,
                                                 const Column_definition *dup,
                                                 const handler *file,
                                                 const Schema_specification_st *schema)
                                                 const
        {
          def->redefine_stage1_common(dup, file, schema);
          def->create_length_to_internal_length_newdecimal();
          return false;
        }
        

      • Remove Column_definition::create_length_to_internal_length()

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            Description This code is not friendly to pluggable data types:
            {code:cpp}
            void Column_definition::create_length_to_internal_length(void)
            {
              switch (real_field_type()) {
              case MYSQL_TYPE_TINY_BLOB:
              ...
              }
            }
            {code}

            As of MDEV creation time, the only place where {{create_length_to_internal_length()}} is used (see {{bb-10.2-ext}} and {{10.3}} branches) is a loop inside {{mysql_prepare_create_table()}}:
            {code:cpp}
            /* Check if we have used the same field name before */
            for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
            {
            ...
                if (!(sql_field->flags & NOT_NULL_FLAG))
                  null_fields--;
                sql_field->flags= dup_field->flags;
                sql_field->create_length_to_internal_length();
                sql_field->interval= dup_field->interval;
                sql_field->vcol_info= dup_field->vcol_info;
            ...
            }
            {code}

            This code is responsible for queries like this:
            {code:sql}
            CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
            {code}
            I.e. {{t1.a}} is queried, but its data type is redefined.

            Under terms of this task we'll do the following:
            - Introduce a new virtual method in {{Type_handler}}:
            {code:cpp
            virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                           const Column_definition *dup,
                                                           const handler *file,
                                                           const Schema_specification_st *)
                                                           const;
            {code}
            - Move the entire redefinition code (responsible for copying members from {{dup_field}} to {{sql_field}}):
            -- Data type independent code will go into a shared method {{Column_definition::redefine_stage1_common()}}
            -- Data type specific code will go to relevant virtual implementations of {{Column_definition_redefine_stage1}}. Every implementation will include a call for {{redefine_stage1_common()}} followed by data specific code. For example, the method responsible for handling {{DECIMAL}}, will look like:
            {code:cpp}
            bool Type_handler_newdecimal::
                   Column_definition_redefine_stage1(Column_definition *def,
                                                     const Column_definition *dup,
                                                     const handler *file,
                                                     const Schema_specification_st *schema)
                                                     const
            {
              def->redefine_stage1_common(dup, file, schema);
              def->create_length_to_internal_length_newdecimal();
              return false;
            }
            {code}
            - Remove {{Column_definition::create_length_to_internal_length()}}
            bar Alexander Barkov made changes -
            Description This code is not friendly to pluggable data types:
            {code:cpp}
            void Column_definition::create_length_to_internal_length(void)
            {
              switch (real_field_type()) {
              case MYSQL_TYPE_TINY_BLOB:
              ...
              }
            }
            {code}

            As of MDEV creation time, the only place where {{create_length_to_internal_length()}} is used (see {{bb-10.2-ext}} and {{10.3}} branches) is a loop inside {{mysql_prepare_create_table()}}:
            {code:cpp}
            /* Check if we have used the same field name before */
            for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
            {
            ...
                if (!(sql_field->flags & NOT_NULL_FLAG))
                  null_fields--;
                sql_field->flags= dup_field->flags;
                sql_field->create_length_to_internal_length();
                sql_field->interval= dup_field->interval;
                sql_field->vcol_info= dup_field->vcol_info;
            ...
            }
            {code}

            This code is responsible for queries like this:
            {code:sql}
            CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
            {code}
            I.e. {{t1.a}} is queried, but its data type is redefined.

            Under terms of this task we'll do the following:
            - Introduce a new virtual method in {{Type_handler}}:
            {code:cpp
            virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                           const Column_definition *dup,
                                                           const handler *file,
                                                           const Schema_specification_st *)
                                                           const;
            {code}
            - Move the entire redefinition code (responsible for copying members from {{dup_field}} to {{sql_field}}):
            -- Data type independent code will go into a shared method {{Column_definition::redefine_stage1_common()}}
            -- Data type specific code will go to relevant virtual implementations of {{Column_definition_redefine_stage1}}. Every implementation will include a call for {{redefine_stage1_common()}} followed by data specific code. For example, the method responsible for handling {{DECIMAL}}, will look like:
            {code:cpp}
            bool Type_handler_newdecimal::
                   Column_definition_redefine_stage1(Column_definition *def,
                                                     const Column_definition *dup,
                                                     const handler *file,
                                                     const Schema_specification_st *schema)
                                                     const
            {
              def->redefine_stage1_common(dup, file, schema);
              def->create_length_to_internal_length_newdecimal();
              return false;
            }
            {code}
            - Remove {{Column_definition::create_length_to_internal_length()}}
            This code is not friendly to pluggable data types:
            {code:cpp}
            void Column_definition::create_length_to_internal_length(void)
            {
              switch (real_field_type()) {
              case MYSQL_TYPE_TINY_BLOB:
              ...
              }
            }
            {code}

            As of MDEV creation time, the only place where {{create_length_to_internal_length()}} is used (see {{bb-10.2-ext}} and {{10.3}} branches) is a loop inside {{mysql_prepare_create_table()}}:
            {code:cpp}
            /* Check if we have used the same field name before */
            for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
            {
            ...
                if (!(sql_field->flags & NOT_NULL_FLAG))
                  null_fields--;
                sql_field->flags= dup_field->flags;
                sql_field->create_length_to_internal_length();
                sql_field->interval= dup_field->interval;
                sql_field->vcol_info= dup_field->vcol_info;
            ...
            }
            {code}

            This code is responsible for queries like this:
            {code:sql}
            CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
            {code}
            I.e. {{t1.a}} is queried, but its data type is redefined.

            Under terms of this task we'll do the following:
            - Introduce a new virtual method in {{Type_handler}}:
            {code:cpp
            virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                           const Column_definition *dup,
                                                           const handler *file,
                                                           const Schema_specification_st *)
                                                           const;
            {code}
            - Move the entire redefinition code (responsible for copying members from {{dup_field}} to {{sql_field}}):
            - Data type independent code will go into a shared method {{Column_definition::redefine_stage1_common()}}
            - Data type specific code will go to relevant virtual implementations of {{Column_definition_redefine_stage1}}. Every implementation will include a call for {{redefine_stage1_common()}} followed by data specific code. For example, the method responsible for handling {{DECIMAL}}, will look like:
            {code:cpp}
            bool Type_handler_newdecimal::
                   Column_definition_redefine_stage1(Column_definition *def,
                                                     const Column_definition *dup,
                                                     const handler *file,
                                                     const Schema_specification_st *schema)
                                                     const
            {
              def->redefine_stage1_common(dup, file, schema);
              def->create_length_to_internal_length_newdecimal();
              return false;
            }
            {code}
            - Remove {{Column_definition::create_length_to_internal_length()}}
            bar Alexander Barkov made changes -
            Description This code is not friendly to pluggable data types:
            {code:cpp}
            void Column_definition::create_length_to_internal_length(void)
            {
              switch (real_field_type()) {
              case MYSQL_TYPE_TINY_BLOB:
              ...
              }
            }
            {code}

            As of MDEV creation time, the only place where {{create_length_to_internal_length()}} is used (see {{bb-10.2-ext}} and {{10.3}} branches) is a loop inside {{mysql_prepare_create_table()}}:
            {code:cpp}
            /* Check if we have used the same field name before */
            for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
            {
            ...
                if (!(sql_field->flags & NOT_NULL_FLAG))
                  null_fields--;
                sql_field->flags= dup_field->flags;
                sql_field->create_length_to_internal_length();
                sql_field->interval= dup_field->interval;
                sql_field->vcol_info= dup_field->vcol_info;
            ...
            }
            {code}

            This code is responsible for queries like this:
            {code:sql}
            CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
            {code}
            I.e. {{t1.a}} is queried, but its data type is redefined.

            Under terms of this task we'll do the following:
            - Introduce a new virtual method in {{Type_handler}}:
            {code:cpp
            virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                           const Column_definition *dup,
                                                           const handler *file,
                                                           const Schema_specification_st *)
                                                           const;
            {code}
            - Move the entire redefinition code (responsible for copying members from {{dup_field}} to {{sql_field}}):
            - Data type independent code will go into a shared method {{Column_definition::redefine_stage1_common()}}
            - Data type specific code will go to relevant virtual implementations of {{Column_definition_redefine_stage1}}. Every implementation will include a call for {{redefine_stage1_common()}} followed by data specific code. For example, the method responsible for handling {{DECIMAL}}, will look like:
            {code:cpp}
            bool Type_handler_newdecimal::
                   Column_definition_redefine_stage1(Column_definition *def,
                                                     const Column_definition *dup,
                                                     const handler *file,
                                                     const Schema_specification_st *schema)
                                                     const
            {
              def->redefine_stage1_common(dup, file, schema);
              def->create_length_to_internal_length_newdecimal();
              return false;
            }
            {code}
            - Remove {{Column_definition::create_length_to_internal_length()}}
            This code is not friendly to pluggable data types:
            {code:cpp}
            void Column_definition::create_length_to_internal_length(void)
            {
              switch (real_field_type()) {
              case MYSQL_TYPE_TINY_BLOB:
              ...
              }
            }
            {code}

            As of MDEV creation time, the only place where {{create_length_to_internal_length()}} is used (see {{bb-10.2-ext}} and {{10.3}} branches) is a loop inside {{mysql_prepare_create_table()}}:
            {code:cpp}
            /* Check if we have used the same field name before */
            for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
            {
            ...
                if (!(sql_field->flags & NOT_NULL_FLAG))
                  null_fields--;
                sql_field->flags= dup_field->flags;
                sql_field->create_length_to_internal_length();
                sql_field->interval= dup_field->interval;
                sql_field->vcol_info= dup_field->vcol_info;
            ...
            }
            {code}

            This code is responsible for queries like this:
            {code:sql}
            CREATE TABLE t2 (a INT) AS SELECT a FROM t1;
            {code}
            I.e. {{t1.a}} is queried, but its data type is redefined.

            Under terms of this task we'll do the following:
            - Introduce a new virtual method in {{Type_handler}}:
            {code:cpp}
            virtual bool Column_definition_redefine_stage1(Column_definition *def,
                                                           const Column_definition *dup,
                                                           const handler *file,
                                                           const Schema_specification_st *)
                                                           const;
            {code}
            - Move the entire redefinition code (responsible for copying members from {{dup_field}} to {{sql_field}}):
            - Data type independent code will go into a shared method {{Column_definition::redefine_stage1_common()}}
            - Data type specific code will go to relevant virtual implementations of {{Column_definition_redefine_stage1}}. Every implementation will include a call for {{redefine_stage1_common()}} followed by data specific code. For example, the method responsible for handling {{DECIMAL}}, will look like:
            {code:cpp}
            bool Type_handler_newdecimal::
                   Column_definition_redefine_stage1(Column_definition *def,
                                                     const Column_definition *dup,
                                                     const handler *file,
                                                     const Schema_specification_st *schema)
                                                     const
            {
              def->redefine_stage1_common(dup, file, schema);
              def->create_length_to_internal_length_newdecimal();
              return false;
            }
            {code}
            - Remove {{Column_definition::create_length_to_internal_length()}}
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2017-05-17 14:08:05.0 2017-05-17 14:08:05.439
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.1 [ 22532 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 80825 ] MariaDB v4 [ 133257 ]

            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.