Bug #59537 Different behavior from console and
Submitted: 16 Jan 2011 16:06 Modified: 14 Feb 2011 17:47
Reporter: Jorge Bastos Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.3.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[16 Jan 2011 16:06] Jorge Bastos
Description:
Howdy,

In previous connector versions (not sure which), executing a query like:

mycmd(";",mycon)
mycmd.executenonquery()

used to work, in the latest (6.3.4 & 6.3.6), an exception happens:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at MySql.Data.MySqlClient.MySqlCommand.TrimSemicolons(String sql)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()

In MySQL console, this works.
I believe this should remain with the same behavior as before, that is do nothing on a query like this one.

--
mysql> ;
ERROR:
No query specified

mysql>
--

How to repeat:
Check the attached example:
[16 Jan 2011 16:06] Jorge Bastos
Sample

Attachment: mysql semicolumn bug.zip (application/octet-stream, text), 213.46 KiB.

[17 Jan 2011 15:22] Santo Leto
Thank you for a bug report.
Verified just as described using attached testcase.

I've noted that connector net does not return nothing when executing the following commands:
  
	sql = ";"
	mycmd.CommandText = sql
	mycmd.ExecuteNonQuery()

with version 1.0.9. In all the other versions that I've tested (5.0.7, 5.1.2, 6.2.4, 6.3.6) I verified the exception:

	A first chance exception of type 'System.IndexOutOfRangeException' occurred in MySql.Data.dll
	System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/...><Description>Unhandled exception</Description><AppDomain>mysql semicolumn bug.vshost.exe</AppDomain><Exception><ExceptionType>System.IndexOutOfRangeException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Index was outside the bounds of the array.</Message><StackTrace>   at System.String.get_Chars(Int32 index)
	   at MySql.Data.MySqlClient.MySqlCommand.TrimSemicolons(String sql)
	   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
	   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
	   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
      
With a query like    

	sql = ";"

I think connector net should return a "no query specified" error - like command client does - or an error like the one connector net returns with a query like

	sql = "wrong sql;"

(i.e. "you have an error in your..."). I would not suggest to return to old behavior of version 1.0.9, where nothing happens.
[17 Jan 2011 15:45] Jorge Bastos
Howdy,

Return to the old 1.0.9 behavior or return an error it's valid, for me it can return an error or a "NO QUERY", anything else than the exception is good.
[14 Feb 2011 17:47] Reggie Burnett
Fixed in 6.0.8, 6.1.6, 6.2.5, 6.3.7+
[11 Mar 2011 15:20] Tony Bedford
An entry has been added to the 6.0.8, 6.1.6, 6.2.5, and 6.3.7 changelogs: 

MySQL Connector/NET generated an exception when executing a query consisting 
of ';', for example: 

mycmd(";",mycon) 
mycmd.executenonquery() 

The exception generated was: 

System.IndexOutOfRangeException: Index was outside the bounds of the array. 
   at MySql.Data.MySqlClient.MySqlCommand.TrimSemicolons(String sql) 
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior 
behavior) 
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() 
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()