MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:June 16 2010 6:02pm
Subject:bzr commit into connector-net-6.2 branch (vvaintroub:859) Bug#53865
Bug#54152
View as plain text  
#At file:///H:/connector_net/6.2/ based on revid:vvaintroub@stripped

  859 Vladislav Vaintroub	2010-06-16
      Bug #53865 , Bug #54152 -fixed crashes in long queries when logging is turned on.
      Crashes mostly result from the assumption that query is welll-formed, the assumption will be wrong in most cases, since query is  truncated to 300 chars,

    modified:
      CHANGES
      MySql.Data/Provider/Source/common/QueryNormalizer.cs
      MySql.Data/Tests/Source/Syntax.cs
=== modified file 'CHANGES'
--- a/CHANGES	2010-06-10 19:25:08 +0000
+++ b/CHANGES	2010-06-16 18:02:25 +0000
@@ -1,3 +1,4 @@
+- fix crashes on long queries, when logging is turned on (bug #53865, bug #54152)
 - Try to avoid exception when Connection is closed by garbage collector (bug #53457)
 - Added trace message in exception blog in MySqlConnection.Abort() method (bug #52769)
 - changed mapping of latin1 from latin1 to windows-1252 (bug #51927)

=== modified file 'MySql.Data/Provider/Source/common/QueryNormalizer.cs'
--- a/MySql.Data/Provider/Source/common/QueryNormalizer.cs	2010-03-05 20:19:45 +0000
+++ b/MySql.Data/Provider/Source/common/QueryNormalizer.cs	2010-06-16 18:02:25 +0000
@@ -154,8 +154,12 @@ namespace MySql.Data.Common
             {
                 // find the close ')'
                 while (++pos < tok.Count)
-                    if (tok[pos].Type == TokenType.Symbol && tok[pos].Text == ")") break;
-                Debug.Assert(pos < tok.Count);
+                {
+                    if (tok[pos].Type == TokenType.Symbol && tok[pos].Text == ")")
+                        break;
+                    if (pos == tok.Count-1)
+                        break;
+                }
                 parenIndices.Add(pos);
 
                 // now find the next "real" token
@@ -206,12 +210,14 @@ namespace MySql.Data.Common
         private void CollapseInList(List<Token> tok, ref int pos)
         {
             Token t = GetNextRealToken(tok, ref pos);
-            Debug.Assert(t.Text == "(");
+            // Debug.Assert(t.Text == "(");
+            if (t == null)
+                return;
 
             // if the first token is a keyword then we likely have a 
             // SELECT .. IN (SELECT ...)
             t = GetNextRealToken(tok, ref pos);
-            if (t.Type == TokenType.Keyword) return;
+            if (t == null || t.Type == TokenType.Keyword) return;
 
             int start = pos;
             // first find all the tokens that make up the in list

=== modified file 'MySql.Data/Tests/Source/Syntax.cs'
--- a/MySql.Data/Tests/Source/Syntax.cs	2010-03-10 19:14:18 +0000
+++ b/MySql.Data/Tests/Source/Syntax.cs	2010-06-16 18:02:25 +0000
@@ -468,5 +468,66 @@ namespace MySql.Data.MySqlClient.Tests
             {
             }
         }
+
+        /// <summary>
+        /// Bug #53865 : crash in QueryNormalizer, "IN" clause incomplete
+        /// </summary>
+        [Test]
+        public void QueryNormalizerCrash1()
+        {
+
+            execSQL(
+                "CREATE TABLE  extable_1 (x_coord int, y_coord int, z_coord int,"+
+                "edge_id int, life_id int)") ;
+            execSQL("CREATE TABLE  extable_2 (daset_id int, sect_id int, "+
+              "xyz_id  int, edge_id int, life_id int, another_id int, yetanother_id int)");
+
+            string connStr = GetConnectionString(true) + ";logging=true";
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                MySqlCommand cmd = new MySqlCommand(
+                    "SELECT tblb.x_coord, tblb.y_coord, tblb.z_coord, " + 
+                    "tbl_c.x_coord, tbl_c.y_coord, tbl_c.z_coord, tbl_a.edge_id, " + 
+                    "tbl_a.life_id, tbl_a.daset_id, tbl_a.sect_id, tbl_a.yetanother_id," +
+                    " IFNULL(tbl_a.xyz_id,0) FROM extable_2 tbl_a, extable_1 tblb, " + 
+                    "extable_1 tbl_c WHERE tbl_a.daset_id=208 AND tbl_a.sect_id IN "+
+                    "(1,2,3,4,5,6,7)",
+                    c);
+                Console.WriteLine(cmd.ExecuteScalar());
+            }
+        }
+
+        /// <summary>
+        /// Bug #54152 : Crash in QueryNormalizer, VALUES incomplete
+        /// </summary>
+        [Test]
+        public void QueryNormalizerCrash2()
+        {
+             execSQL("CREATE TABLE bug54152 (id INT, expr INT,name VARCHAR(20),"+
+                 "fld4 VARCHAR(10), fld5 VARCHAR(10), fld6 VARCHAR(10),"+
+                 "fld7 VARCHAR(10), fld8 VARCHAR(10), fld9 VARCHAR(10),"+
+                 "fld10 VARCHAR(10), PRIMARY KEY(id))");
+
+            string connStr = GetConnectionString(true) + ";logging=true";
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                string query =
+                    "INSERT INTO bug54152 VALUES "+
+                    "(1,1, 'name 1',1,1,1,1,1,1,1)," +
+                    "(2,2,'name 2',2,2,2,2,2,2,2)," +
+                    "(3,3,'name 3',3,3,3,3,3,3,3)," +
+                    "(4,4,'name 4',4,4,4,4,4,4,4)," +
+                    "(5,5,'name 5',5,5,5,5,5,5,5)," +
+                    "(6,6,'name 6',6,6,6,6,6,6,6)," +
+                    "(7,7,'name 7',7,7,7,7,7,7,7)," +
+                    "(8,8,'name 8',8,8,8,8,8,8,8)," +
+                    "(9,9,'name 9',9,9,9,9,9,9,9)," +
+                    "(10,10,'name 10',10,10,10,10,10,10,10)";
+                MySqlCommand cmd = new MySqlCommand(query, c);
+                cmd.ExecuteNonQuery();
+            }
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20100616180225-u2oftzsau9u1cw7v.bundle
Thread
bzr commit into connector-net-6.2 branch (vvaintroub:859) Bug#53865Bug#54152Vladislav Vaintroub16 Jun