Bug #44473 fails to execute stored procedures if the database name contains a period
Submitted: 25 Apr 2009 7:54 Modified: 6 Dec 2010 6:35
Reporter: Rami Abughazaleh Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.1.5 OS:Windows (2003 Server Enterprise Edition)
Assigned to: Lawrenty Novitsky CPU Architecture:Any

[25 Apr 2009 7: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 2009 7: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 2009 8:17] Rami Abughazaleh
Ok, thank you. :)
[2 Sep 2010 12:50] Tonci Grgin
After recent testing, it appears this is a bug in CLI lib that has been fixed lately. I have yet to confirm this.
[3 Sep 2010 5:39] Tonci Grgin
Bug#56510
[6 Dec 2010 6:35] Bogdan Degtyariov
SQLProcedures worked correctly in Connector/ODBC 5.1.8:
------------------------------------------------------------------
SQLProcedures:
				In:				StatementHandle = 0x007F2D80, 
										CatalogName = "MyDatabase 1.0.1.0", NameLength1 = 18, SchemaName = SQL_NULL_HANDLE, NameLength2 = 0, 
										ProcName = "%", NameLength3 = 1
				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"
"mydatabase 1.0.1.0", <Null>, "SP_BUG44473", <Null>, <Null>, <Null>, "", 1
1 row fetched from 8 columns.
------------------------------------------------------------------
ADO test case worked well too.

The bug report is closed.

If your application is still displaying errors, please attach the entire project with all source files.