[MDEV-31978] Turn ok_for_lower_case_names() to a method in Lex_ident_fs Created: 2023-08-22  Updated: 2023-09-12  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-27490 Allow full utf8mb4 for identifiers Stalled
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   

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

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