Bug #47154 | Connector/NET MySqlScript tokenizer does not like empty comment lines | ||
---|---|---|---|
Submitted: | 6 Sep 2009 6:36 | Modified: | 23 Oct 2009 18:21 |
Reporter: | Bassam Tabbara | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / NET | Severity: | S3 (Non-critical) |
Version: | 5.2.7 | OS: | Any |
Assigned to: | Reggie Burnett | CPU Architecture: | Any |
[6 Sep 2009 6:36]
Bassam Tabbara
[9 Sep 2009 8:04]
Tonci Grgin
Hi Bassam and thanks for your report. I tried: cmdCreateTable.CommandText = "--" + "\n" + "-- 'quoted' comment" + "\n" + " CREATE TABLE `bug29010` (" + " `ID` int(10) unsigned NOT NULL," + " `NAME` varchar(80) default NULL," + " PRIMARY KEY (`ID`)" + " ) ENGINE=MyISAM"; cmdCreateTable.ExecuteNonQuery(); cmdCreateTable.CommandText = ("--" + "\n" + "-- 'quoted' comment" + "\n" + " CREATE PROCEDURE `SP_BUG29010`(" +"\n"+ "IN P_ID INT, -- com. param1 \n" + "IN P_NAME VARCHAR(80) -- com. param2 \n" + ") \n" + "BEGIN INSERT INTO bug29010 (`ID`, NAME) VALUES (P_ID, P_NAME); END\n"); and all comments were recognized: [09.09.09 10:01:44] - Executing command QUERY with text ='-- -- 'quoted' comment CREATE TABLE `bug29010` ( `ID` int(10) unsigned NOT NULL, `NAME` varchar(80) default NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM' [09.09.09 10:01:44] - Executing command QUERY with text ='-- -- 'quoted' comment CREATE PROCEDURE `SP_BUG29010`( IN P_ID INT, -- com. param1 IN P_NAME VARCHAR(80) -- com. param2 ) BEGIN INSERT INTO bug29010 (`ID`, NAME) VALUES (P_ID, P_NAME); END ' If you still think this is a bug, please attach complete test case so I can recheck.
[11 Sep 2009 18:40]
Bassam Tabbara
Here's a repro on 5.2.7: using System; using MySql.Data.MySqlClient; namespace MySqlBug { class Program { static string connectionString = "server=dev;database=control;user id=root;password=;Connection Reset=true;"; static void Main(string[] args) { TokenizerBug(); } static void TokenizerBug() { using (MySqlConnection cn = new MySqlConnection(connectionString)) { cn.Open(); // no space after -- MySqlScript script = new MySqlScript(cn); script.Query = @"--comment" + Environment.NewLine + @"DROP PROCEDURE IF EXISTS `Foo`;"; script.Execute(); //throws } } } } throws the following: MySql.Data.MySqlClient.MySqlException was unhandled Message="You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--comment\r\nDROP PROCEDURE IF EXISTS `Foo`' at line 1" Source="MySql.Data" ErrorCode=-2147467259 Number=1064 StackTrace: at MySql.Data.MySqlClient.MySqlStream.OpenPacket() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\MySqlStream.cs:line 177 at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\NativeDriver.cs:line 536 at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\datareader.cs:line 831 at MySql.Data.MySqlClient.MySqlDataReader.NextResult() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\datareader.cs:line 923 at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\command.cs:line 466 at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\command.cs:line 343 at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\command.cs:line 312 at MySql.Data.MySqlClient.MySqlScript.Execute() in C:\OldLaptop\Sources\mysqlconnector-bazaar\5.2\MySql.Data\Provider\Source\MySqlScript.cs:line 180 at MySqlBug.Program.TokenizerBug() in C:\Users\bassam\Documents\Visual Studio 2008\Projects\MySqlBug\MySqlBug\Program.cs:line 24 at MySqlBug.Program.Main(String[] args) in C:\Users\bassam\Documents\Visual Studio 2008\Projects\MySqlBug\MySqlBug\Program.cs:line 12 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
[13 Oct 2009 11:48]
Tonci Grgin
Verified just as described using latest c/NET sources (trunk).
[23 Oct 2009 18:21]
Reggie Burnett
This is not a bug. I refer you to the following documentation page: http://dev.mysql.com/doc/refman/5.0/en/comments.html Please see the following passage that clearly indicates that '--' must be followed by at least 1 white space character to begin a comment. There is also a link there to describe why this is. I've made a note to add a feature to our next release to support standard SQL '--' syntax in scripts. From a “-- ” sequence to the end of the line. In MySQL, the “-- ” (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on). This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.7.5.6, “'--' as the Start of a Comment”.