List:Commits« Previous MessageNext Message »
From:rburnett Date:October 10 2008 10:28pm
Subject:Connector/NET commit: r1438 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Source
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Data/Provider/Source/MySqlScript.cs
   branches/5.2/MySql.Data/Tests/Source/ScriptExecution.cs
Log:
- fixed MySqlScript object so that it handles scripts with user variables


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2008-10-10 19:52:05 UTC (rev 1437)
+++ branches/5.2/CHANGES	2008-10-10 20:28:06 UTC (rev 1438)
@@ -20,7 +20,9 @@
   MySqlConnection.ConnectionString property
 - implemented Disposable pattern on MySqlTransaction class so including one in a using
statement
   and then not calling commit will cause a rollback when the using exits (bug #39817)
+- fixed MySqlScript object so that it handles scripts with user variables
   
+  
 Version 5.2.3 - 8/14/08
 - Increased the speed of MySqlDataReader.GetOrdinal dramatically by using a couple
   of hashes for lookups

Modified: branches/5.2/MySql.Data/Provider/Source/MySqlScript.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/MySqlScript.cs	2008-10-10 19:52:05 UTC (rev
1437)
+++ branches/5.2/MySql.Data/Provider/Source/MySqlScript.cs	2008-10-10 20:28:06 UTC (rev
1438)
@@ -145,6 +145,13 @@
                 connection.Open();
             }
 
+            // since we don't allow setting of parameters on a script we can 
+            // therefore safely allow the use of user variables.  no one should be using
+            // this connection while we are using it so we can temporarily tell it
+            // to allow the use of user variables
+            bool allowUserVars = connection.Settings.AllowUserVariables;
+            connection.Settings.AllowUserVariables = true;
+
             try
             {
                 string mode = connection.driver.Property("sql_mode");
@@ -179,6 +186,7 @@
             }
             finally
             {
+                connection.Settings.AllowUserVariables = allowUserVars;
                 if (openedConnection)
                 {
                     connection.Close();

Modified: branches/5.2/MySql.Data/Tests/Source/ScriptExecution.cs
===================================================================
--- branches/5.2/MySql.Data/Tests/Source/ScriptExecution.cs	2008-10-10 19:52:05 UTC (rev
1437)
+++ branches/5.2/MySql.Data/Tests/Source/ScriptExecution.cs	2008-10-10 20:28:06 UTC (rev
1438)
@@ -152,5 +152,22 @@
             args.Ignore = false;
             statementCount++;
         }
+
+        [Test]
+        public void ExecuteScriptWithUserVariables()
+        {
+            string connStr = conn.ConnectionString.ToLowerInvariant();
+            connStr = connStr.Replace("allow user variables=true",
+                "allow user variables=false");
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                string scriptText = "SET @myvar = 1";
+                MySqlScript script = new MySqlScript(scriptText);
+                script.Connection = c;
+                int count = script.Execute();
+                Assert.AreEqual(1, count);
+            }
+        }
     }
 }

Thread
Connector/NET commit: r1438 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Sourcerburnett10 Oct