Bug #43220 Test backup_datatypes fails on powermacg5 platform.
Submitted: 26 Feb 2009 10:33 Modified: 25 Jun 2009 22:15
Reporter: Rafal Somla Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0 OS:Any
Assigned to: Jørgen Løland CPU Architecture:Any
Tags: pushbuild failure

[26 Feb 2009 10:33] Rafal Somla
Description:
Test backup_datatypes fails in PB on powermacg5 platform with the following error:

CURRENT_TEST: backup.backup_datatypes
mysqltest: At line 102: query 'RESTORE FROM 'bup_datatype.bak' OVERWRITE' failed: 1685: Could not restore table `¥ü`.`§Æ`

...

Warnings from just before the error:
Error 1050 Table '§æ' already exists 
Error 1685 Could not restore table `¥ü`.`§Æ`

Note in the last errors, that the table case is different in the first error (which is most probably generated by CREATE TABLE statement executed from within RESTORE) and the second error (which is generated by RESTORE itself). This suggest that there is confusion about the upper/lower case of the table name.

I can also observe this in servers log

090226 13:19:30 [Warning] Setting lower_case_table_names=2 because file system for <path> is case insensitive

which supports the theory that this is a problem with handling case in table names.

How to repeat:
Xref search for this failure: http://tinyurl.com/a9qrh3

Problem can be repeated manually when running this test on powermacg5.
[5 Mar 2009 15:30] Jørgen Løland
This might be a duplicate of bug#43363
[5 Mar 2009 15:36] Jørgen Løland
Could also be related to bug#39063
[2 Apr 2009 11:05] Jørgen Løland
The fixes to the bugs above did not fix the problem.
[3 Apr 2009 9:41] Jørgen Løland
The error occurs because the table has not been removed from the table definition cache. The error comes from sql_table.cc around line 3599:

-------------------
    /*
      We don't assert here, but check the result, because the table could be
      in the table definition cache and in the same time the .frm could be
      missing from the disk, in case of manual intervention which deletes
      the .frm file. The user has to use FLUSH TABLES; to clear the cache.
      Then she could create the table. This case is pretty obscure and
      therefore we don't introduce a new error message only for it.
    */
     if (get_cached_table_share(db, alias))
    {
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
      goto unlock_and_end;
    }
-------------

Adding FLUSH TABLES after dropping the database in the backup_datatypes.test file solves the problem for backup. This seems to be a bug in the server code.
[3 Apr 2009 11:51] Jørgen Løland
IRC with Dmitry Lenev:

The server APIs for openening and locking tables (probably others as well) expect table names in a normalized form. This means that if lower_case_table_names>0, the APIs expect *lower case table names*. Backup, however, gets and uses the table names found in INFORMATION_SCHEMA.TABLES. If lctn=2, the names there may contain upper case characters. The problem in this bug is that backup does not convert names to lower case before calling these server functions.

The server functions in question take the table names in form of TABLE_LIST, so we need to check all places in the backup code that creates such lists and do the same as st_select_lex::add_table_to_list does:

  if (lower_case_table_names && table->table.length)
    table->table.length= my_casedn_str(files_charset_info, table->table.str);
[29 Apr 2009 14:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/73029

2698 Jorgen Loland	2009-04-29
      Bug#43220 - Test backup_datatypes fails on powermacg5 platform.
      
      The server APIs for openening and locking tables et al. expect table
      names in a normalized form. This means that if lower_case_table_names>0, the APIs expect
      lower case table names. Backup, however, gets and uses the table names found in
      INFORMATION_SCHEMA.TABLES. If lctn=2, the names there may contain upper case characters.
      
      With this patch, backup normalizes table names used internally. I.e., if lctn>0, table names are represented in lower case where backup/restore calls server code.
     @ sql/backup/backup_aux.h
        Make the table names backup/restore uses to call server code lower case if lower_case_table_names is set.
[29 Apr 2009 15:33] Chuck Bell
Patch approved. Works on Windows.
[30 Apr 2009 6:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/73075

2702 Jorgen Loland	2009-04-30
      Bug#43220 - Test backup_datatypes fails on powermacg5 platform.
            
      The server APIs for openening and locking tables et al. expect table an database
      names in a normalized form. This means that if lower_case_table_names>0, the APIs expect
      lower case table/db names. Backup, however, gets and uses the names found in
      INFORMATION_SCHEMA.TABLES. If lctn=2, the names there may contain upper case characters.
            
      With this patch, backup normalizes table and database names used internally. I.e., if lctn>0, table and database names are represented in lower case where backup/restore calls server code.
     @ mysql-test/suite/backup/t/backup_datatypes.test
        Reenable test on powermac
     @ sql/backup/backup_aux.h
        Make the table and database names backup/restore uses to call server code lower case if lower_case_table_names is set.
[30 Apr 2009 7:41] Rafal Somla
Good to push.
[6 May 2009 9:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/73464

2804 Jorgen Loland	2009-05-06
      BUG#43220 - Test backup_datatypes fails on powermacg5 platform.
      
      The previous patch for this bug did not solve the issue. Disabling backup_datatypes.test on powermac platform.
     @ mysql-test/suite/backup/t/backup_datatypes.test
        Test disabled on powermac platform due to bug 43220.
[8 May 2009 7:08] Jørgen Løland
The committed patch fixed a bug in the backup code, only to uncover a new bug in the server. I created BUG#44738 to track that issue. Most likely, the only thing that remains on this bug is to reenable the test on powermacg5 once BUG#44738 is fixed.
[27 May 2009 13:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75055

2816 Jorgen Loland	2009-05-27
      Bug#43220 - Test backup_datatypes fails on powermacg5 platform.
      
      Followup patch enabling backup_datatypes on powermacg5.
     @ mysql-test/suite/backup/t/backup_datatypes.test
        Enable test on powermacg5.
[25 Jun 2009 14:39] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090625143727-9gqcfzh7ajuk66oj) (version source revid:jorgen.loland@sun.com-20090527133405-du5dbxqvkak51sdl) (merge vers: 6.0.12-alpha) (pib:11)
[25 Jun 2009 22:15] Paul DuBois
Test case changes. No changelog entry needed.