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

Split create_schema_table() into virtual methods in Type_handler

Details

    Description

      The code in create_schema_table() has switch's and if's testing MYSQL_TYPE_XXX.
      This is not friendly to data type plugins.

      Additionally, when schema tables are created in two steps:

      • On the first step, Items are created from ST_FIELD_INFO
      • On the second step, these Items create Fields
        which is slow.

      Let's do the following:

      • Add a new method in Type_handler:

           virtual Field *make_schema_field(TABLE *table,
                                            const Record_addr &addr,
                                            const ST_FIELD_INFO &def,
                                            bool show_field) const
        

      • Change the logic to create Fields directly from ST_FIELD_INFO.
      • For that purpose, and to be able to reuse the code in a convenient way, wrap create_tmp_table() into a class Create_tmp_table with approximately these methods:

      class Create_tmp_table
      {
      public:
        ...
        // The former beginning of create_tmp_table()
        TABLE *start(THD *thd,
                     TMP_TABLE_PARAM *param,
                     const LEX_CSTRING *table_alias);
       
        // The former loop of create_tmp_table(), adding fields into the table
        bool add_fields(THD *thd, TABLE *table,
                        TMP_TABLE_PARAM *param, List<Item> &fields);
       
        // A new code adding fields directly from ST_FIELD_INFO
        bool add_schema_fields(THD *thd, TABLE *table,
                               TMP_TABLE_PARAM *param,
                               const ST_SCHEMA_TABLE &schema_table,
                               const MY_BITMAP &bitmap);
       
        // The forder end of create_tmp_table(), after the loop adding fields.
        bool finalize(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
                      bool do_not_open, bool keep_row_order);
      };
      

      • Remove method Item::create_field_for_schema()
      • Remove class Item_return_date_time
      • Remove class Item_blob

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            Rank Ranked higher
            bar Alexander Barkov made changes -
            Description The code in create_schema_table() has switch's and if's testing MYSQL_TYPE_XXX.
            This is not friendly to data type plugins.

            Additionally, when schema tables are created in two steps:
            - On the first step, Items are created from ST_FIELD_INFO
            - On the second step, these Items create Fields
            which is slow.

            Let's do the following:
            - Add a new method in Type_handler:
            {code:sql}
               virtual Field *make_schema_field(TABLE *table,
                                                const Record_addr &addr,
                                                const ST_FIELD_INFO &def,
                                                bool show_field) const
            {code}
            - Change the logic to create Fields directly from ST_FIELD_INFO.
            - For that purpose, and to be able to reuse the code in a convenient way, wrap create_tmp_table() into a class Create_tmp_table with approximately with methods:

            {code:cpp}
            class Create_tmp_table
            {
            public:
              ...
              // The former beginning of {{create_tmp_table()}}
              TABLE *start(THD *thd,
                           TMP_TABLE_PARAM *param,
                           const LEX_CSTRING *table_alias);

              // The former loop of {{create_tmp_table()}} adding fields
              bool add_fields(THD *thd, TABLE *table,
                              TMP_TABLE_PARAM *param, List<Item> &fields);

              // A new code adding fields directly from ST_FIELD_INFO
              bool add_schema_fields(THD *thd, TABLE *table,
                                     TMP_TABLE_PARAM *param,
                                     const ST_SCHEMA_TABLE &schema_table,
                                     const MY_BITMAP &bitmap);

              // The forder end of {{create_tmp_table()}}, after the loop.
              bool finalize(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
                            bool do_not_open, bool keep_row_order);
            };
            {code}

            - Remove method Item::create_field_for_schema()
            - Remove class Item_return_date_time
            - Remove class Item_blob
            The code in create_schema_table() has switch's and if's testing MYSQL_TYPE_XXX.
            This is not friendly to data type plugins.

            Additionally, when schema tables are created in two steps:
            - On the first step, Items are created from ST_FIELD_INFO
            - On the second step, these Items create Fields
            which is slow.

            Let's do the following:
            - Add a new method in Type_handler:
            {code:sql}
               virtual Field *make_schema_field(TABLE *table,
                                                const Record_addr &addr,
                                                const ST_FIELD_INFO &def,
                                                bool show_field) const
            {code}
            - Change the logic to create Fields directly from ST_FIELD_INFO.
            - For that purpose, and to be able to reuse the code in a convenient way, wrap create_tmp_table() into a class Create_tmp_table with approximately these methods:

            {code:cpp}
            class Create_tmp_table
            {
            public:
              ...
              // The former beginning of {{create_tmp_table()}}
              TABLE *start(THD *thd,
                           TMP_TABLE_PARAM *param,
                           const LEX_CSTRING *table_alias);

              // The former loop of {{create_tmp_table()}} adding fields
              bool add_fields(THD *thd, TABLE *table,
                              TMP_TABLE_PARAM *param, List<Item> &fields);

              // A new code adding fields directly from ST_FIELD_INFO
              bool add_schema_fields(THD *thd, TABLE *table,
                                     TMP_TABLE_PARAM *param,
                                     const ST_SCHEMA_TABLE &schema_table,
                                     const MY_BITMAP &bitmap);

              // The forder end of {{create_tmp_table()}}, after the loop.
              bool finalize(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
                            bool do_not_open, bool keep_row_order);
            };
            {code}

            - Remove method Item::create_field_for_schema()
            - Remove class Item_return_date_time
            - Remove class Item_blob
            bar Alexander Barkov made changes -
            Description The code in create_schema_table() has switch's and if's testing MYSQL_TYPE_XXX.
            This is not friendly to data type plugins.

            Additionally, when schema tables are created in two steps:
            - On the first step, Items are created from ST_FIELD_INFO
            - On the second step, these Items create Fields
            which is slow.

            Let's do the following:
            - Add a new method in Type_handler:
            {code:sql}
               virtual Field *make_schema_field(TABLE *table,
                                                const Record_addr &addr,
                                                const ST_FIELD_INFO &def,
                                                bool show_field) const
            {code}
            - Change the logic to create Fields directly from ST_FIELD_INFO.
            - For that purpose, and to be able to reuse the code in a convenient way, wrap create_tmp_table() into a class Create_tmp_table with approximately these methods:

            {code:cpp}
            class Create_tmp_table
            {
            public:
              ...
              // The former beginning of {{create_tmp_table()}}
              TABLE *start(THD *thd,
                           TMP_TABLE_PARAM *param,
                           const LEX_CSTRING *table_alias);

              // The former loop of {{create_tmp_table()}} adding fields
              bool add_fields(THD *thd, TABLE *table,
                              TMP_TABLE_PARAM *param, List<Item> &fields);

              // A new code adding fields directly from ST_FIELD_INFO
              bool add_schema_fields(THD *thd, TABLE *table,
                                     TMP_TABLE_PARAM *param,
                                     const ST_SCHEMA_TABLE &schema_table,
                                     const MY_BITMAP &bitmap);

              // The forder end of {{create_tmp_table()}}, after the loop.
              bool finalize(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
                            bool do_not_open, bool keep_row_order);
            };
            {code}

            - Remove method Item::create_field_for_schema()
            - Remove class Item_return_date_time
            - Remove class Item_blob
            The code in create_schema_table() has switch's and if's testing MYSQL_TYPE_XXX.
            This is not friendly to data type plugins.

            Additionally, when schema tables are created in two steps:
            - On the first step, Items are created from ST_FIELD_INFO
            - On the second step, these Items create Fields
            which is slow.

            Let's do the following:
            - Add a new method in Type_handler:
            {code:sql}
               virtual Field *make_schema_field(TABLE *table,
                                                const Record_addr &addr,
                                                const ST_FIELD_INFO &def,
                                                bool show_field) const
            {code}
            - Change the logic to create Fields directly from ST_FIELD_INFO.
            - For that purpose, and to be able to reuse the code in a convenient way, wrap create_tmp_table() into a class Create_tmp_table with approximately these methods:

            {code:cpp}
            class Create_tmp_table
            {
            public:
              ...
              // The former beginning of create_tmp_table()
              TABLE *start(THD *thd,
                           TMP_TABLE_PARAM *param,
                           const LEX_CSTRING *table_alias);

              // The former loop of create_tmp_table(), adding fields into the table
              bool add_fields(THD *thd, TABLE *table,
                              TMP_TABLE_PARAM *param, List<Item> &fields);

              // A new code adding fields directly from ST_FIELD_INFO
              bool add_schema_fields(THD *thd, TABLE *table,
                                     TMP_TABLE_PARAM *param,
                                     const ST_SCHEMA_TABLE &schema_table,
                                     const MY_BITMAP &bitmap);

              // The forder end of create_tmp_table(), after the loop adding fields.
              bool finalize(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
                            bool do_not_open, bool keep_row_order);
            };
            {code}

            - Remove method Item::create_field_for_schema()
            - Remove class Item_return_date_time
            - Remove class Item_blob
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2019-05-25 12:48:25.0 2019-05-25 12:48:25.651
            bar Alexander Barkov made changes -
            Component/s Data types [ 13906 ]
            Component/s Information Schema [ 14413 ]
            Fix Version/s 10.5.0 [ 23709 ]
            Fix Version/s 10.5 [ 23123 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 96969 ] MariaDB v4 [ 133972 ]

            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.