Bug #31658 database() returns lowercase with lower_case_table_names 2
Submitted: 17 Oct 2007 7:26 Modified: 17 Oct 2007 17:55
Reporter: Sebastian Mendel (Basic Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1.22 OS:Microsoft Windows
Assigned to: CPU Architecture:Any
Tags: qc
Triage: Triaged: D2 (Serious) / R2 (Low) / E3 (Medium)

[17 Oct 2007 7:26] Sebastian Mendel
Description:
database() returns lowercase names with lower_case_table_names 2

my problem with this:

copying a database requires first to create the database, but how the database name is really created depends on MySQL configuration -  so i need to figure out real database name before i can copy tables from old db to new db

is there any other method to figure out how the real name is of a newly created database is?

How to repeat:
mysql> show variables like "lower_case%";
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | ON    |
| lower_case_table_names | 2     |
+------------------------+-------+
2 rows in set (0.00 sec)

mysql> create database UPPERCASE;
Query OK, 1 row affected (0.00 sec)

mysql> show databases like "UPPERCASE";
+----------------------+
| Database (UPPERCASE) |
+----------------------+
| UPPERCASE            |
+----------------------+
1 row in set (0.00 sec)

mysql> use UPPERCASE
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| uppercase  |
+------------+
1 row in set (0.00 sec)

Suggested fix:
database() should return lettercase as is
[17 Oct 2007 17:55] Miguel Solorzano
Thank you for the bug report.

c:\dev\5.1>bin\mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.23-beta-nt Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show variables like "lower_case%";
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | ON    |
| lower_case_table_names | 2     |
+------------------------+-------+
2 rows in set (0.00 sec)

mysql> create database UPPERCASE;
Query OK, 1 row affected (0.00 sec)

mysql> show databases like "UPPERCASE";
+----------------------+
| Database (UPPERCASE) |
+----------------------+
| UPPERCASE            |
+----------------------+
1 row in set (0.00 sec)

mysql> use UPPERCASE
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| uppercase  |
+------------+
1 row in set (0.00 sec)

mysql> exit
Bye

c:\dev\5.1>dir data
 O volume na unidade C não tem nome.
 O Número de Série do Volume é 289B-645A

 Pasta de c:\dev\5.1\data

17/10/2007  15:52    <DIR>          .
17/10/2007  15:52    <DIR>          ..
16/10/2007  14:40    <DIR>          db7
15/10/2007  20:52    <DIR>          dbtest
17/10/2007  15:50        10.485.760 ibdata1
17/10/2007  15:51         5.242.880 ib_logfile0
14/10/2007  15:08         5.242.880 ib_logfile1
17/10/2007  15:50               551 luar.err
17/10/2007  15:51                 5 luar.pid
14/10/2007  15:06    <DIR>          mysql
14/10/2007  15:27    <DIR>          report
14/10/2007  14:03    <DIR>          test
17/10/2007  15:52    <DIR>          UPPERCASE
               5 arquivo(s)     20.972.076 bytes
               8 pasta(s)   71.981.821.952 bytes disponíveis
[21 Nov 2007 4:08] Jeffrey Pugh
Fixing the case sensitivity behavior for be ANSI-compliant is planned for 6.1, and this bug will be considered with those fixes.