Bug #13777 MySqlCommandBuilder crash if select query ends with ;
Submitted: 5 Oct 2005 18:14 Modified: 10 Nov 2005 18:25
Reporter: jose manuel enriquez Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.6 OS:Windows (winxp)
Assigned to: CPU Architecture:Any

[5 Oct 2005 18:14] jose manuel enriquez
Description:

Using Connector/Net 1.0.6

If the query ends with ; (standar syntax of SQL)  select * from mytable; then GetDeleteCommand, GetInsertCommand and GetUpdateCommand (the first used) of MySqlCommandBuilder throws the MySqlException:

Message: #42000Query was empty
Number: 1065
IsFatal: False
Trace: 
MySql.Data.MySqlClient.MySqlException: #42000Query was empty
   at MySql.Data.MySqlClient.PacketReader.CheckForError()
   at MySql.Data.MySqlClient.PacketReader.ReadHeader()
   at MySql.Data.MySqlClient.PacketReader.OpenPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId)
   at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
   at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
   at MySql.Data.MySqlClient.MySqlCommand.Consume()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at MySql.Data.MySqlClient.MySqlCommandBuilder.GenerateSchema()
   at MySql.Data.MySqlClient.MySqlCommandBuilder.GetUpdateCommand()
   at TestConnector.Form1.Leer() in c:\test\testconnector\testconnector\form1.cs:line 95

How to repeat:

Simply:

MySqlDataAdapterd da = new MySqlDataAdapter("select * from mytable;", conn);
conn.Open();
MySqlCommandBuilder cb = new MySqlCommandBuilder(da,true);
da.DeleteCommand = cb.GetDeleteCommand(); // CRASH
da.InsertCommand = cb.GetInsertCommand();
da.UpdateCommand = cb.GetUpdateCommand();
da.Fill(ds, "paises");
...
da.Update(ds, "paises");

// crash the first used, GetDeleteCommand or GetInsertCommand or GetUpdateCommand
[5 Oct 2005 18:25] jose manuel enriquez
The same query without ; (select * from mytable instead of select * from mytable;) works well
[9 Oct 2005 11:33] Vasily Kishkin
Sorry....I was not able to reproduce the bug in my test case. Could you please create and attach simple test case ?
[19 Oct 2005 8:49] jose manuel enriquez
my software:

Mysql 5.0.13-rc-net via tcp/ip
connector/net 1.0.6.15336
sharpziplib 0.81.0.1407
xp pro sp1
vs 7.1.3088
framework dotnet 1.1.4322

my table:

use test;
CREATE TABLE `t1` (
  `id` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
)
insert into t1 values(123);

my test case:

using System;
using System.Data;
using MySql.Data.MySqlClient;

namespace TestConnector
{
	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
			MySqlConnection conn = new MySqlConnection();
			try
			{
				conn.ConnectionString = "Host=localhost;"
					+ "port=3306;"
					+ "database=test;"
					+ "CharSet=utf8;"
					+ "uid=root;" 
					+ "pwd="
					;
				MySqlDataAdapter da = new MySqlDataAdapter("select * from t1;", conn);
				DataSet ds = new DataSet("t1");
				da.Fill(ds, "t1");
				conn.Open();
				MySqlCommandBuilder cb = new MySqlCommandBuilder(da, true);
				da.DeleteCommand = cb.GetDeleteCommand(); // throws exception, "select * from t1" no
				da.InsertCommand = cb.GetInsertCommand();
				da.UpdateCommand = cb.GetUpdateCommand();
				da.Update(ds, "t1");
				Console.WriteLine("ok");
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
			}
			finally
			{
				conn.Close();
			}
			Console.ReadLine();
		}

	}
}
[23 Oct 2005 12:54] Vasily Kishkin
Thanks for test case. But I still was not able to reproduce the bug. Your test case wrote "ok". I would like to notice I use server 5.0.14 rc. Could you please re-verify the bug on 5.0.14 rc ? But I don't think the bug is server bug.
[24 Oct 2005 11:09] jose manuel enriquez
sorry, re-verify the bug on 5.0.14-rc? yes, of course, when available.
The current windows version in http://dev.mysql.com/downloads/mysql/5.0.html is 5.0.13-rc.
[24 Oct 2005 14:50] jose manuel enriquez
re-tested with 5.0.15-nt via TCP/IP, and continues...
[25 Oct 2005 11:52] Vasily Kishkin
Sorry...I think the bug is not connector or mysql server bug.
[10 Nov 2005 16:52] Mat
Connector/Net 1.0.6.15336
MySQL 4.1.15-nt

Client:WinXP, VS7.1, .NET 1.1
Server Win2k / Win2003

I have the exact same bug/error or whatever it is.
[10 Nov 2005 18:25] jose manuel enriquez
This bug was finally verified as http://bugs.mysql.com/bug.php?id=14631
Thanks.