List:Commits« Previous MessageNext Message »
From:Rafal Somla Date:March 5 2009 9:52am
Subject:Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)
Bug#39063
View as plain text  
Jorgen,

See my proposition below.

Jørgen Løland wrote:
> Values of lower_case_file_names:
> --------------------------------
> 0:
> * I_S stores the database name exactly as specified by the CREATE 
> DATABASE command
> * BACKUP command must be specified with exact database name case
> * The database name is not normalized.
> * If wrong case is used on the name, BACKUP fails with "No such database"
> * RESTORE will create a database with the same case as specified by 
> CREATE DATABASE (if restored on case sensitive systems, see bug#43363)
> 
> 1:
> * I_S stores the database name in lower case independently of the case 
> of the CREATE DATABASE command
> * BACKUP command can be specified with any database name case, the 
> database names are converted to lower case internally.
> * RESTORE will always create a database with lower case name
> 
> 2:
> * I_S stores the database name exactly as specified by the CREATE 
> DATABASE command
> * BACKUP should be able to figure out the correct case of the dbname, 
> but I'm not sure how to do that. Maybe handler.cc#get_canonical_filename?
> * The database name is normalized to correct case.
> * RESTORE will create a database with the same case as specified by 
> CREATE DATABASE
>

How about the following solution: put the logic in get_database_stub and use 
I_S.SCHEMATA to get the normalized name. When looking for the database, case 
should be ignored unless lctn==0. Like this:

Obj *get_database_stub(const String *db_name)
{
   Ed_connection ed_connection(thd);
   String_stream s_stream;
   Ed_result_set *ed_result_set;

   // Prepare SELECT statement.

   s_stream << "SELECT schema_name "
               "FROM INFORMATION_SCHEMA.SCHEMATA WHERE";
   if (lower_case_table_names)
      s_stream << "LCASE(schema_name) = LCASE('" << db_name << "')";
   else
      s_stream << "schema_name = '" << db_name << "'";

   // Execute SELECT.

   if (run_service_interface_sql(thd, &ed_connection, s_stream.lex_string()) ||
       ed_connection.get_warn_count())
     return NULL;

   // Fetch result.

   ed_result_set= ed_connection.use_result_set();

   if (ed_result_set->size() != 1)
     return NULL;

   List_iterator_fast<Ed_row> row_it(*ed_result_set);
   Ed_row *row= row_it++;

   DBUG_ASSERT(row->size() == 1);

   // Create object using normalized name.

   return new Database_obj(row->get_column(0));
}

I think that with this change, things should work as expected without any 
changes in the backup kernel code (except for moving detection of repeated 
database there, as you did in your patch).

Disclaimer: code not tested.

Rafal
Thread
bzr commit into mysql-6.0-backup branch (jorgen.loland:2784) Bug#39063Jorgen Loland4 Mar
  • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)Bug#39063Chuck Bell4 Mar
    • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)Bug#39063Rafal Somla5 Mar
    • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)Bug#39063Jørgen Løland5 Mar
      • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)Bug#39063Jørgen Løland5 Mar
      • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2784)Bug#39063Rafal Somla5 Mar