Bug #2994 | lower_case_table_names=2 is not sensible for InnoDB | ||
---|---|---|---|
Submitted: | 27 Feb 2004 7:26 | Modified: | 5 Mar 2004 4:40 |
Reporter: | Heikki Tuuri | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S1 (Critical) |
Version: | 4.0.18 | OS: | MacOS (OS X) |
Assigned to: | Michael Widenius | CPU Architecture: | Any |
[27 Feb 2004 7:26]
Heikki Tuuri
[27 Feb 2004 13:28]
Bruce Dembecki
OK, so to summarize Heikki's excellent and rapid input InnoDB can't currently deal with lower_case_table_names=2 and from my experience to date MySQL 4.0.18 on Mac OSX 10.3 won't run in any mode other than lower_case_table_names=2. Shortest term fix for my immediate problem would be to tell me how I can change lower_case_table_names to a different value, ideally we want 0 because our applications are well written and always work knowing that case is sensitive. It seems that there is a second bug here in that on Mac OSX MySQL sets itself to lower_case_table_names=2 ignoring or overwriting our "set-variable = lower_case_table_names=0" line in my.cnf. For what it is worth we have also tried using the line formated as "lower_case_table_names=0". So in combination the fact that InnoDB and lower_case_table_names=2 don't mix and the fact that Mac OSX is overwriting our settings and using lower_case_table_names=2 means we can't use 4.0.18 at all.
[27 Feb 2004 15:24]
Sergei Golubchik
Bruce, use lower_case_table_names=1 it won't be changed to lower_case_table_names=2 automatically
[27 Feb 2004 23:36]
Heikki Tuuri
How about this way to fix the value 2: MySQL could look at the name of the .frm file, and internally convert all table names to the same case as the in the name of the .frm file. The way the user specifies the name in an arbitrary SQL query (except CREATE) should not affect the internal name of the table. I think this is the most logical way on case-insensitive file systems. Regards, Heikki
[28 Feb 2004 0:20]
Bruce Dembecki
Sergei suggested: Bruce, use lower_case_table_names=1 it won't be changed to lower_case_table_names=2 automatically The manual states that a value of 1 behaves like: Table and database names are not case sensitive and are stored on disk in lowercase. MySQL will convert all table names to lowercase on storage and lookup. This is the default on Windows and Mac OS X systems. (This option also applies to database names as of MySQL 4.0.2, and to table aliases as of 4.1.1.) I have 50 databases with 36 tables each containing mixed case table names, already stored in InnoDB data... it may be true that with lower_case_table_names=1 new table and database names are stored on disk in lowercase, but it won't affect the 1500+ tables I already have in InnoDB storage space with mixed case table names and of course MySQL will convert all the table names to lowercase as queries come in, so they still won't match what InnoDB has in it's filespace. Using any valid value of lower_case_table_names with 4.0.18 generates errors such as the one described above. In the case of a value of 0 or 2 it uses 2 and as Heikki says 2 and InnoDB aren't compatible. In the case of 1 it converts incoming queries to lower case table names and that doesn't match what InnoDB already has... so every attempt to use 4.0.18 has failed with MySQL and InnoDB unable to sort out what tables they are being asked about. The only truly workable solution here is to use a value of 0 and have it behave in a case sensitive manner, but for reasons I don't understand, it won't do that... I understand the desire to add this feature to make the MySQL product more idiot proof so even people who don't understand the concept of case sensitive file systems or who write sloppy code can successfully use MySQL, but the result of this implementation as it currently stands is to penalize those who write good applications and follow the rules as our tables are now unrecognized by MySQL. I'm fine in principal with you setting the default value for OSX to 1, and even making the features on the 2 value available (although I don't think Heikki is too pleased on that issue), but don't offer these features at the expense of the original functionality... we need to have an option to use the behavior specified by lower_case_table_names=0... you can't be converting our queries but not our existing tables. As to the thought of converting our code to be all lower case, it isn't going to happen... we have 20 live application servers serving a total of 2 instances for each of 50 applications accessing 6 MySQL servers with ~1500 tables in InnoDB... I could write a script to relatively painlessly ALTER all my tables to MyISAM and back again to InnoDB under 4.0.18 which would result in them all being stored with lower case table names, but it would take hours and hours to run... in the meanwhile we'd be offline, and we can't be offline for hours and hours. Once that was done it would take many weeks of engineering resources to go through all our application code and convert all the table names in the software. We followed the rules of good programming and wrote everything so it would be case sensitive. We didn't break this. Side issue... assuming you and Heikki work out a solution and somewhere along the way lower_case_table_names=2 becomes workable... what is the performance overhead involved in changing every incoming query's table names to lower case on the fly? I'm sure it is tiny looked at on it's own... but we do over 300 Million queries each week, 300 Million times a tiny perfomance overhead becomes big system resource drain guys... Another argument why we need to be able to use lower_case_table_names=0 regardless of our platform. Bruce
[5 Mar 2004 4:40]
Michael Widenius
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html Additional info: Thanks for the good description in this bug report. I hope that the workaround we have added in the 4.0.18 tree (fix will be in 4.0.19 and 4.1.2) will help solve your problems. The reason we introduced lower_case_table_names=2 was that if you use MyISAM tables on a case insensitive file system and use them with mixed case, then you will get an index file corruption as the MyISAM table handler will not notice that you are using the same files in conflicting operations. lower_case_table_names=2 also allows on to move files between different file system, independent of the case sensitiviness of them (as long you follow some simple roles). A lot of MySQL users on windows have requested this feature from us. What was left out of the documentation is that if you use lower_case_table_names=2 then all InnoDB tables will be stored and retrived in lower case (to ensure that the user can use them case insensitive). We verified that there was no problem on windows, but missed to test this properly on Mac OS X on a system with old InnoDB tables :( (I didn't know that InnoDB stored files differently between these operation systems). The way to get this to work is to: - Make a mysqldump of all InnoDB tables - Drop them from the database - Start mysqld with --lower-case-table-names=2 - Insert them again. To make life a little easyer for people that gets hit by this bug on MacOS X we have done the following: - Added a lot of documentation about this issue in the MySQL manual. - If you specify --lower-case-table-names=0 on the command line or in an option file MySQL will honor this flag (it will not automaticly change it to 2). If the file system is case insensitive it will write a warning in the error log that if one is not carefull one can crash an MyISAM index. Regards, Monty