[MDEV-32019] Replace my_casedn_str(local_buffer) to CharBuffer::copy_casedn() Created: 2023-08-26  Updated: 2023-09-12  Resolved: 2023-08-26

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

 Description   

Under terms of MDEV-31531 we're removing all my_casedn_str() calls, because MDEV-27490 will switch the Unicode version to 14.0.0, and this version does not support inplace lower-casing: some characters can grow in octet length when converting to lower case.

This task is to remove my_casedn_str() calls which use a local char[] buffer, like this example in find_field_in_group_list():

  LEX_CSTRING db_name= ((Item_ident*) find_item)->db_name;
  char name_buff[SAFE_NAME_LEN+1];
  ...
  if (db_name.str && lower_case_table_names)
  {
    /* Convert database to lower case for comparison */
    strmake_buf(name_buff, db_name.str);
    my_casedn_str(files_charset_info, name_buff);
    db_name= Lex_cstring_strlen(name_buff);
  }

Let's change code pieces like the above to this style:

  LEX_CSTRING db_name= ((Item_ident*) find_item)->db_name;
  IdentBuffer<SAFE_NAME_LEN> name_buff;
  ..
  if (db_name.str && lower_case_table_names)
  {
    /* Convert database to lower case for comparison */
    db_name= name_buff.copy_casedn(db_name).to_lex_cstring();
  }

where IdentBuffer is a CharBuffer descendant with the utf8 character set:

template<size_t buff_sz>
class IdentBuffer: public CharBuffer<buff_sz>
{
  constexpr static CHARSET_INFO *charset()
  {
    return &my_charset_utf8mb3_general_ci;
  }
public:
  IdentBuffer()
  { }
  IdentBuffer<buff_sz> & copy_casedn(const LEX_CSTRING &str)
  {
    CharBuffer<buff_sz>::copy_casedn(charset(), str);
    return *this;
  }
  ...
}

Note, this task won't touch other (without local char[] buffers) cases of my_casedn_str(), e.g. those using a MEM_ROOT allocated memory for the lower case data. Such calls will be removed separately, in the main patch MDEV-31531.


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