Bug #23268 System.FormatException when invoking procedure with ENUM input parameter
Submitted: 13 Oct 2006 17:22 Modified: 29 Oct 2006 4:53
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.0.1-beta OS:Microsoft Windows (Windows XP SP2)
Assigned to: Reggie Burnett CPU Architecture:Any
Tags: enum, stored procedure, System.FormatException

[13 Oct 2006 17:22] Todd Farmer
Description:
System.FormatException is generated when invoking a stored procedure that is defined with an IN parameter of ENUM type.  The error occurs regardless of whether the input parameter is a string or an integer data type.

One possible workaround for affected users is to redefine the stored procedure to use a different data type for the IN paramter.

The stack trace is below:

MySql.Data.MySqlClient.Tests.Csc12029Tests.ProcEnumParamTest : System.FormatException : Input string was not in a correct format.   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info)
   at System.Byte.Parse(String s)
   at MySql.Data.MySqlClient.ISSchemaProvider.ParseType(String type, String sql_mode, DataRow parmRow) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ISSchemaProvider.cs:line 537
   at MySql.Data.MySqlClient.ISSchemaProvider.ParseParameter(String parmDef, ContextString cs, String sqlMode, DataRow parmRow) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ISSchemaProvider.cs:line 488
   at MySql.Data.MySqlClient.ISSchemaProvider.ParseProcedureBody(DataTable parametersTable, String body, DataRow row, String nameToRestrict) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ISSchemaProvider.cs:line 441
   at MySql.Data.MySqlClient.ISSchemaProvider.GetParametersFromShowCreate(DataTable parametersTable, String[] restrictions, DataTable routines) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ISSchemaProvider.cs:line 364
   at MySql.Data.MySqlClient.ISSchemaProvider.GetProcedureParameters(String[] restrictions, DataTable routines) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ISSchemaProvider.cs:line 219
   at MySql.Data.MySqlClient.ProcedureCache.GetProcData(MySqlConnection connection, String spName) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ProcedureCache.cs:line 120
   at MySql.Data.MySqlClient.ProcedureCache.AddNew(MySqlConnection connection, String spName) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ProcedureCache.cs:line 79
   at MySql.Data.MySqlClient.ProcedureCache.GetProcedure(MySqlConnection conn, String spName) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\ProcedureCache.cs:line 61
   at MySql.Data.MySqlClient.StoredProcedure.ProcessCommandText() in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\StoredProcedure.cs:line 73
   at MySql.Data.MySqlClient.StoredProcedure.get_ProcessedCommandText() in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\StoredProcedure.cs:line 61
   at MySql.Data.MySqlClient.Statement.BindParameters() in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\Statement.cs:line 80
   at MySql.Data.MySqlClient.Statement.Execute(MySqlParameterCollection parameters) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\Statement.cs:line 62
   at MySql.Data.MySqlClient.PreparableStatement.Execute(MySqlParameterCollection parameters) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\PreparableStatement.cs:line 94
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\command.cs:line 373
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\mysqlclient\command.cs:line 312
   at MySql.Data.MySqlClient.Tests.Csc12029Tests.ProcEnumParamTest() in C:\Program Files\MySQL\MySQL Connector Net 5.0.1\Source\TestSuite\Csc12029.cs:line 97

How to repeat:
Test case attached.

Create a procedure with an ENUM IN parameter.  Try to invoke this stored procedure using Connector/NET 5.0.1-beta.

Suggested fix:
Eliminate System.FormatException when using ENUM input parameters.
[13 Oct 2006 17:24] Todd Farmer
Test case

Attachment: Csc12029.cs (text/plain), 2.70 KiB.

[23 Oct 2006 15:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14197
[23 Oct 2006 15:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14198
[29 Oct 2006 4:53] MC Brown
A note has been added to the 5.0.2 changelog.