From: Date: November 8 2007 6:04pm Subject: Connector/NET commit: r1095 - in branches/5.1: . Driver/Source Driver/Source/docs TestSuite/Source List-Archive: http://lists.mysql.com/commits/37354 X-Bug: 27958 Message-Id: <200711081704.lA8H4ZKN012559@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/5.1/CHANGES branches/5.1/Driver/Source/MySqlConnectionStringBuilder.cs branches/5.1/Driver/Source/command.cs branches/5.1/Driver/Source/docs/MySqlConnection.xml branches/5.1/TestSuite/Source/CommandTests.cs Log: - Added the Default Command Timeout connection string option to allow DDEX users to set an initial command timeout for very large databases (bug #27958) Modified: branches/5.1/CHANGES =================================================================== --- branches/5.1/CHANGES 2007-11-08 16:32:53 UTC (rev 1094) +++ branches/5.1/CHANGES 2007-11-08 17:04:34 UTC (rev 1095) @@ -16,6 +16,8 @@ - Marked MySqlDbType.Datetime obsolete; replaced with DateTime (just corrected capitalization) (Bug #26344) - fixed code where we were returning bit(1) as boolean but mysql treats tinyint(1) as boolean (bug #27959) + - Added the Default Command Timeout connection string option to allow DDEX users to set + an initial command timeout for very large databases (bug #27958) Version 5.1.3 - 9/19/2007 - Fixed problem with using a stored procedure that takes a parameter as a select routine Modified: branches/5.1/Driver/Source/MySqlConnectionStringBuilder.cs =================================================================== --- branches/5.1/Driver/Source/MySqlConnectionStringBuilder.cs 2007-11-08 16:32:53 UTC (rev 1094) +++ branches/5.1/Driver/Source/MySqlConnectionStringBuilder.cs 2007-11-08 17:04:34 UTC (rev 1095) @@ -49,6 +49,7 @@ bool autoEnlist, respectBinaryFlags, treatBlobsAsUTF8; string blobAsUtf8IncludePattern, blobAsUtf8ExcludePattern; Regex blobAsUtf8ExcludeRegex, blobAsUtf8IncludeRegex; + uint defaultCommandTimeout; static MySqlConnectionStringBuilder() { @@ -86,6 +87,7 @@ defaultValues.Add(Keyword.BlobAsUTF8ExcludePattern, null); defaultValues.Add(Keyword.BlobAsUTF8IncludePattern, null); defaultValues.Add(Keyword.TreatBlobsAsUTF8, false); + defaultValues.Add(Keyword.DefaultCommandTimeout, 30); } /// @@ -364,6 +366,28 @@ } } + /// + /// Gets or sets the default command timeout. + /// +#if !CF && !MONO + [Category("Connection")] + [DisplayName("Default Command Timeout")] + [Description(@"The default timeout that MySqlCommand objects will use + unless changed.")] + [DefaultValue(30)] + [RefreshProperties(RefreshProperties.All)] +#endif + public uint DefaultCommandTimeout + { + get { return defaultCommandTimeout; } + set + { + SetValue("Default Command Timeout", value); + defaultCommandTimeout = value; + } + } + + #endregion #region Authentication Properties @@ -1042,6 +1066,8 @@ case "treatblobsasutf8": case "treat blobs as utf8": return Keyword.TreatBlobsAsUTF8; + case "default command timeout": + return Keyword.DefaultCommandTimeout; } throw new ArgumentException(Resources.KeywordNotSupported, key); } @@ -1118,6 +1144,8 @@ return blobAsUtf8ExcludePattern; case Keyword.BlobAsUTF8IncludePattern: return blobAsUtf8IncludePattern; + case Keyword.DefaultCommandTimeout: + return defaultCommandTimeout; default: return null; /* this will never happen */ } @@ -1206,6 +1234,8 @@ blobAsUtf8ExcludePattern = (string)value; break; case Keyword.BlobAsUTF8IncludePattern: blobAsUtf8IncludePattern = (string)value; break; + case Keyword.DefaultCommandTimeout: + defaultCommandTimeout = ConvertToUInt(value); break; } } @@ -1382,6 +1412,7 @@ RespectBinaryFlags, TreatBlobsAsUTF8, BlobAsUTF8IncludePattern, - BlobAsUTF8ExcludePattern + BlobAsUTF8ExcludePattern, + DefaultCommandTimeout } } Modified: branches/5.1/Driver/Source/command.cs =================================================================== --- branches/5.1/Driver/Source/command.cs 2007-11-08 16:32:53 UTC (rev 1094) +++ branches/5.1/Driver/Source/command.cs 2007-11-08 17:04:34 UTC (rev 1095) @@ -67,7 +67,6 @@ updatedRowSource = UpdateRowSource.Both; cursorPageSize = 0; cmdText = String.Empty; - commandTimeout = 30; canCancel = false; timedOut = false; } @@ -142,7 +141,7 @@ #endif public override int CommandTimeout { - get { return commandTimeout; } + get { return commandTimeout == 0 ? 30 : commandTimeout; } set { commandTimeout = value; } } @@ -184,6 +183,11 @@ this.Transaction = null; connection = (MySqlConnection)value; + + // if the user has not already set the command timeout, then + // take the default from the connection + if (connection != null && commandTimeout == 0) + commandTimeout = (int)connection.Settings.DefaultCommandTimeout; } } Modified: branches/5.1/Driver/Source/docs/MySqlConnection.xml =================================================================== --- branches/5.1/Driver/Source/docs/MySqlConnection.xml 2007-11-08 16:32:53 UTC (rev 1094) +++ branches/5.1/Driver/Source/docs/MySqlConnection.xml 2007-11-08 17:04:34 UTC (rev 1095) @@ -1072,6 +1072,13 @@ Pattern that should be used to indicate which blob columns should not be treated as UTF-8. + + Default Command Timeout + 30 + + The default timeout that new MySqlCommand objects will use unless changed. + + Modified: branches/5.1/TestSuite/Source/CommandTests.cs =================================================================== --- branches/5.1/TestSuite/Source/CommandTests.cs 2007-11-08 16:32:53 UTC (rev 1094) +++ branches/5.1/TestSuite/Source/CommandTests.cs 2007-11-08 17:04:34 UTC (rev 1095) @@ -404,9 +404,31 @@ Assert.Fail(ex.Message); } } - } + /// + /// Bug #27958 Cannot use Data Source Configuration Wizard on large databases + /// + [Test] + public void DefaultCommandTimeout() + { + MySqlConnection c = new MySqlConnection("server=localhost"); + MySqlCommand cmd = new MySqlCommand("", c); + Assert.AreEqual(30, cmd.CommandTimeout); + c = new MySqlConnection("server=localhost;default command timeout=47"); + cmd = new MySqlCommand("", c); + Assert.AreEqual(47, cmd.CommandTimeout); + + cmd = new MySqlCommand(""); + Assert.AreEqual(30, cmd.CommandTimeout); + + cmd.CommandTimeout = 66; + cmd.Connection = c; + Assert.AreEqual(66, cmd.CommandTimeout); + } + } + + #region Configs public class CommandTestsSocketCompressed : CommandTests