[MDEV-31982] Remove old check_db_name() from prepare_db_action() Created: 2023-08-22  Updated: 2023-09-17  Resolved: 2023-08-22

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Fix Version/s: 11.3.0

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-31531 Remove my_casedn_str() and my_caseup_... In Testing
blocks MDEV-31606 Refactor check_db_name() to get a con... Closed
Problem/Incident
causes MDEV-32026 lowercase_table2.test failures in 11.3 Closed

 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.


Generated at Thu Feb 08 10:27:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.