Bug #31433 Username incorrectly cached for logon where case sensitive
Submitted: 7 Oct 2007 16:13 Modified: 13 Nov 2007 12:40
Reporter: Nick dAlterio
Status: Closed
Category:Connector/Net Severity:S3 (Non-critical)
Version:5.0.37 OS:Microsoft Windows
Assigned to: Target Version:

[7 Oct 2007 16:13] Nick dAlterio
Description:
Using .NET connectors 5.0.7 and 5.0.8.1 I find that the logon credentials are incorrectly
cached (by the server?) when there is a mistake in only case of user id. For example 

The correct user id = Test

Logon attempt 1 with User ID = test fails with the error

Access denied for user 'test'@'localhost' (using password: YES)

Logon attempt 1 with User ID = Test fails with the error

Access denied for user 'test'@'localhost' (using password: YES)

As you can see the user id appears to have been cached as the first incorrect version.

How to repeat:
The following code demonstrates the problem

using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main( string[] args )
		{

			// Connect to the DB with wrong username - lowercase first char
			using ( MySqlConnection con = new MySqlConnection(
"Database=test;Server=localhost;User Id=test;Password=test" ) )
			{
				try
				{
					con.Open();
				}   // try
				catch ( MySqlException dbe )
				{
					Console.WriteLine( dbe.Message );
				}   // catch
			}   // using

			// Connect to the DB with correct username
			using ( MySqlConnection con = new MySqlConnection(
"Database=test;Server=localhost;User Id=Test;Password=test" ) )
			{
				try
				{

					// Connect to the DB
					con.Open();
				}   // try
				catch ( MySqlException dbe )
				{
					Console.WriteLine( dbe.Message );
				}   // catch

			}   // using

		}
	}
}

Suggested fix:
Perform case sensitive check when looking for cache hits
[11 Oct 2007 9:21] Tonci Grgin
Hi Nick and thanks for your report. This sure sounds like c/NET problem so I'll start from
there.
[25 Oct 2007 21: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/36373
[25 Oct 2007 21:40] 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/36374
[25 Oct 2007 21:41] Reggie Burnett
Fixed in 5.0.9 and 5.1.4+
[13 Nov 2007 12:40] MC Brown
A note has been added to the 5.0.9, 5.1.4 and 5.2.0 changelog: 

        Data cached from the connection string could return invalid
        information because the internal routines were not using
        case-sensitive semantics. This lead to updated connection string
        options not being recognized if they were of a different case
        than the existing cached values.