Bug #44473 fails to execute stored procedures if the database name contains a period
Submitted: 25 Apr 9:54 Modified: 27 Apr 10:17
Reporter: Rami Abughazaleh
Status: Verified
Category:Connector/ODBC Severity:S3 (Non-critical)
Version:5.1.5 OS:Microsoft Windows (2003 Server Enterprise Edition)
Assigned to: Target Version:
Triage: D4 (Minor)

[25 Apr 9:54] Rami Abughazaleh
Description:
Hi.

Using a connection string similar to:

DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=MyDatabase
1.0.1.0;USER=root;PASSWORD=password;OPTION=3

And trying to execute an arbitrary stored procedure will result in an exception as
follows:

[MySQL][ODBC 5.1 Driver][mysqld-5.1.34-community]PROCEDURE MyDatabase
1.0.1.0.my_stored_procedure does not exist

The client uses msado26.
ADODB::_CommandPtr
ADODB::_RecordsetPtr
ADODB::_ConnectionPtr
ADODB::adCmdStoredProc
CursorLocation adUseClient
m_pCommandPtr.Execute();

Any ideas?

Thank you.

How to repeat:
1. create a database with a (space and) period in the name

2. create a stored procedure in the database

3. create a (c++ \ mfc \ msado26) client and try to execute the stored procedure

Suggested fix:
A fix would probably require wrapping the database name with the "tick" character.

For example, `MyDatabase 1.0.1.0`.my_stored_procedure
[27 Apr 9:30] Tonci Grgin
Hi Rami and thanks for your report.

Verified as described. Problem seems to be in:

SQLProcedures(attached to 'MyDatabase 1.0.1.0' schema):
	In:	StatementHandle = 0x00000000000FA930, CatalogName = "MyDatabase 1.0.1.0",
NameLength1 = 4, SchemaName = "MyDatabase 1.0.1.0", NameLength2 = 4, ProcName =
SQL_NULL_HANDLE, NameLength3 = 0
	Return:	SQL_ERROR=-1
	stmt:	szSqlState = "42S02", *pfNativeError = 1146, *pcbErrorMsg = 92, *ColumnNumber =
-1, *RowNumber = -2
	MessageText = "[MySQL][ODBC 5.1 Driver][mysqld-5.1.31-log]Table 'MyDatabase
1.0.1.0.ROUTINES' doesn't exist"

SQLProcedures (attached to 'test' schema):
	In:	StatementHandle = 0x00000000000FADA0, CatalogName = "test", NameLength1 = 4,
SchemaName = "test", NameLength2 = 4, ProcName = SQL_NULL_HANDLE, NameLength3 = 0
	Return:	SQL_SUCCESS=0

Get Data All:
"PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "NUM_INPUT_PARAMS",
"NUM_OUTPUT_PARAMS", "NUM_RESULT_SETS", "REMARKS", "PROCEDURE_TYPE"
"test", <Null>, "bug43349", <Null>, <Null>, <Null>, "", 1
"test", <Null>, "bug43576_1", <Null>, <Null>, <Null>, "", 1
"test", <Null>, "bug43576_2", <Null>, <Null>, <Null>, "", 1
"test", <Null>, "nullableParameterTest", <Null>, <Null>, <Null>, "", 1
"test", <Null>, "ptestfwins", <Null>, <Null>, <Null>, "", 1
"test", <Null>, "ptestfwsel", <Null>, <Null>, <Null>, "", 1
6 rows fetched from 8 columns.

Server version: 5.1.31-log MySQL Community Server (GPL)

mysql> use `MyDatabase 1.0.1.0`;
Database changed
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| MyDatabase 1.0.1.0 |
| mysql              |
| test               |
| test1              |
+--------------------+
5 rows in set (0.01 sec)

mysql> DELIMITER //
mysql> CREATE PROCEDURE `SP_BUG44473`(IN p_1 VARCHAR(5), IN p_2 VARCHAR(5))
    -> BEGIN
    ->   SELECT p_1 AS P1, p_2 AS P2;
    -> END //
Query OK, 0 rows affected (0.03 sec)

mysql> DELIMITER ;

I do not agree with your severity setting as this problem hit's very few people using
such database names. Please see manual for naming guidelines as with names like this
you're bound to get in trouble, sooner or later.
[27 Apr 10:17] Rami Abughazaleh
Ok, thank you. :)