Bug #48779 bogus 'unknown database' error when encoding long table names on windows
Submitted: 15 Nov 2009 11:28 Modified: 16 Nov 2009 12:41
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1.40 OS:Microsoft Windows (XP64)
Assigned to: CPU Architecture:Any
Tags: regression
Triage: Triaged: D4 (Minor)

[15 Nov 2009 11:28] Shane Bester
Description:
mysql> create database hello;
Query OK, 1 row affected (0.00 sec)

mysql> use hello;
Database changed

mysql> create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.00 sec)

mysql> create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
ERROR 1049 (42000): Unknown database 'hello'

How to repeat:
#on a windows server:

drop database if exists hello;
create database hello;
use hello;
create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
[15 Nov 2009 11:35] Valeriy Kravchuk
No problem like this on Mac OS X:

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.1.42-debug |
+--------------+
1 row in set (0.01 sec)

mysql> create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.39 sec)

mysql>  create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.08 sec)

mysql>  create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.07 sec)
[15 Nov 2009 12:22] Peter Laursen
This

DROP DATABASE IF EXISTS hello;
CREATE DATABASE hello;
USE hello;
CREATE TABLE `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` INT)ENGINE=MYISAM;
CREATE TABLE `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` INT)ENGINE=MYISAM;

.. works fine for me on Windows7 64 bit with 64 bit server for Windows.

SHOW FULL TABLES;
/*
Tables_in_hello                       Table_type
------------------------------------  ----------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   BASE TABLE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  BASE TABLE
*/
[15 Nov 2009 17:00] Miguel Solorzano
I couldn't repeat too:

c:\dbs>c:\dbs\5.1\bin\mysql -uroot --port=3510 --prompt="mysql 5.1 >"
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.42-Win X64-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.1 >drop database if exists hello;
Query OK, 1 row affected (0.15 sec)

mysql 5.1 >create database hello;
Query OK, 1 row affected (0.01 sec)

mysql 5.1 >use hello;
Database changed
mysql 5.1 >create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.14 sec)

mysql 5.1 >create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.17 sec)

mysql 5.1 >
[15 Nov 2009 17:23] Shane Bester
maybe the total length of path matters?  my datadir is:
E:\downloads\mysql\5.1\5.1.40\mysql-advanced-gpl-5.1.40-winx64\data
[16 Nov 2009 10:49] Peter Laursen
My path is the installer default path:
C:\ProgramData\MySQL\MySQL Server 5.1
[16 Nov 2009 12:41] Miguel Solorzano
Thank you for the bug report. Verified installing the server on path similar of the one reported:

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

c:\dbs>cd C:\Downloads\mysql\5.1\5.1.40\mysql-advanced-gpl-5.1.40-winx64

C:\Downloads\mysql\5.1\5.1.40\mysql-advanced-gpl-5.1.40-winx64>bin\mysql -uroot test
ERROR 1049 (42000): Unknown database 'test'

C:\Downloads\mysql\5.1\5.1.40\mysql-advanced-gpl-5.1.40-winx64>bin\mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.42-Win X64 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database hello;
Query OK, 1 row affected (0.05 sec)

mysql> use hello;
Database changed
mysql> create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
Query OK, 0 rows affected (0.15 sec)

mysql> create table `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`(`a` int)engine=myisam;
ERROR 1049 (42000): Unknown database 'hello'
mysql>

mysql> show variables like "datadir"\G
*************************** 1. row ***************************
Variable_name: datadir
        Value: C:\Downloads\mysql\5.1\5.1.40\mysql-advanced-gpl-5.1.40-winx64\data\
1 row in set (0.00 sec)

mysql>