• Alexander Barkov's avatar
    MDEV-33019 The database part is not case sensitive in SP names · 9695974e
    Alexander Barkov authored
    Problem:
    
    sp_cache erroneously looked up fully qualified SP names (e.g. `DB`.`SP`),
    in case insensitive style. It was wrong, because only the "name"
    part is always case insensitive, while the "db" part should be compared
    according to lower_case_table_names (case sensitively for 0,
    case insensitively for 1 and 2).
    
    Fix:
    
    Adding a "casedn_name" parameter make_qname() to tell
    if the name part should be lower cased:
      `DB1`.`SP` -> "DB1.SP"  (when casedn_name=false)
      `DB1`.`SP` -> "DB1.sp"  (when casedn_name=true)
    and using make_qname() with casedn_name=true when creating
    sp_cache hash lookup keys.
    
    Details:
    
    As a result, it now works as follows:
    - sp_head::m_db is converted to lower case if lower_case_table_names>0
      during the sp_name initialization phase. So when make_qname() is called,
      sp_head::m_db is already normalized. There are no changes in here.
    
    - The initialization phase of sp_head when creating sp_head::m_qname
      now calls make_qname() with casedn_name=true,
      so sp_head::m_name gets written to sp_head::m_qname in lower case.
    
    - sp_cache_lookup() now also calls make_qname() with casedn_name=true,
      so sp_head::m_name gets written to the temporary lookup key in lower case.
    
    - sp_cache::m_hashtable now uses case sensitive comparison
    9695974e
sql_lex.cc 317 KB