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

Remove old check_db_name() from prepare_db_action()

    XMLWordPrintable

Details

    Description

      This task is a part of MDEV-31606. It's to remove the old style check_db_name() from prepare_db_action().

      Let's do the following:

      • Add a new class Lex_ident_db, to store normalized database names: lower-cased if lower-case-table-name says so, and checked to be a valid database name using Lex_ident_fs::check_db_name(), with asserts in the contructor:

        class Lex_ident_db: public Lex_ident_fs
        {
        public:
          Lex_ident_db()
           :Lex_ident_fs(NULL, 0)
          { }
          Lex_ident_db(const char *str, size_t length)
           :Lex_ident_fs(str, length)
          {
            DBUG_SLOW_ASSERT(ok_for_lower_case_names());
            DBUG_SLOW_ASSERT(!check_db_name());
          }
        };
        

      • Add the following method to class DBNameBuffer:

          Lex_ident_db to_lex_ident_db_with_error() const
          {
            LEX_CSTRING tmp= to_lex_cstring();
            if (Lex_ident_fs(tmp).check_db_name_with_error())
              return Lex_ident_db();
            return Lex_ident_db(tmp.str, tmp.length);
          }
        

      • Remove check_db_name() from prepare_db_action()
      • Change the "db" parameter to prepare_db_action() from LEX_CSTRING to Lex_ident_db
      • Move creation of Lex_ident_db one level upper, in the switch cases handling SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB_UPGRADE, SQLCOM_ALTER_DB, with help of the class DBNameBuffer.
      • Change the "db" parameter from LEX_CSTRNG to Lex_ident_db in the following function:

        int mysql_create_db(THD *thd, const Lex_ident_db &db, DDL_options_st options,
                            const Schema_specification_st *create);
        bool mysql_alter_db(THD *thd, const Lex_ident_db &db,
                            const Schema_specification_st *create);
        bool mysql_rm_db(THD *thd, const Lex_ident_db &db, bool if_exists);
        bool mysql_upgrade_db(THD *thd, const Lex_ident_db &old_db);
        

        so these functions know that the database was already normalized and validated.

      Attachments

        Issue Links

          Activity

            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.