List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:November 25 2009 3:14pm
Subject:bzr push into connector-net-trunk branch (reggie.burnett:803 to 804)
View as plain text  
  804 Reggie Burnett	2009-11-25
      restoring 4.1 support that was mistakenly removed.  We are officially removing 4.1 support starting with 6.3

    modified:
      MySql.Data/Provider/Properties/Resources.Designer.cs
      MySql.Data/Provider/Properties/Resources.resx
      MySql.Data/Provider/Source/CommandBuilder.cs
      MySql.Data/Provider/Source/Connection.cs
      MySql.Data/Provider/Source/Driver.cs
      MySql.Data/Provider/Source/Field.cs
      MySql.Data/Provider/Source/NativeDriver.cs
      MySql.Data/Provider/Source/Types/MySqlBinary.cs
      MySql.Data/Provider/Source/Types/MySqlDateTime.cs
      MySql.Data/Provider/Source/Types/MySqlGuid.cs
      MySql.Data/Provider/Source/Types/MySqlTime.cs
      MySql.Data/Provider/Source/command.cs
      MySql.Data/Tests/Source/GetSchemaTests.cs
  803 Reggie Burnett	2009-11-23
      a couple of small changes to our tracing

    modified:
      MySql.Data/Provider/Source/MySqlTrace.cs
      MySql.Data/Provider/Source/TracingDriver.cs
=== modified file 'MySql.Data/Provider/Properties/Resources.Designer.cs'
=== modified file 'MySql.Data/Provider/Properties/Resources.Designer.cs'
--- a/MySql.Data/Provider/Properties/Resources.Designer.cs	2009-11-20 17:04:03 +0000
+++ b/MySql.Data/Provider/Properties/Resources.Designer.cs	2009-11-25 15:14:35 +0000
@@ -700,7 +700,7 @@
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Connector/Net no longer supports server versions prior to 5.0.
+        ///   Looks up a localized string similar to Connector/Net no longer supports server versions prior to 4.1.
         /// </summary>
         public static string ServerTooOld {
             get {

=== modified file 'MySql.Data/Provider/Properties/Resources.resx'
--- a/MySql.Data/Provider/Properties/Resources.resx	2009-11-20 17:04:03 +0000
+++ b/MySql.Data/Provider/Properties/Resources.resx	2009-11-25 15:14:35 +0000
@@ -388,7 +388,7 @@
     <value>'{0}' is an illegal value for a boolean option.</value>
   </data>
   <data name="ServerTooOld" xml:space="preserve">
-    <value>Connector/Net no longer supports server versions prior to 5.0</value>
+    <value>Connector/Net no longer supports server versions prior to 4.1</value>
   </data>
   <data name="InvalidConnectionStringValue" xml:space="preserve">
     <value>The requested value '{0}' is invalid for the given keyword '{1}'.</value>

=== modified file 'MySql.Data/Provider/Source/CommandBuilder.cs'
--- a/MySql.Data/Provider/Source/CommandBuilder.cs	2009-11-09 17:54:29 +0000
+++ b/MySql.Data/Provider/Source/CommandBuilder.cs	2009-11-25 15:14:35 +0000
@@ -76,6 +76,10 @@
         /// a valid stored procedure name.</exception>
         public static void DeriveParameters(MySqlCommand command)
         {
+            if (!command.Connection.driver.Version.isAtLeast(5, 0, 0))
+                throw new MySqlException("DeriveParameters is not supported on MySQL versions " +
+                    "prior to 5.0");
+
             // retrieve the proc definitino from the cache.
             string spName = command.CommandText;
             if (spName.IndexOf(".") == -1)

=== modified file 'MySql.Data/Provider/Source/Connection.cs'
--- a/MySql.Data/Provider/Source/Connection.cs	2009-11-20 17:04:03 +0000
+++ b/MySql.Data/Provider/Source/Connection.cs	2009-11-25 15:14:35 +0000
@@ -53,6 +53,7 @@
 #if !CF
         private PerformanceMonitor perfMonitor;
 #endif
+        private bool isExecutingBuggyQuery;
         private bool abortOnTimeout;
         private string database;
         private int commandTimeout;
@@ -112,6 +113,12 @@
             }
         }
 
+        internal bool IsExecutingBuggyQuery
+        {
+            get { return isExecutingBuggyQuery; }
+            set { isExecutingBuggyQuery = value; }
+        } 
+
         internal bool SoftClosed
         {
             get 
@@ -467,7 +474,10 @@
                 ChangeDatabase(settings.Database);
 
             // setup our schema provider
-            schemaProvider = new ISSchemaProvider(this);
+            if (driver.Version.isAtLeast(5, 0, 0))
+                schemaProvider = new ISSchemaProvider(this);
+            else
+                schemaProvider = new SchemaProvider(this); 
 #if !CF
             perfMonitor = new PerformanceMonitor(this);
 #endif
@@ -647,6 +657,9 @@
 
         public void CancelQuery(int timeout)
         {
+            if (!driver.Version.isAtLeast(5, 0, 0))
+                throw new NotSupportedException(Resources.CancelNotSupported); 
+
             MySqlConnectionStringBuilder cb = new MySqlConnectionStringBuilder(
                 Settings.ConnectionString);
             cb.Pooling = false;

=== modified file 'MySql.Data/Provider/Source/Driver.cs'
--- a/MySql.Data/Provider/Source/Driver.cs	2009-11-20 17:04:03 +0000
+++ b/MySql.Data/Provider/Source/Driver.cs	2009-11-25 15:14:35 +0000
@@ -162,9 +162,28 @@
             get { return Version.isAtLeast(6,0,8); }
         }
 
+        /// <summary> 
+        /// Returns true if this connection can handle batch SQL natively 
+        /// This means MySQL 4.1.1 or later. 
+        /// </summary> 
         public bool SupportsBatch
         {
-            get { return (handler.Flags & ClientFlags.MULTI_STATEMENTS) != 0; }
+            get
+            {
+                if ((handler.Flags & ClientFlags.MULTI_STATEMENTS) != 0)
+                {
+                    if (Version.isAtLeast(4, 1, 0) && !Version.isAtLeast(4, 1, 10))
+                    {
+                        object qtType = serverProps["query_cache_type"];
+                        object qtSize = serverProps["query_cache_size"];
+                        if (qtType != null && qtType.Equals("ON") &&
+                            (qtSize != null && !qtSize.Equals("0")))
+                            return false;
+                    }
+                    return true;
+                }
+                return false;
+            }
         }
 
         #endregion

=== modified file 'MySql.Data/Provider/Source/Field.cs'
--- a/MySql.Data/Provider/Source/Field.cs	2009-11-11 17:41:52 +0000
+++ b/MySql.Data/Provider/Source/Field.cs	2009-11-25 15:14:35 +0000
@@ -295,6 +295,8 @@
 				colName = OriginalColumnName.ToUpper(CultureInfo.InvariantCulture);
             if (colName.StartsWith("CHAR("))
                 binaryOk = false;
+            else if (connection.IsExecutingBuggyQuery)
+                binaryOk = false;
         }
 
         public IMySqlValue GetValueObject()

=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
--- a/MySql.Data/Provider/Source/NativeDriver.cs	2009-11-11 19:49:07 +0000
+++ b/MySql.Data/Provider/Source/NativeDriver.cs	2009-11-25 15:14:35 +0000
@@ -191,7 +191,7 @@
             int protocol = packet.ReadByte();
             string versionString = packet.ReadString();
             version = DBVersion.Parse(versionString);
-            if (!version.isAtLeast(5, 0, 0))
+            if (!version.isAtLeast(4, 1, 1))
                 throw new NotSupportedException(Resources.ServerTooOld);
             threadId = packet.ReadInteger(4);
             encryptionSeed = packet.ReadString();

=== modified file 'MySql.Data/Provider/Source/Types/MySqlBinary.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlBinary.cs	2009-10-22 15:27:25 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlBinary.cs	2009-11-25 15:14:35 +0000
@@ -126,7 +126,9 @@
 			}
 			else
 			{
-                packet.WriteStringNoNull("_binary ");
+                if (packet.Version.isAtLeast(4, 1, 0))
+                    packet.WriteStringNoNull("_binary "); 
+
                 packet.WriteByte((byte)'\'');
 				EscapeByteArray(buffToWrite, length, packet);
                 packet.WriteByte((byte)'\'');

=== modified file 'MySql.Data/Provider/Source/Types/MySqlDateTime.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlDateTime.cs	2009-10-22 15:27:25 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlDateTime.cs	2009-11-25 15:14:35 +0000
@@ -247,11 +247,17 @@
 		{
 			string val = String.Empty;
 
-			val = String.Format("{0:0000}-{1:00}-{2:00}",
-                value.Year, value.Month, value.Day);
-            if (type != MySqlDbType.Date)
-                val = String.Format("{0} {1:00}:{2:00}:{3:00}", val,
-                    value.Hour, value.Minute, value.Second);
+            if (type == MySqlDbType.Timestamp && !packet.Version.isAtLeast(4, 1, 0))
+				val = String.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}",
+					value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second);
+			else
+			{
+				val = String.Format("{0:0000}-{1:00}-{2:00}",
+                    value.Year, value.Month, value.Day);
+                if (type != MySqlDbType.Date)
+                    val = String.Format("{0} {1:00}:{2:00}:{3:00}", val,
+                        value.Hour, value.Minute, value.Second);
+			}
             packet.WriteStringNoNull("'" + val + "'");
 		}
 
@@ -301,20 +307,67 @@
                 packet.WriteInteger(dtValue.Millisecond, 4);
 		}
 
+		private MySqlDateTime Parse40Timestamp(string s)
+		{
+			int pos = 0;
+			year = month = day = 1;
+			hour = minute = second = 0;
+
+			if (s.Length == 14 || s.Length == 8)
+			{
+				year = int.Parse(s.Substring(pos, 4));
+				pos += 4;
+			}
+			else
+			{
+				year = int.Parse(s.Substring(pos, 2));
+				pos += 2;
+				if (year >= 70)
+					year += 1900;
+				else
+					year += 2000;
+			}
+
+			if (s.Length > 2)
+			{
+				month = int.Parse(s.Substring(pos, 2));
+				pos += 2;
+			}
+			if (s.Length > 4)
+			{
+				day = int.Parse(s.Substring(pos, 2));
+				pos += 2;
+			}
+			if (s.Length > 8)
+			{
+				hour = int.Parse(s.Substring(pos, 2));
+				minute = int.Parse(s.Substring(pos + 2, 2));
+				pos += 4;
+			}
+			if (s.Length > 10)
+				second = int.Parse(s.Substring(pos, 2));
+
+			return new MySqlDateTime(type, year, month, day, hour,
+					 minute, second);
+		}
+
 		static internal MySqlDateTime Parse(string s)
 		{
 			MySqlDateTime dt = new MySqlDateTime();
-			return dt.ParseMySql(s);
+			return dt.ParseMySql(s, true);
 		}
 
 		static internal MySqlDateTime Parse(string s, Common.DBVersion version)
 		{
 			MySqlDateTime dt = new MySqlDateTime();
-			return dt.ParseMySql(s);
+			return dt.ParseMySql(s, version.isAtLeast(4, 1, 0));
 		}
 
-		private MySqlDateTime ParseMySql(string s)
+		private MySqlDateTime ParseMySql(string s, bool is41)
 		{
+			if (type == MySqlDbType.Timestamp && !is41)
+				return Parse40Timestamp(s);
+
 			string[] parts = s.Split('-', ' ', ':', '/');
 
 			int year = int.Parse(parts[0]);
@@ -339,7 +392,7 @@
 			if (length >= 0)
 			{
                 string value = packet.ReadString(length);
-                return ParseMySql(value);
+                return ParseMySql(value, packet.Version.isAtLeast(4, 1, 0));
 			}
 
             long bufLength = packet.ReadByte();

=== modified file 'MySql.Data/Provider/Source/Types/MySqlGuid.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlGuid.cs	2009-10-22 15:27:25 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlGuid.cs	2009-11-25 15:14:35 +0000
@@ -136,7 +136,9 @@
             }
             else
             {
-                packet.WriteStringNoNull("_binary ");
+                if (packet.Version.isAtLeast(4, 1, 0))
+                    packet.WriteStringNoNull("_binary "); 
+ 
                 packet.WriteByte((byte)'\'');
                 EscapeByteArray(bytes, bytes.Length, packet);
                 packet.WriteByte((byte)'\'');

=== modified file 'MySql.Data/Provider/Source/Types/MySqlTime.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlTime.cs	2009-10-22 15:27:25 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlTime.cs	2009-11-25 15:14:35 +0000
@@ -113,7 +113,7 @@
 			if (length >= 0)
 			{
                 string value = packet.ReadString(length);
-				ParseMySql(value);
+                ParseMySql(value, packet.Version.isAtLeast(4, 1, 0));
 				return this;
 			}
 
@@ -186,7 +186,7 @@
 				mValue.Days, mValue.Hours, mValue.Minutes, mValue.Seconds, mValue.Milliseconds);
 		}
 
-		private void ParseMySql(string s)
+		private void ParseMySql(string s, bool is41)
 		{
 			string[] parts = s.Split(':');
 			int hours = Int32.Parse(parts[0]);

=== modified file 'MySql.Data/Provider/Source/command.cs'
--- a/MySql.Data/Provider/Source/command.cs	2009-11-20 17:04:03 +0000
+++ b/MySql.Data/Provider/Source/command.cs	2009-11-25 15:14:35 +0000
@@ -289,6 +289,9 @@
 			// Data readers have to be closed first
 			if (connection.Reader != null)
 				throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
+
+            if (CommandType == CommandType.StoredProcedure && !connection.driver.Version.isAtLeast(5, 0, 0))
+                throw new MySqlException("Stored procedures are not supported on this version of MySQL"); 
 		}
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ExecuteNonQuery/*'/>
@@ -357,7 +360,22 @@
             if (CommandType == CommandType.TableDirect)
                 sql = "SELECT * FROM " + sql;
 
-			if (statement == null || !statement.IsPrepared)
+            // now we check to see if we are executing a query that is buggy 
+            // in 4.1 
+            connection.IsExecutingBuggyQuery = false;
+            if (!connection.driver.Version.isAtLeast(5, 0, 0) &&
+                connection.driver.Version.isAtLeast(4, 1, 0))
+            {
+                string snippet = sql;
+                if (snippet.Length > 17)
+                    snippet = sql.Substring(0, 17);
+                snippet = snippet.ToUpper(CultureInfo.InvariantCulture);
+                connection.IsExecutingBuggyQuery =
+                    snippet.StartsWith("DESCRIBE") ||
+                    snippet.StartsWith("SHOW TABLE STATUS");
+            }
+
+            if (statement == null || !statement.IsPrepared)
 			{
 				if (CommandType == CommandType.StoredProcedure)
 					statement = new StoredProcedure(this, sql);
@@ -462,6 +480,9 @@
         /// <include file='docs/mysqlcommand.xml' path='docs/Prepare2/*'/>
         private void Prepare(int cursorPageSize)
         {
+            if (!connection.driver.Version.isAtLeast(5, 0, 0) && cursorPageSize > 0)
+                throw new InvalidOperationException("Nested commands are only supported on MySQL 5.0 and later");
+
             using (new CommandTimer(Connection, CommandTimeout))
             {
                 // if the length of the command text is zero, then just return

=== modified file 'MySql.Data/Tests/Source/GetSchemaTests.cs'
--- a/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-10-22 21:24:21 +0000
+++ b/MySql.Data/Tests/Source/GetSchemaTests.cs	2009-11-25 15:14:35 +0000
@@ -49,12 +49,16 @@
             Assert.AreEqual("Indexes", dt.Rows[row++][0]);
             Assert.AreEqual("Foreign Key Columns", dt.Rows[row++][0]);
             Assert.AreEqual("UDF", dt.Rows[row++][0]);
-            Assert.AreEqual("Views", dt.Rows[row++][0]);
-            Assert.AreEqual("ViewColumns", dt.Rows[row++][0]);
-            Assert.AreEqual("Procedure Parameters", dt.Rows[row++][0]);
-            Assert.AreEqual("Procedures", dt.Rows[row++][0]);
-            Assert.AreEqual("Triggers", dt.Rows[row++][0]);
-		}
+
+            if (Version >= new Version(5, 0))
+            {
+                Assert.AreEqual("Views", dt.Rows[row++][0]);
+                Assert.AreEqual("ViewColumns", dt.Rows[row++][0]);
+                Assert.AreEqual("Procedure Parameters", dt.Rows[row++][0]);
+                Assert.AreEqual("Procedures", dt.Rows[row++][0]);
+                Assert.AreEqual("Triggers", dt.Rows[row++][0]);
+            }
+        }
 
 		/// <summary>
 		/// Bug #25907 DataType Column of DataTypes collection does'nt contain the correct CLR Datatype 


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20091125151435-7cf6fwrc5p4uh4nb.bundle
Thread
bzr push into connector-net-trunk branch (reggie.burnett:803 to 804)Reggie Burnett25 Nov