mysql-connector-net-6.9.3 bug.
Posted by: KIM WANJUN
Date: September 12, 2014 01:09AM

In the middle of "ExecuteScalar()" function of MySql.Data.MySqlClient.MySqlCommand in MySql.Data.command.cs source file,
You can see :

1 #if !CF && !RT
2 // give our interceptors a shot at it first
3 if (connection != null &&
4 connection.commandInterceptor.ExecuteScalar(CommandText, ref val))
5 return val;
6 #endif

The problem is at 4, value of connection.commandInterceptor can be null. There is a calling of ExecuteScalar() method WITH OUT validation.
In command.cs, every sentence which calls method of connection.commandInterceptor is used with validation except ExecuteScalar().
So the correction should be :

1 #if !CF && !RT
2 // give our interceptors a shot at it first
3 if (connection != null &&
4 connection.commandInterceptor != null && // Newly inserted.
5 connection.commandInterceptor.ExecuteScalar(CommandText, ref val))
6 return val;
7 #endif

You can say that it's trivial, because people usually call ExecuteReader() or ExecuteNonQuery() rather than ExecuteScalar().
Keep it mind that ExecuteScalar() method also called by MySql connector itself.
When you call MySqlDataAdapter.AddToBatch() to stack your prepared command for batch process.
Call flow would be :

MySql.Data.MySqlDataAdapter.AddToBatch() // dataadapter.cs
commandToBatch.GetCommandTextForBatching() // command.cs
MySqlCommand.ExecuteScalar().ToString();// command.cs, need to know @@sql_mode to make more precise SQL sentence..
// Oops !, it calls ExecuteScalar().

Connectors from 6.5.7 to 6.9.3 with commandInterceptor facility have the problem. Before 6.5.7 free from it.
I wish I'm wrong.

Any suggestions ?

Options: ReplyQuote


Subject
Written By
Posted
mysql-connector-net-6.9.3 bug.
September 12, 2014 01:09AM
September 14, 2014 07:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.