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

Turn ok_for_lower_case_names() to a method in Lex_ident_fs

    XMLWordPrintable

Details

    Description

      Let's turn the global function ok_for_lower_case_names() into a method in Lex_ident_fs:

      #ifndef DBUG_OFF
      /**
        Verifies that database/table name is in lowercase, when it should be
       
        This is supposed to be used only inside DBUG_ASSERT()
      */
      bool Lex_ident_fs::ok_for_lower_case_names() const
      {
        if (!lower_case_table_names || !str)
          return true;
        DBNameBuffer buf(*this, lower_case_table_names);
        return cmp(*this, buf.to_lex_cstring()) == 0;
      }
      #endif
      

      We'll add a new class Lex_ident_db soon, deriving from Lex_ident_fs.
      It will perform DBUG_ASSERT(ok_for_lower_case_names()) in constructor.

      Also, additionally, let's change a few functions and methods to get a database name as a `const LEX_CSTRING` instead of const char *:

      bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
                            const char *db, const char *name)
                            const LEX_CSTRING &db, const LEX_CSTRING &name);
       
      Events::drop_schema_events(THD *thd, const LEX_CSTRING &db_lex);
       
      bool lock_db_routines(THD *thd, const LEX_CSTRING &db);
       
      int sp_drop_db_routines(THD *thd, const LEX_CSTRING &db);
       
      void Query_cache::invalidate(THD *thd, const LEX_CSTRING &db)
      

      These functions and methods use ok_for_lower_case_names() inside. We'll change these functions/methods later to get the database name as Lex_ident_db instead of LEX_CSTRING.

      This current change from `const char *` to `const LEX_CSTRING` will help to:

      • avoid adding new strlen()
      • remove some existing strlen()
      • reduce the later patch which will add Lex_ident_db

      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.