Added:
trunk/mysqlclient/MySqlConnectionStringBuilder.cs
Removed:
trunk/mysqlclient/ConnectionString.cs
trunk/mysqlclient/common/DBConnectionString.cs
Modified:
trunk/mysqlclient/ClientDriver.cs
trunk/mysqlclient/Connection.cs
trunk/mysqlclient/Driver.cs
trunk/mysqlclient/EmbeddedAPI.cs
trunk/mysqlclient/EmbeddedDriver.cs
trunk/mysqlclient/MySqlPool.cs
trunk/mysqlclient/MySqlPoolManager.cs
trunk/mysqlclient/ProcedureCache.cs
trunk/mysqlclient/SharedMemoryStream.cs
trunk/mysqlclient/Strings.resx
trunk/mysqlclient/common/StreamCreator.cs
trunk/mysqlclient/nativedriver.cs
Log:
Implementation of the .NET 2.0 version of MySqlConnectionStringBuilder
Modified: trunk/mysqlclient/ClientDriver.cs
===================================================================
--- trunk/mysqlclient/ClientDriver.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/ClientDriver.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -37,7 +37,7 @@
private uint[] currentLengths;
private int resultsCount;
- public ClientDriver(MySqlConnectionString settings) : base(settings)
+ public ClientDriver(MySqlConnectionStringBuilder settings) : base(settings)
{
resultSet = IntPtr.Zero;
resultsCount = 0;
@@ -77,7 +77,7 @@
//TODO: support charset, shared memory, named pipes
- IntPtr result = Connect(mysql, connectionString.Server, connectionString.UserId,
+ IntPtr result = Connect(mysql, connectionString.Server, connectionString.UserID,
connectionString.Password, connectionString.Database, connectionString.Port,
null, (uint)flags);
if (result == IntPtr.Zero)
Modified: trunk/mysqlclient/Connection.cs
===================================================================
--- trunk/mysqlclient/Connection.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/Connection.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -40,7 +40,7 @@
internal ConnectionState connectionState;
internal Driver driver;
private MySqlDataReader dataReader;
- private MySqlConnectionString settings;
+ private MySqlConnectionStringBuilder settings;
private UsageAdvisor advisor;
private bool hasBeenOpen;
private SchemaProvider schemaProvider;
@@ -55,8 +55,8 @@
public MySqlConnection()
{
//TODO: add event data to StateChange docs
- settings = new MySqlConnectionString();
- advisor = new UsageAdvisor( this );
+ settings = new MySqlConnectionStringBuilder();
+ advisor = new UsageAdvisor(this);
}
/// <include file='docs/MySqlConnection.xml' path='docs/Ctor1/*'/>
@@ -72,7 +72,7 @@
get { return procedureCache; }
}
- internal MySqlConnectionString Settings
+ internal MySqlConnectionStringBuilder Settings
{
get { return settings; }
}
@@ -141,7 +141,7 @@
#endif
public override int ConnectionTimeout
{
- get { return settings.ConnectionTimeout; }
+ get { return (int)settings.ConnectionTimeout; }
}
/// <include file='docs/MySqlConnection.xml' path='docs/Database/*'/>
@@ -216,10 +216,12 @@
try
{
- MySqlConnectionString newSettings = new MySqlConnectionString(value);
+ MySqlConnectionStringBuilder newSettings =
+ new MySqlConnectionStringBuilder(value);
settings = newSettings;
if (driver != null)
driver.Settings = newSettings;
+ //TODO: what happens if we are in a pool
}
catch (Exception)
{
Deleted: trunk/mysqlclient/ConnectionString.cs
===================================================================
--- trunk/mysqlclient/ConnectionString.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/ConnectionString.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -1,383 +0,0 @@
-// Copyright (C) 2004-2005 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.Text;
-using MySql.Data.Common;
-
-namespace MySql.Data.MySqlClient
-{
- internal enum ConnectionProtocol
- {
- Sockets, NamedPipe, UnixSocket, SharedMemory
- }
-
- /// <summary>
- /// Specifies the connection types supported
- /// </summary>
- public enum DriverType
- {
- /// <summary>Use TCP/IP sockets</summary>
- Native,
- /// <summary>Use client library</summary>
- Client,
- /// <summary>Use MySQL embedded server</summary>
- Emebedded
- }
-
- /// <summary>
- /// Summary description for MySqlConnectionString.
- /// </summary>
- internal sealed class MySqlConnectionString : DBConnectionString
- {
- private bool useUsageAdvisor;
- private int procedureCacheSize;
- private string charSet;
- private ConnectionProtocol protocol;
- private bool compress;
- private string pipeName;
- private bool allowBatch;
- private bool logging;
- private string sharedMemoryName;
- private bool supportOldSyntax;
- private string optionFile;
- private bool useSSL;
- private DriverType driverType;
- private bool allowZeroDateTime;
- private bool convertZeroDateTime;
- private bool usePerformanceMonitor;
-
- public MySqlConnectionString() : base()
- {
- useUsageAdvisor = false;
- procedureCacheSize = 25;
- protocol = ConnectionProtocol.Sockets;
- compress = false;
- allowBatch = true;
- pipeName = "MYSQL";
- logging = false;
- sharedMemoryName = "MYSQL";
- supportOldSyntax = false;
- useSSL = false;
- driverType = DriverType.Native;
- allowZeroDateTime = true;
- convertZeroDateTime = true;
- usePerformanceMonitor = false;
- }
-
- public MySqlConnectionString(string connectString) : this()
- {
- this.connectString = connectString;
- Parse();
- }
-
- #region Server Properties
-
-#if DESIGN
- [Category("Connection")]
- [Description("Protocol to use for connection to MySQL")]
- [DefaultValue(ConnectionProtocol.Sockets)]
-#endif
- public ConnectionProtocol Protocol
- {
- get { return protocol; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Name of pipe to use when connecting with named pipes (Win32 only)")]
-#endif
- public string PipeName
- {
- get { return pipeName; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Should the connection ues compression")]
- [DefaultValue(false)]
-#endif
- public bool UseCompression
- {
- get { return compress; }
- }
-
-
-
-#if DESIGN
- [Category("Connection")]
- [Description("Allows execution of multiple SQL commands in a single statement")]
- [DefaultValue(true)]
-#endif
- public bool AllowBatch
- {
- get { return allowBatch; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Enables output of diagnostic messages")]
- [DefaultValue(false)]
-#endif
- public bool Logging
- {
- get { return logging; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Name of the shared memory object to use")]
- [DefaultValue("MYSQL")]
-#endif
- public string SharedMemoryName
- {
- get { return sharedMemoryName; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Allows the use of old style @ syntax for parameters")]
- [DefaultValue(false)]
-#endif
- public bool UseOldSyntax
- {
- get { return supportOldSyntax; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Specifies the type of driver to use for this connection")]
- [DefaultValue(DriverType.Native)]
-#endif
- public DriverType DriverType
- {
- get { return driverType; }
- }
-
- public string OptionFile
- {
- get { return optionFile; }
- }
-
- #endregion
-
- #region Authentication Properties
-
-#if DESIGN
- [Category("Authentication")]
- [Description("Should the connection use SSL. This currently has no effect.")]
- [DefaultValue(false)]
-#endif
- public bool UseSSL
- {
- get { return useSSL; }
- }
-
- #endregion
-
- #region Other Properties
-
-#if DESIGN
- [Category("Other")]
- [Description("Should zero datetimes be supported")]
- [DefaultValue(false)]
-#endif
- public bool AllowZeroDateTime
- {
- get { return allowZeroDateTime; }
- }
-
-#if DESIGN
- [Category("Other")]
- [Description("Should illegal datetime values be converted to DateTime.MinValue")]
- [DefaultValue(false)]
-#endif
- public bool ConvertZeroDateTime
- {
- get { return convertZeroDateTime; }
- }
-
-#if DESIGN
- [Category("Other")]
- [Description("Character set this connection should use")]
- [DefaultValue(null)]
-#endif
- public string CharacterSet
- {
- get { return charSet; }
- }
-
-#if DESIGN
- [Category("Other")]
- [Description("Logs inefficient database operations")]
- [DefaultValue(false)]
-#endif
- public bool UseUsageAdvisor
- {
- get { return useUsageAdvisor; }
- }
-
-#if DESIGN
- [Category("Other")]
- [Description("Number of stored procedures to cache. 0 to disable.")]
- [DefaultValue(25)]
-#endif
- public int ProcedureCacheSize
- {
- get { return procedureCacheSize; }
- }
-
-#if DESIGN
- [Category("Other")]
- [Description("Should performance metrics be generated.")]
- [DefaultValue(false)]
-#endif
- public bool UsePerformanceMonitor
- {
- get { return usePerformanceMonitor; }
- }
-
- #endregion
-
- /// <summary>
- /// Takes a given connection string and returns it, possible
- /// stripping out the password info
- /// </summary>
- /// <returns></returns>
- public string GetConnectionString(bool includePass)
- {
- if (connectString == null) return String.Empty;
-
- string connStr = connectString;
- if (! PersistSecurityInfo && !includePass)
- connStr = RemovePassword(connStr);
-
- return connStr;
- }
-
- private string RemovePassword(string connStr)
- {
- return RemoveKeys(connStr, new string[2] { "password", "pwd" });
- }
-
- protected override bool ConnectionParameterParsed(string key, string value)
- {
- string lowerCaseKey = key.ToLower();
- string lowerCaseValue = value.Trim().ToLower();
- bool boolVal = lowerCaseValue == "yes" || lowerCaseValue == "true";
-
- switch (lowerCaseKey)
- {
- case "option file":
- optionFile = value;
- return true;
-
- case "driver":
- string d = value.ToLower();
- if (d == "native")
- driverType = DriverType.Native;
- else if (d == "client")
- driverType = DriverType.Client;
- else if (d == "embedded")
- driverType = DriverType.Emebedded;
- else
- throw new ArgumentException("Unknown driver type: " + value);
- return true;
-
- case "usage advisor":
- case "useusageadvisor":
- useUsageAdvisor = boolVal;
- return true;
-
- case "character set":
- case "charset":
- charSet = value;
- return true;
-
- case "use compression":
- case "compress":
- compress = boolVal;
- return true;
-
- case "protocol":
- if (value == "socket" || value == "tcp")
- protocol = ConnectionProtocol.Sockets;
- else if (value == "pipe")
- protocol = ConnectionProtocol.NamedPipe;
- else if (value == "unix")
- protocol = ConnectionProtocol.UnixSocket;
- else if (value == "memory")
- protocol = ConnectionProtocol.SharedMemory;
- return true;
-
- case "pipe name":
- case "pipe":
- pipeName = value;
- return true;
-
- case "allow batch":
- allowBatch = boolVal;
- return true;
-
- case "logging":
- logging = boolVal;
- return true;
-
- case "shared memory name":
- sharedMemoryName = value;
- return true;
-
- case "old syntax":
- case "oldsyntax":
- supportOldSyntax = boolVal;
- return true;
-
- case "convert zero datetime":
- case "convertzerodatetime":
- convertZeroDateTime = boolVal;
- return true;
-
- case "allow zero datetime":
- case "allowzerodatetime":
- allowZeroDateTime = boolVal;
- return true;
-
- case "procedure cache size":
- case "procedurecachesize":
- case "procedure cache":
- case "procedurecache":
- procedureCacheSize = Int32.Parse(value);
- return true;
-
- case "useperformancemonitor":
- case "use performance monitor":
- usePerformanceMonitor = boolVal;
- return true;
- }
-
- if (! base.ConnectionParameterParsed(key, value))
- throw new ArgumentException("Keyword not supported: '" + key + "'");
- return true;
- }
-
- }
-}
Modified: trunk/mysqlclient/Driver.cs
===================================================================
--- trunk/mysqlclient/Driver.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/Driver.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -35,7 +35,7 @@
protected DBVersion version;
protected Encoding encoding;
protected ServerStatusFlags serverStatus;
- protected MySqlConnectionString connectionString;
+ protected MySqlConnectionStringBuilder connectionString;
protected ClientFlags serverCaps;
protected bool isOpen;
protected DateTime creationTime;
@@ -46,7 +46,7 @@
protected Hashtable charSets;
protected bool hasWarnings;
- public Driver(MySqlConnectionString settings)
+ public Driver(MySqlConnectionStringBuilder settings)
{
encoding = System.Text.Encoding.GetEncoding(1252);
connectionString = settings;
@@ -73,7 +73,7 @@
get { return version; }
}
- public MySqlConnectionString Settings
+ public MySqlConnectionStringBuilder Settings
{
get { return connectionString; }
set { connectionString = value; }
@@ -100,18 +100,18 @@
public bool IsTooOld()
{
TimeSpan ts = DateTime.Now.Subtract( creationTime );
- if (ts.Seconds > Settings.ConnectionLifetime)
+ if (ts.Seconds > Settings.ConnectionLifeTime)
return true;
return false;
}
- public static Driver Create( MySqlConnectionString settings )
+ public static Driver Create(MySqlConnectionStringBuilder settings)
{
Driver d = null;
- if (settings.DriverType == DriverType.Native)
+ if (settings.DriverType == MySqlDriverType.Native)
d = new NativeDriver(settings);
#if !COMPACT_FRAMEWORK
- else if (settings.DriverType == DriverType.Client)
+ else if (settings.DriverType == MySqlDriverType.Client)
d = new ClientDriver(settings);
else
d = new EmbeddedDriver(settings);
Modified: trunk/mysqlclient/EmbeddedAPI.cs
===================================================================
--- trunk/mysqlclient/EmbeddedAPI.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/EmbeddedAPI.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -1,4 +1,4 @@
-// Copyright (C) 2004 MySQL AB
+// Copyright (C) 2006 MySQL AB
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as published by
Modified: trunk/mysqlclient/EmbeddedDriver.cs
===================================================================
--- trunk/mysqlclient/EmbeddedDriver.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/EmbeddedDriver.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -11,7 +11,7 @@
{
string[] options;
- public EmbeddedDriver(MySqlConnectionString settings) : base(settings)
+ public EmbeddedDriver(MySqlConnectionStringBuilder settings) : base(settings)
{
options = new string[2];
}
Added: trunk/mysqlclient/MySqlConnectionStringBuilder.cs
===================================================================
--- trunk/mysqlclient/MySqlConnectionStringBuilder.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/MySqlConnectionStringBuilder.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -0,0 +1,664 @@
+using System;
+using System.ComponentModel;
+using System.Data.Common;
+using MySql.Data.Common;
+using System.Globalization;
+
+namespace MySql.Data.MySqlClient
+{
+ public enum MySqlConnectionProtocol
+ {
+ Sockets, NamedPipe, UnixSocket, SharedMemory
+ }
+
+ /// <summary>
+ /// Specifies the connection types supported
+ /// </summary>
+ public enum MySqlDriverType
+ {
+ /// <summary>Use TCP/IP sockets</summary>
+ Native,
+ /// <summary>Use client library</summary>
+ Client,
+ /// <summary>Use MySQL embedded server</summary>
+ Embedded
+ }
+
+ public sealed class MySqlConnectionStringBuilder : DbConnectionStringBuilder
+ {
+ string userId, password, server;
+ string database, sharedMemName, pipeName, charSet;
+ string optionFile;
+ string originalConnectionString;
+ uint port, connectionTimeout, minPoolSize, maxPoolSize;
+ uint procCacheSize, connectionLifetime;
+ MySqlConnectionProtocol protocol;
+ MySqlDriverType driverType;
+ bool compress, connectionReset, allowBatch, logging;
+ bool oldSyntax, persistSI, usePerfMon, pooling;
+ bool cacheServerConfig, allowZeroDatetime, convertZeroDatetime;
+ bool useUsageAdvisor, useSSL;
+
+ public MySqlConnectionStringBuilder()
+ {
+ Clear();
+ }
+
+ public MySqlConnectionStringBuilder(string connstr) : base()
+ {
+ originalConnectionString = connstr;
+ ConnectionString = connstr;
+ }
+
+ #region Server Properties
+
+ public string Server
+ {
+ get { return this.server; }
+ set { CheckNullAndSet("Server", value); server = value; }
+ }
+
+ public string Database
+ {
+ get { return this.database; }
+ set { CheckNullAndSet("Database", value); database = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Protocol to use for connection to MySQL")]
+ [DefaultValue(MySqlConnectionProtocol.Sockets)]
+#endif
+ public MySqlConnectionProtocol ConnectionProtocol
+ {
+ get { return this.protocol; }
+ set { base["Protocol"] = value; protocol = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Name of pipe to use when connecting with named pipes (Win32 only)")]
+#endif
+ public string PipeName
+ {
+ get { return this.pipeName; }
+ set { CheckNullAndSet("Pipe Name", value); pipeName = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Should the connection ues compression")]
+ [DefaultValue(false)]
+#endif
+ public bool UseCompression
+ {
+ get { return this.compress; }
+ set { base["compress"] = value; compress = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Allows execution of multiple SQL commands in a single statement")]
+ [DefaultValue(true)]
+#endif
+ public bool AllowBatch
+ {
+ get { return this.allowBatch; }
+ set { base["allow batch"] = value; allowBatch = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Enables output of diagnostic messages")]
+ [DefaultValue(false)]
+#endif
+ public bool Logging
+ {
+ get { return this.logging; }
+ set { base["logging"] = value; logging = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Name of the shared memory object to use")]
+ [DefaultValue("MYSQL")]
+#endif
+ public string SharedMemoryName
+ {
+ get { return this.sharedMemName; }
+ set { CheckNullAndSet("Shared Memory Name", value); sharedMemName = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Allows the use of old style @ syntax for parameters")]
+ [DefaultValue(false)]
+#endif
+ public bool UseOldSyntax
+ {
+ get { return this.oldSyntax; }
+ set { base["Old Syntax"] = value; oldSyntax = value; }
+ }
+
+#if !CF
+ [Category("Connection")]
+ [Description("Specifies the type of driver to use for this connection")]
+ [DefaultValue(MySqlDriverType.Native)]
+#endif
+ public MySqlDriverType DriverType
+ {
+ get { return this.driverType; }
+ set { base["Driver Type"] = value; driverType = value; }
+ }
+
+ internal string OptionFile
+ {
+ get { return this.optionFile; }
+ set { CheckNullAndSet("Option File", value); optionFile = value; }
+ }
+
+ public uint Port
+ {
+ get { return this.port; }
+ set { base["Port"] = value; port = value; }
+ }
+
+ public uint ConnectionTimeout
+ {
+ get { return this.connectionTimeout; }
+ set { base["Connection Timeout"] = value; connectionTimeout = value; }
+ }
+
+ #endregion
+
+ #region Authentication Properties
+
+ public string UserID
+ {
+ get { return this.userId; }
+ set { CheckNullAndSet("User Id", value); userId = value; }
+ }
+
+ public string Password
+ {
+ get { return this.password; }
+ set { CheckNullAndSet("Password", value); password = value; }
+ }
+
+ public bool PersistSecurityInfo
+ {
+ get { return persistSI; }
+ set { base["Persist Security Info"] = value; persistSI = value; }
+ }
+
+#if !CF
+ [Category("Authentication")]
+ [Description("Should the connection use SSL. This currently has no effect.")]
+ [DefaultValue(false)]
+#endif
+ internal bool UseSSL
+ {
+ get { return useSSL; }
+ set { base["usessl"] = value; useSSL = value; }
+ }
+
+ #endregion
+
+ #region Other Properties
+
+ public bool CacheServerConfig
+ {
+ get { return cacheServerConfig; }
+ set { base["Cache Server Config"] = value; cacheServerConfig = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Should zero datetimes be supported")]
+ [DefaultValue(false)]
+#endif
+ public bool AllowZeroDateTime
+ {
+ get { return this.allowZeroDatetime; }
+ set { base["Allow Zero DateTime"] = value; allowZeroDatetime = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Should illegal datetime values be converted to DateTime.MinValue")]
+ [DefaultValue(false)]
+#endif
+ public bool ConvertZeroDateTime
+ {
+ get { return this.convertZeroDatetime; }
+ set { base["Convert Zero DateTime"] = value; convertZeroDatetime = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Character set this connection should use")]
+ [DefaultValue(null)]
+#endif
+ public string CharacterSet
+ {
+ get { return this.charSet; }
+ set { CheckNullAndSet("Character Set", value); charSet = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Logs inefficient database operations")]
+ [DefaultValue(false)]
+#endif
+ public bool UseUsageAdvisor
+ {
+ get { return useUsageAdvisor; }
+ set { base["Use Usage Advisor"] = value; useUsageAdvisor = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Number of stored procedures to cache. 0 to disable.")]
+ [DefaultValue(25)]
+#endif
+ public uint ProcedureCacheSize
+ {
+ get { return this.procCacheSize; }
+ set { base["Procedure Cache Size"] = value; procCacheSize = value; }
+ }
+
+#if !CF
+ [Category("Other")]
+ [Description("Should performance metrics be generated.")]
+ [DefaultValue(false)]
+#endif
+ public bool UsePerformanceMonitor
+ {
+ get { return usePerfMon; }
+ set { base["Use Performance Monitor"] = value; usePerfMon = value; }
+ }
+
+ #endregion
+
+ #region Pooling Properties
+
+ public uint ConnectionLifeTime
+ {
+ get { return connectionLifetime; }
+ set { base["Connection Lifetime"] = value; connectionLifetime = value; }
+ }
+
+ public bool Pooling
+ {
+ get { return pooling; }
+ set { base["Pooling"] = value; pooling = value; }
+ }
+
+ public uint MinimumPoolSize
+ {
+ get { return minPoolSize; }
+ set { base["Minimum Pool Size"] = value; minPoolSize = value; }
+ }
+
+ public uint MaximumPoolSize
+ {
+ get { return maxPoolSize; }
+ set { base["Maximum Pool Size"] = value; maxPoolSize = value; }
+ }
+
+ public bool ConnectionReset
+ {
+ get { return connectionReset; }
+ set { base["Connection Reset"] = value; connectionReset = value; }
+ }
+
+#endregion
+
+ #region Conversion Routines
+
+ private void CheckNullAndSet(string keyword, object value)
+ {
+ if (value == null)
+ throw new ArgumentException(
+ Resources.GetString("KeywordNoNull"), keyword);
+ base[keyword] = value;
+ }
+
+ private uint ConvertToUInt(object value)
+ {
+ try
+ {
+ uint uValue = (value as
IConvertible).ToUInt32(CultureInfo.InvariantCulture);
+ return uValue;
+ }
+ catch (InvalidCastException)
+ {
+ throw new ArgumentException(
+ Resources.GetString("UnableToConvertValueToUInt"), value.ToString());
+ }
+ }
+
+ private bool ConvertToBool(object value)
+ {
+ if (value is string)
+ {
+ string s = value.ToString().ToLower();
+ if (s == "yes" || s == "true") return true;
+ if (s == "no" || s == "false") return false;
+ throw new ArgumentException(
+ Resources.GetString("UnableToConvertValueToBool"), (string)value);
+ }
+ else
+ {
+ try
+ {
+ return (value as IConvertible).ToBoolean(
+ CultureInfo.InvariantCulture);
+ }
+ catch (InvalidCastException)
+ {
+ throw new ArgumentException(
+ Resources.GetString("UnableToConvertValueToBool"),
value.ToString());
+ }
+ }
+ }
+
+ private MySqlConnectionProtocol ConvertToProtocol(object value)
+ {
+ try
+ {
+ if (value is string)
+ return (MySqlConnectionProtocol)Enum.Parse(
+ typeof(MySqlConnectionProtocol), (value as string), true);
+ }
+ catch (Exception)
+ {
+ if (value is string)
+ {
+ string lowerString = (value as string).ToLower();
+ if (lowerString == "socket" || lowerString == "tcp")
+ return MySqlConnectionProtocol.Sockets;
+ else if (lowerString == "pipe")
+ return MySqlConnectionProtocol.NamedPipe;
+ else if (lowerString == "unix")
+ return MySqlConnectionProtocol.UnixSocket;
+ else if (lowerString == "memory")
+ return MySqlConnectionProtocol.SharedMemory;
+ }
+ }
+ throw new ArgumentException(
+ Resources.GetString("UnableToConvertToProtocol"), value.ToString());
+ }
+
+ private MySqlDriverType ConvertToDriverType(object value)
+ {
+ if (value is string)
+ return (MySqlDriverType)Enum.Parse(
+ typeof(MySqlDriverType), (value as string), true);
+ throw new ArgumentException(
+ Resources.GetString("UnableToConvertToDriverType"), value.ToString());
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private void Reset()
+ {
+ connectionTimeout = 15;
+ pooling = true;
+ port = 3306;
+ server = "localhost";
+ persistSI = false;
+ connectionLifetime = 0;
+ connectionReset = true;
+ minPoolSize = 0;
+ maxPoolSize = 100;
+ userId = "";
+ password = "";
+ useUsageAdvisor = false;
+ charSet = "";
+ compress = false;
+ pipeName = "MYSQL";
+ logging = false;
+ oldSyntax = false;
+ sharedMemName = "MYSQL";
+ allowBatch = true;
+ convertZeroDatetime = false;
+ database = "";
+ driverType = MySqlDriverType.Native;
+ protocol = MySqlConnectionProtocol.Sockets;
+ allowZeroDatetime = false;
+ usePerfMon = false;
+ procCacheSize = 25;
+ cacheServerConfig = false;
+ useSSL = false;
+ }
+
+ private string RemovePassword(string connStr)
+ {
+ return RemoveKeys(connStr, new string[2] { "password", "pwd" });
+ }
+
+ private string RemoveKeys(string value, string[] keys)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ string[] pairs = Utility.ContextSplit(value, ";", "\"'");
+ foreach (string keyvalue in pairs)
+ {
+ string test = keyvalue.Trim().ToLower();
+ if (test.StartsWith("pwd") || test.StartsWith("password"))
+ continue;
+ sb.Append(keyvalue);
+ sb.Append(";");
+ }
+ sb.Remove(sb.Length - 1, 1); // remove the trailing ;
+ return sb.ToString();
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Takes a given connection string and returns it, possible
+ /// stripping out the password info
+ /// </summary>
+ /// <returns></returns>
+ public string GetConnectionString(bool includePass)
+ {
+ string connStr = originalConnectionString;
+ if (!PersistSecurityInfo && !includePass)
+ connStr = RemovePassword(connStr);
+
+ return connStr;
+ }
+
+ public override void Clear()
+ {
+ base.Clear();
+ Reset();
+ }
+
+ private Keyword GetKey(string key)
+ {
+ string lowerKey = key.ToLower();
+ switch (lowerKey)
+ {
+ case "uid": case "username": case "user id": case "user name":
+ case "userid": case "user":
+ return Keyword.UserID;
+ case "host": case "server": case "data source":
+ case "datasource": case "address": case "addr":
+ case "network address":
+ return Keyword.Server;
+ case "password": case "pwd":
+ return Keyword.Password;
+ case "useusageadvisor": case "usage advisor":
+ case "use usage advisor":
+ return Keyword.UseUsageAdvisor;
+ case "character set": case "charset":
+ return Keyword.CharacterSet;
+ case "use compression": case "compress":
+ return Keyword.Compress;
+ case "pipe name": case "pipe":
+ return Keyword.PipeName;
+ case "logging":
+ return Keyword.Logging;
+ case "old syntax": case "oldsyntax":
+ return Keyword.OldSyntax;
+ case "shared memory name":
+ return Keyword.SharedMemoryName;
+ case "allow batch":
+ return Keyword.AllowBatch;
+ case "convert zero datetime":
+ case "convertzerodatetime":
+ return Keyword.ConvertZeroDatetime;
+ case "persist security info":
+ return Keyword.PersistSecurityInfo;
+ case "initial catalog": case "database":
+ return Keyword.Database;
+ case "connection timeout": case "connect timeout":
+ return Keyword.ConnectionTimeout;
+ case "port":
+ return Keyword.Port;
+ case "pooling":
+ return Keyword.Pooling;
+ case "min pool size": case "minimum pool size":
+ return Keyword.MinimumPoolSize;
+ case "max pool size": case "maximum pool size":
+ return Keyword.MaximumPoolSize;
+ case "connection lifetime":
+ return Keyword.ConnectionLifetime;
+ case "driver":
+ return Keyword.DriverType;
+ case "protocol":
+ return Keyword.Protocol;
+ case "allow zero datetime":
+ case "allowzerodatetime":
+ return Keyword.AllowZeroDatetime;
+ case "useperformancemonitor": case "use performance monitor":
+ return Keyword.UsePerformanceMonitor;
+ case "procedure cache size": case "procedurecachesize":
+ case "procedure cache": case "procedurecache":
+ return Keyword.ProcedureCacheSize;
+ case "connection reset":
+ return Keyword.ConnectionReset;
+ }
+ throw new ArgumentException(Resources.GetString("KeywordNotSupported"),
+ key);
+ }
+
+ private object GetValue(Keyword kw)
+ {
+ switch (kw)
+ {
+ case Keyword.UserID: return UserID;
+ case Keyword.Password: return Password;
+ case Keyword.Port: return Port;
+ case Keyword.Server: return Server;
+ case Keyword.UseUsageAdvisor: return UseUsageAdvisor;
+ case Keyword.CharacterSet: return CharacterSet;
+ case Keyword.Compress: return UseCompression;
+ case Keyword.PipeName: return PipeName;
+ case Keyword.Logging: return Logging;
+ case Keyword.OldSyntax: return UseOldSyntax;
+ case Keyword.SharedMemoryName: return SharedMemoryName;
+ case Keyword.AllowBatch: return AllowBatch;
+ case Keyword.ConvertZeroDatetime: return ConvertZeroDateTime;
+ case Keyword.PersistSecurityInfo: return PersistSecurityInfo;
+ case Keyword.Database: return Database;
+ case Keyword.ConnectionTimeout: return ConnectionTimeout;
+ case Keyword.Pooling: return Pooling;
+ case Keyword.MinimumPoolSize: return MinimumPoolSize;
+ case Keyword.MaximumPoolSize: return MaximumPoolSize;
+ case Keyword.ConnectionLifetime: return ConnectionLifeTime;
+ case Keyword.DriverType: return DriverType;
+ case Keyword.Protocol: return ConnectionProtocol;
+ case Keyword.ConnectionReset: return ConnectionReset;
+ case Keyword.ProcedureCacheSize: return ProcedureCacheSize;
+ case Keyword.AllowZeroDatetime: return AllowZeroDateTime;
+ case Keyword.UsePerformanceMonitor: return UsePerformanceMonitor;
+ case Keyword.CacheServerConfig: return CacheServerConfig;
+ default: return null; /* this will never happen */
+ }
+ }
+
+ private void SetValue(Keyword kw, object value)
+ {
+ switch (kw)
+ {
+ case Keyword.UserID: UserID = (string)value; break;
+ case Keyword.Password: Password = (string)value; break;
+ case Keyword.Port: Port = ConvertToUInt(value); break;
+ case Keyword.Server: Server = (string)value; break;
+ case Keyword.UseUsageAdvisor: UseUsageAdvisor = ConvertToBool(value);
break;
+ case Keyword.CharacterSet: CharacterSet = (string)value; break;
+ case Keyword.Compress: UseCompression = ConvertToBool(value); break;
+ case Keyword.PipeName: PipeName = (string)value; break;
+ case Keyword.Logging: Logging = ConvertToBool(value); break;
+ case Keyword.OldSyntax: UseOldSyntax = ConvertToBool(value); break;
+ case Keyword.SharedMemoryName: SharedMemoryName = (string)value; break;
+ case Keyword.AllowBatch: AllowBatch = ConvertToBool(value); break;
+ case Keyword.ConvertZeroDatetime: ConvertZeroDateTime =
ConvertToBool(value); break;
+ case Keyword.PersistSecurityInfo: PersistSecurityInfo =
ConvertToBool(value); break;
+ case Keyword.Database: Database = (string)value; break;
+ case Keyword.ConnectionTimeout: ConnectionTimeout = ConvertToUInt(value);
break;
+ case Keyword.Pooling: Pooling = ConvertToBool(value); break;
+ case Keyword.MinimumPoolSize: MinimumPoolSize = ConvertToUInt(value);
break;
+ case Keyword.MaximumPoolSize: MaximumPoolSize = ConvertToUInt(value);
break;
+ case Keyword.ConnectionLifetime: ConnectionLifeTime =
ConvertToUInt(value); break;
+ case Keyword.DriverType: DriverType = ConvertToDriverType(value); break;
+ case Keyword.Protocol: ConnectionProtocol = ConvertToProtocol(value);
break;
+ case Keyword.ConnectionReset: ConnectionReset = ConvertToBool(value);
break;
+ case Keyword.UsePerformanceMonitor: UsePerformanceMonitor =
ConvertToBool(value); break;
+ case Keyword.AllowZeroDatetime: AllowZeroDateTime = ConvertToBool(value);
break;
+ case Keyword.ProcedureCacheSize: ProcedureCacheSize =
ConvertToUInt(value); break;
+ case Keyword.CacheServerConfig: CacheServerConfig = ConvertToBool(value);
break;
+ }
+ }
+
+ public override object this[string key]
+ {
+ get
+ {
+ Keyword kw = GetKey(key);
+ return GetValue(kw);
+ }
+ set
+ {
+ Keyword kw = GetKey(key);
+ SetValue(kw, value);
+ }
+ }
+ }
+
+ internal enum Keyword
+ {
+ UserID,
+ Password,
+ Server,
+ Port,
+ UseUsageAdvisor,
+ CharacterSet,
+ Compress,
+ PipeName,
+ Logging,
+ OldSyntax,
+ SharedMemoryName,
+ AllowBatch,
+ ConvertZeroDatetime,
+ PersistSecurityInfo,
+ Database,
+ ConnectionTimeout,
+ Pooling,
+ MinimumPoolSize,
+ MaximumPoolSize,
+ ConnectionLifetime,
+ DriverType,
+ Protocol,
+ ConnectionReset,
+ AllowZeroDatetime,
+ UsePerformanceMonitor,
+ ProcedureCacheSize,
+ CacheServerConfig
+ }
+}
Modified: trunk/mysqlclient/MySqlPool.cs
===================================================================
--- trunk/mysqlclient/MySqlPool.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/MySqlPool.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -1,199 +1,199 @@
-// Copyright (C) 2004 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-using MySql.Data.Common;
-using System.Collections;
-
-namespace MySql.Data.MySqlClient
-{
- /// <summary>
- /// Summary description for MySqlPool.
- /// </summary>
- internal sealed class MySqlPool
- {
- private ArrayList inUsePool;
- private ArrayList idlePool;
- private MySqlConnectionString settings;
- private int minSize;
- private int maxSize;
- private ProcedureCache procedureCache;
-
- public MySqlPool(MySqlConnectionString settings)
- {
- minSize = settings.MinPoolSize;
- maxSize = settings.MaxPoolSize;
- this.settings = settings;
- inUsePool =new ArrayList();
- idlePool = new ArrayList( settings.MinPoolSize );
-
- // prepopulate the idle pool to minSize
- for (int i=0; i < minSize; i++)
+// Copyright (C) 2004 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using MySql.Data.Common;
+using System.Collections;
+
+namespace MySql.Data.MySqlClient
+{
+ /// <summary>
+ /// Summary description for MySqlPool.
+ /// </summary>
+ internal sealed class MySqlPool
+ {
+ private ArrayList inUsePool;
+ private ArrayList idlePool;
+ private MySqlConnectionStringBuilder settings;
+ private uint minSize;
+ private uint maxSize;
+ private ProcedureCache procedureCache;
+
+ public MySqlPool(MySqlConnectionStringBuilder settings)
+ {
+ minSize = settings.MinimumPoolSize;
+ maxSize = settings.MaximumPoolSize;
+ this.settings = settings;
+ inUsePool =new ArrayList();
+ idlePool = new ArrayList((int)settings.MinimumPoolSize);
+
+ // prepopulate the idle pool to minSize
+ for (int i=0; i < minSize; i++)
CreateNewPooledConnection();
- procedureCache = new ProcedureCache(settings.ProcedureCacheSize);
- }
-
- public MySqlConnectionString Settings
- {
- get { return settings; }
- set { settings = value; }
+ procedureCache = new ProcedureCache(settings.ProcedureCacheSize);
}
+ public MySqlConnectionStringBuilder Settings
+ {
+ get { return settings; }
+ set { settings = value; }
+ }
+
public ProcedureCache ProcedureCache
{
get { return procedureCache; }
- }
-
- private int CheckConnections()
- {
- int freed = 0;
- lock (inUsePool.SyncRoot)
- {
- for (int i=inUsePool.Count-1; i >= 0; i--)
- {
- Driver d = (inUsePool[i] as Driver);
- if (! d.Ping())
- {
- inUsePool.RemoveAt(i);
- freed++;
- }
- }
- }
- return freed;
- }
-
- private Driver GetPooledConnection()
- {
- Driver driver = null;
-
- // if here are no idle connections and inUsePool is full, then we
- // check each of the inUsePool connections and make sure they are
- // actually in use.
- if (idlePool.Count == 0 && inUsePool.Count == maxSize)
- {
- int freed = CheckConnections();
-
- // if we freed no connections, then we can't pull one so we return null
- if (0 == freed) return null;
- }
-
- // if we get here, then we have at least one connection in the idle pool
- lock (idlePool.SyncRoot)
- {
- for (int i=idlePool.Count-1; i >=0; i--)
- {
- driver = (idlePool[i] as Driver);
- if ( driver.Ping() )
- {
- lock (inUsePool)
- {
- inUsePool.Add(driver);
- }
- idlePool.RemoveAt(i);
- break;
- }
- else
- {
- driver.SafeClose();
- idlePool.RemoveAt(i);
- driver = null;
- }
- }
- }
-
- if ( driver != null )
- {
- driver.Settings = settings;
- driver.Reset();
- }
- else if ((idlePool.Count+inUsePool.Count) < maxSize)
- {
- // if we couldn't get a pooled connection and there is still room
- // make a new one
- driver = CreateNewPooledConnection();
- if ( driver != null)
- {
- lock (idlePool.SyncRoot)
- lock (inUsePool.SyncRoot)
- {
- idlePool.Remove( driver );
- inUsePool.Add( driver );
- }
- }
- }
-
- // make sure we stay at least minSize in our combined pools
- while ((idlePool.Count + inUsePool.Count) < minSize)
- CreateNewPooledConnection();
-
- return driver;
- }
-
- private Driver CreateNewPooledConnection()
- {
- lock(idlePool.SyncRoot)
- lock (inUsePool.SyncRoot)
- {
- // first we check if we are allowed to create another
- if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
-
- Driver driver = Driver.Create(settings);
- idlePool.Add(driver);
- return driver;
- }
- }
-
- public void ReleaseConnection(Driver driver)
- {
- lock (idlePool.SyncRoot)
- lock (inUsePool.SyncRoot)
- {
- inUsePool.Remove( driver );
- if (driver.Settings.ConnectionLifetime != 0 && driver.IsTooOld())
- driver.Close();
- else
- idlePool.Add( driver );
- }
- }
-
- public Driver GetConnection()
- {
- Driver driver = null;
-
- int start = Environment.TickCount;
- int ticks = settings.ConnectionTimeout * 1000;
-
- // wait timeOut seconds at most to get a connection
- while (driver == null && (Environment.TickCount - start) < ticks)
- driver = GetPooledConnection();
-
- // if pool size is at maximum, then we must have reached our timeout so we simply
- // throw our exception
- if (driver == null)
- throw new MySqlException("error connecting: Timeout expired. The timeout period
elapsed " +
- "prior to obtaining a connection from the pool. This may have occurred because all
" +
- "pooled connections were in use and max pool size was reached.");
-
- return driver;
- }
-
- }
-}
+ }
+
+ private int CheckConnections()
+ {
+ int freed = 0;
+ lock (inUsePool.SyncRoot)
+ {
+ for (int i=inUsePool.Count-1; i >= 0; i--)
+ {
+ Driver d = (inUsePool[i] as Driver);
+ if (! d.Ping())
+ {
+ inUsePool.RemoveAt(i);
+ freed++;
+ }
+ }
+ }
+ return freed;
+ }
+
+ private Driver GetPooledConnection()
+ {
+ Driver driver = null;
+
+ // if here are no idle connections and inUsePool is full, then we
+ // check each of the inUsePool connections and make sure they are
+ // actually in use.
+ if (idlePool.Count == 0 && inUsePool.Count == maxSize)
+ {
+ int freed = CheckConnections();
+
+ // if we freed no connections, then we can't pull one so we return null
+ if (0 == freed) return null;
+ }
+
+ // if we get here, then we have at least one connection in the idle pool
+ lock (idlePool.SyncRoot)
+ {
+ for (int i=idlePool.Count-1; i >=0; i--)
+ {
+ driver = (idlePool[i] as Driver);
+ if ( driver.Ping() )
+ {
+ lock (inUsePool)
+ {
+ inUsePool.Add(driver);
+ }
+ idlePool.RemoveAt(i);
+ break;
+ }
+ else
+ {
+ driver.SafeClose();
+ idlePool.RemoveAt(i);
+ driver = null;
+ }
+ }
+ }
+
+ if ( driver != null )
+ {
+ driver.Settings = settings;
+ driver.Reset();
+ }
+ else if ((idlePool.Count+inUsePool.Count) < maxSize)
+ {
+ // if we couldn't get a pooled connection and there is still room
+ // make a new one
+ driver = CreateNewPooledConnection();
+ if ( driver != null)
+ {
+ lock (idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
+ {
+ idlePool.Remove( driver );
+ inUsePool.Add( driver );
+ }
+ }
+ }
+
+ // make sure we stay at least minSize in our combined pools
+ while ((idlePool.Count + inUsePool.Count) < minSize)
+ CreateNewPooledConnection();
+
+ return driver;
+ }
+
+ private Driver CreateNewPooledConnection()
+ {
+ lock(idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
+ {
+ // first we check if we are allowed to create another
+ if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
+
+ Driver driver = Driver.Create(settings);
+ idlePool.Add(driver);
+ return driver;
+ }
+ }
+
+ public void ReleaseConnection(Driver driver)
+ {
+ lock (idlePool.SyncRoot)
+ lock (inUsePool.SyncRoot)
+ {
+ inUsePool.Remove( driver );
+ if (driver.Settings.ConnectionLifeTime != 0 && driver.IsTooOld())
+ driver.Close();
+ else
+ idlePool.Add( driver );
+ }
+ }
+
+ public Driver GetConnection()
+ {
+ Driver driver = null;
+
+ int start = Environment.TickCount;
+ uint ticks = settings.ConnectionTimeout * 1000;
+
+ // wait timeOut seconds at most to get a connection
+ while (driver == null && (Environment.TickCount - start) < ticks)
+ driver = GetPooledConnection();
+
+ // if pool size is at maximum, then we must have reached our timeout so we simply
+ // throw our exception
+ if (driver == null)
+ throw new MySqlException("error connecting: Timeout expired. The timeout period
elapsed " +
+ "prior to obtaining a connection from the pool. This may have occurred because all
" +
+ "pooled connections were in use and max pool size was reached.");
+
+ return driver;
+ }
+
+ }
+}
Modified: trunk/mysqlclient/MySqlPoolManager.cs
===================================================================
--- trunk/mysqlclient/MySqlPoolManager.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/MySqlPoolManager.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -43,7 +43,7 @@
pools = new Hashtable();
}
- public static MySqlPool GetPool(MySqlConnectionString settings)
+ public static MySqlPool GetPool(MySqlConnectionStringBuilder settings)
{
// make sure the manager is initialized
if (MySqlPoolManager.pools == null)
Modified: trunk/mysqlclient/ProcedureCache.cs
===================================================================
--- trunk/mysqlclient/ProcedureCache.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/ProcedureCache.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -9,13 +9,17 @@
{
private Hashtable procHash;
private Queue<int> hashQueue;
- private int maxSize;
+ private uint maxSize;
- public ProcedureCache(int size)
+ public ProcedureCache(uint size)
{
maxSize = size;
- hashQueue = new Queue<int>(maxSize);
- procHash = new Hashtable(maxSize);
+#if NET20
+ hashQueue = new Queue<int>((int)maxSize);
+#else
+ hashQueue = new Queue(maxSize);
+#endif
+ procHash = new Hashtable((int)maxSize);
}
public DataSet GetProcedure(MySqlConnection conn, string spName)
Modified: trunk/mysqlclient/SharedMemoryStream.cs
===================================================================
--- trunk/mysqlclient/SharedMemoryStream.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/SharedMemoryStream.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -51,7 +51,7 @@
memoryName = memName;
}
- public void Open(int timeOut)
+ public void Open(uint timeOut)
{
GetConnectNumber(timeOut);
SetupEvents();
@@ -63,7 +63,7 @@
CloseHandle( dataMap );
}
- private void GetConnectNumber(int timeOut)
+ private void GetConnectNumber(uint timeOut)
{
AutoResetEvent connectRequest = new AutoResetEvent(false);
connectRequest.Handle = OpenEvent( EVENT_ALL_ACCESS, false,
@@ -82,7 +82,7 @@
if (! connectRequest.Set())
throw new MySqlException( "Failed to open shared memory connection " );
- connectAnswer.WaitOne( timeOut*1000, false );
+ connectAnswer.WaitOne((int)(timeOut*1000), false );
connectNumber = Marshal.ReadInt32( connectView );
}
Modified: trunk/mysqlclient/Strings.resx
===================================================================
--- trunk/mysqlclient/Strings.resx 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/Strings.resx 2006-06-16 21:32:36 UTC (rev 251)
@@ -1,154 +1,231 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<root>
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"
/>
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"
/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"
/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="ResMimeType">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="Version">
- <value>1.0.0.0</value>
- </resheader>
- <resheader name="Reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="Writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <data name="BadVersionFormat">
- <value>Version string not in acceptable format</value>
- </data>
- <data name="NamedPipeNoSeek">
- <value>NamedPipeStream does not support seeking</value>
- </data>
- <data name="StreamAlreadyClosed">
- <value>The stream has already been closed</value>
- </data>
- <data name="BufferCannotBeNull">
- <value> The buffer cannot be null</value>
- </data>
- <data name="BufferNotLargeEnough">
- <value> Buffer is not large enough</value>
- </data>
- <data name="OffsetCannotBeNegative">
- <value> Offset cannot be negative</value>
- </data>
- <data name="CountCannotBeNegative">
- <value> Count cannot be negative</value>
- </data>
- <data name="StreamNoRead">
- <value> The stream does not support reading</value>
- </data>
- <data name="NamedPipeNoSetLength">
- <value>NamedPipeStream doesn't support SetLength</value>
- </data>
- <data name="StreamNoWrite">
- <value>The stream does not support writing</value>
- </data>
- <data name="ErrorCreatingSocket">
- <value>Error creating socket connection</value>
- <comment></comment>
- </data>
- <data name="SocketNoSeek">
- <value>Socket streams do not support seeking</value>
- </data>
- <data name="UnixSocketsNotSupported">
- <value>Unix sockets are not supported on Windows</value>
- </data>
- <data name="OffsetMustBeValid">
- <value>Offset must be a valid position in buffer</value>
- </data>
- <data name="CSNoSetLength">
- <value>SetLength is not a valid operation on CompressedStream</value>
- </data>
- <data name="FromIndexMustBeValid">
- <value>From index must be a valid index inside the from buffer</value>
- </data>
- <data name="FromAndLengthTooBig">
- <value>From index and length use more bytes than from contains</value>
- </data>
- <data name="IndexMustBeValid">
- <value>Index must be a valid position in the buffer</value>
- </data>
- <data name="IndexAndLengthTooBig">
- <value>Index and length use more bytes than to has room for</value>
- </data>
- <data name="PasswordMustHaveLegalChars">
- <value>Password must be valid and contain length characters</value>
- </data>
- <data name="ParameterCannotBeNegative">
- <value>Parameter cannot have a negative value</value>
- </data>
- <data name="ConnectionMustBeOpen">
- <value>Connection must be valid and open</value>
- </data>
- <data name="DataReaderOpen">
- <value>There is already an open DataReader associated with this Connection which
must be closed first.</value>
- </data>
- <data name="SPNotSupported">
- <value>Stored procedures are not supported on this version of MySQL</value>
- </data>
- <data name="ConnectionNotSet">
- <value>The connection property has not been set.</value>
- </data>
- <data name="ConnectionNotOpen">
- <value>The connection is not open.</value>
- </data>
- <data name="AdapterIsNull">
- <value>Improper MySqlCommandBuilder state: adapter is null</value>
- </data>
- <data name="AdapterSelectIsNull">
- <value>Improper MySqlCommandBuilder state: adapter's SelectCommand is
null</value>
- </data>
- <data name="CBMultiTableNotSupported">
- <value>MySqlCommandBuilder does not support multi-table statements</value>
- </data>
- <data name="CBNoKeyColumn">
- <value>MySqlCommandBuilder cannot operate on tables with no unique or key
columns</value>
- </data>
- <data name="ParameterCannotBeNull">
- <value>Parameter cannot be null</value>
- </data>
- <data name="ChaosNotSupported">
- <value>Chaos isolation level is not supported</value>
- </data>
- <data name="ParameterIsInvalid">
- <value>Parameter is invalid.</value>
- </data>
- <data name="ConnectionAlreadyOpen">
- <value>The connection is already open.</value>
- </data>
- <data name="KeywordNotSupported">
- <value>Keyword not supported.</value>
- </data>
- <data name="WriteToStreamFailed">
- <value>Writing to the stream failed.</value>
- </data>
- <data name="ReadFromStreamFailed">
- <value>Reading from the stream has failed.</value>
- </data>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader,
System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter,
System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long
string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color,
System.Drawing">Blue</data>
+ <data name="Bitmap1"
mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the
.NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0"
msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"
msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"
/>
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="BadVersionFormat" xml:space="preserve">
+ <value>Version string not in acceptable format</value>
+ </data>
+ <data name="NamedPipeNoSeek" xml:space="preserve">
+ <value>NamedPipeStream does not support seeking</value>
+ </data>
+ <data name="StreamAlreadyClosed" xml:space="preserve">
+ <value>The stream has already been closed</value>
+ </data>
+ <data name="BufferCannotBeNull" xml:space="preserve">
+ <value> The buffer cannot be null</value>
+ </data>
+ <data name="BufferNotLargeEnough" xml:space="preserve">
+ <value> Buffer is not large enough</value>
+ </data>
+ <data name="OffsetCannotBeNegative" xml:space="preserve">
+ <value> Offset cannot be negative</value>
+ </data>
+ <data name="CountCannotBeNegative" xml:space="preserve">
+ <value> Count cannot be negative</value>
+ </data>
+ <data name="StreamNoRead" xml:space="preserve">
+ <value> The stream does not support reading</value>
+ </data>
+ <data name="NamedPipeNoSetLength" xml:space="preserve">
+ <value>NamedPipeStream doesn't support SetLength</value>
+ </data>
+ <data name="StreamNoWrite" xml:space="preserve">
+ <value>The stream does not support writing</value>
+ </data>
+ <data name="ErrorCreatingSocket" xml:space="preserve">
+ <value>Error creating socket connection</value>
+ </data>
+ <data name="SocketNoSeek" xml:space="preserve">
+ <value>Socket streams do not support seeking</value>
+ </data>
+ <data name="UnixSocketsNotSupported" xml:space="preserve">
+ <value>Unix sockets are not supported on Windows</value>
+ </data>
+ <data name="OffsetMustBeValid" xml:space="preserve">
+ <value>Offset must be a valid position in buffer</value>
+ </data>
+ <data name="CSNoSetLength" xml:space="preserve">
+ <value>SetLength is not a valid operation on CompressedStream</value>
+ </data>
+ <data name="FromIndexMustBeValid" xml:space="preserve">
+ <value>From index must be a valid index inside the from buffer</value>
+ </data>
+ <data name="FromAndLengthTooBig" xml:space="preserve">
+ <value>From index and length use more bytes than from contains</value>
+ </data>
+ <data name="IndexMustBeValid" xml:space="preserve">
+ <value>Index must be a valid position in the buffer</value>
+ </data>
+ <data name="IndexAndLengthTooBig" xml:space="preserve">
+ <value>Index and length use more bytes than to has room for</value>
+ </data>
+ <data name="PasswordMustHaveLegalChars" xml:space="preserve">
+ <value>Password must be valid and contain length characters</value>
+ </data>
+ <data name="ParameterCannotBeNegative" xml:space="preserve">
+ <value>Parameter cannot have a negative value</value>
+ </data>
+ <data name="ConnectionMustBeOpen" xml:space="preserve">
+ <value>Connection must be valid and open</value>
+ </data>
+ <data name="DataReaderOpen" xml:space="preserve">
+ <value>There is already an open DataReader associated with this Connection
which must be closed first.</value>
+ </data>
+ <data name="SPNotSupported" xml:space="preserve">
+ <value>Stored procedures are not supported on this version of
MySQL</value>
+ </data>
+ <data name="ConnectionNotSet" xml:space="preserve">
+ <value>The connection property has not been set.</value>
+ </data>
+ <data name="ConnectionNotOpen" xml:space="preserve">
+ <value>The connection is not open.</value>
+ </data>
+ <data name="AdapterIsNull" xml:space="preserve">
+ <value>Improper MySqlCommandBuilder state: adapter is null</value>
+ </data>
+ <data name="AdapterSelectIsNull" xml:space="preserve">
+ <value>Improper MySqlCommandBuilder state: adapter's SelectCommand is
null</value>
+ </data>
+ <data name="CBMultiTableNotSupported" xml:space="preserve">
+ <value>MySqlCommandBuilder does not support multi-table
statements</value>
+ </data>
+ <data name="CBNoKeyColumn" xml:space="preserve">
+ <value>MySqlCommandBuilder cannot operate on tables with no unique or key
columns</value>
+ </data>
+ <data name="ParameterCannotBeNull" xml:space="preserve">
+ <value>Parameter cannot be null</value>
+ </data>
+ <data name="ChaosNotSupported" xml:space="preserve">
+ <value>Chaos isolation level is not supported</value>
+ </data>
+ <data name="ParameterIsInvalid" xml:space="preserve">
+ <value>Parameter is invalid.</value>
+ </data>
+ <data name="ConnectionAlreadyOpen" xml:space="preserve">
+ <value>The connection is already open.</value>
+ </data>
+ <data name="KeywordNotSupported" xml:space="preserve">
+ <value>Keyword not supported.</value>
+ </data>
+ <data name="WriteToStreamFailed" xml:space="preserve">
+ <value>Writing to the stream failed.</value>
+ </data>
+ <data name="ReadFromStreamFailed" xml:space="preserve">
+ <value>Reading from the stream has failed.</value>
+ </data>
</root>
\ No newline at end of file
Deleted: trunk/mysqlclient/common/DBConnectionString.cs
===================================================================
--- trunk/mysqlclient/common/DBConnectionString.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/common/DBConnectionString.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -1,306 +0,0 @@
-// Copyright (C) 2004 MySQL AB
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation
-//
-// There are special exceptions to the terms and conditions of the GPL
-// as it is applied to this software. View the full text of the
-// exception in file EXCEPTIONS in the directory of this software
-// distribution.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-using System;
-
-namespace MySql.Data.Common
-{
- /// <summary>
- /// Summary description for Utility.
- /// </summary>
- internal abstract class DBConnectionString
- {
- protected string connectString;
- protected bool persistSecurityInfo;
- protected string userId;
- protected string password;
- protected string host;
- protected string database;
- protected int connectionTimeout;
- protected uint port;
- protected bool pooling;
- protected int minPoolSize;
- protected int maxPoolSize;
- protected int poolLifeTime;
-
- public DBConnectionString()
- {
- persistSecurityInfo = false;
- connectionTimeout = 15;
- pooling = true;
- minPoolSize = 0;
- maxPoolSize = 100;
- port = 3306;
- password = String.Empty;
- }
-
- public DBConnectionString(string connectString) : this()
- {
- this.connectString = connectString;
- }
-
- #region Base Connection Properties
-
-#if DESIGN
- [Category("Connection")]
- [Description("The name or IP address of the server to use")]
-#endif
- public string Server
- {
- get { return host; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Port to use when connecting with sockets")]
- [DefaultValue(3306)]
-#endif
- public uint Port
- {
- get { return port; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Database to use initially")]
- [Editor("MySql.Data.MySqlClient.Design.DatabaseTypeEditor,MySqlClient.Design",
typeof(System.Drawing.Design.UITypeEditor))]
-#endif
- public string Database
- {
- get { return database; }
- set { database = value; }
- }
-
-#if DESIGN
- [Category("Connection")]
- [Description("Number of seconds to wait for the connection to succeed")]
- [DefaultValue(15)]
-#endif
- public int ConnectionTimeout
- {
- get { return connectionTimeout; }
- }
-
-#if DESIGN
- [Category("Authentication")]
- [Description("Show user password in connection string")]
- [DefaultValue(false)]
-#endif
- public bool PersistSecurityInfo
- {
- get { return persistSecurityInfo; }
- }
-
-#if DESIGN
- [Category("Authentication")]
- [Description("The username to connect as")]
-#endif
- public string UserId
- {
- get { return userId; }
- }
-
-#if DESIGN
- [Category("Authentication")]
- [Description("The password to use for authentication")]
-#endif
- public string Password
- {
- get { return password; }
- }
-
-
-#endregion
-
- #region Pooling Properties
-
-#if DESIGN
- [Category("Pooling")]
- [Description("Should the connection support pooling")]
- [DefaultValue(true)]
-#endif
- public bool Pooling
- {
- get { return pooling; }
- }
-
-#if DESIGN
- [Category("Pooling")]
- [Description("Minimum number of connections to have in this pool")]
- [DefaultValue(0)]
-#endif
- public int MinPoolSize
- {
- get { return minPoolSize; }
- }
-
-#if DESIGN
- [Category("Pooling")]
- [Description("Maximum number of connections to have in this pool")]
- [DefaultValue(100)]
-#endif
- public int MaxPoolSize
- {
- get { return maxPoolSize; }
- }
-
-#if DESIGN
- [Category("Pooling")]
- [Description("Maximum number of seconds a connection should live. This is checked when
a connection is returned to the pool.")]
- [DefaultValue(0)]
-#endif
- public int ConnectionLifetime
- {
- get { return poolLifeTime; }
- }
-
- #endregion
-
- protected string RemoveKeys(string value, string[] keys)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- string[] pairs = Utility.ContextSplit(value, ";", "\"'");
- foreach (string keyvalue in pairs)
- {
- string test = keyvalue.Trim().ToLower();
- if (test.StartsWith("pwd") || test.StartsWith("password"))
- continue;
- sb.Append(keyvalue);
- sb.Append(";");
- }
- sb.Remove(sb.Length-1, 1); // remove the trailing ;
- return sb.ToString();
- }
-
- protected virtual bool ConnectionParameterParsed(string key, string value)
- {
- string lowerKey = key.ToLower(System.Globalization.CultureInfo.InvariantCulture);
-
- switch (lowerKey)
- {
- case "persist security info":
- persistSecurityInfo = value.ToLower() == "yes" || value.ToLower() ==
"true";
- return true;
-
- case "uid":
- case "username":
- case "user id":
- case "user name":
- case "userid":
- userId = value;
- return true;
-
- case "password":
- case "pwd":
- password = value;
- return true;
-
- case "host":
- case "server":
- case "data source":
- case "datasource":
- case "address":
- case "addr":
- case "network address":
- host = value;
- return true;
-
- case "initial catalog":
- case "database":
- database = value;
- return true;
-
- case "connection timeout":
- case "connect timeout":
- connectionTimeout = Int32.Parse(value,
- System.Globalization.NumberFormatInfo.InvariantInfo);
- return true;
-
- case "port":
- port = UInt32.Parse(value,
- System.Globalization.NumberFormatInfo.InvariantInfo);
- return true;
-
- case "pooling":
- pooling = value.ToLower() == "yes" || value.ToLower() == "true";
- return true;
-
- case "min pool size":
- minPoolSize = Int32.Parse(value,
- System.Globalization.NumberFormatInfo.InvariantInfo);
- return true;
-
- case "max pool size":
- maxPoolSize = Int32.Parse(value,
- System.Globalization.NumberFormatInfo.InvariantInfo);
- return true;
-
- case "connection lifetime":
- poolLifeTime = Int32.Parse(value,
- System.Globalization.NumberFormatInfo.InvariantInfo);
- return true;
- }
- return false;
- }
-
- protected virtual void Parse()
- {
- String[] keyvalues = connectString.Split(';');
- String[] newkeyvalues = new String[keyvalues.Length];
- int x = 0;
-
- // first run through the array and check for any keys that
- // have ; in their value
- foreach (String keyvalue in keyvalues)
- {
- // check for trailing ; at the end of the connection string
- if (keyvalue.Length == 0) continue;
-
- // this value has an '=' sign so we are ok
- if (keyvalue.IndexOf('=') >= 0)
- {
- newkeyvalues[x++] = keyvalue;
- }
- else
- {
- newkeyvalues[x - 1] += ";";
- newkeyvalues[x - 1] += keyvalue;
- }
- }
-
- // now we run through our normalized key-values, splitting on equals
- for (int y = 0; y < x; y++)
- {
- String[] parts = newkeyvalues[y].Split('=');
-
- // first trim off any space and lowercase the key
- parts[0] = parts[0].Trim().ToLower();
- parts[1] = parts[1].Trim();
-
- // we also want to clear off any quotes
- parts[0] = parts[0].Trim('\'', '"');
- parts[1] = parts[1].Trim('\'', '"');
-
- ConnectionParameterParsed(parts[0], parts[1]);
- }
- }
-
- }
-}
Modified: trunk/mysqlclient/common/StreamCreator.cs
===================================================================
--- trunk/mysqlclient/common/StreamCreator.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/common/StreamCreator.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -38,7 +38,7 @@
string hostList;
uint port;
string pipeName;
- int timeOut;
+ uint timeOut;
public StreamCreator( string hosts, uint port, string pipeName)
{
@@ -49,7 +49,7 @@
this.pipeName = pipeName;
}
- public Stream GetStream(int timeOut)
+ public Stream GetStream(uint timeOut)
{
this.timeOut = timeOut;
@@ -132,7 +132,7 @@
ss = unix ?
new SocketStream(AddressFamily.Unix, SocketType.Stream,
ProtocolType.IP) :
new SocketStream(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
- ss.Connect(endPoint, timeOut);
+ ss.Connect(endPoint, (int)timeOut);
ss.Socket.SetSocketOption(SocketOptionLevel.Tcp,
SocketOptionName.NoDelay, 1);
return ss;
}
Modified: trunk/mysqlclient/nativedriver.cs
===================================================================
--- trunk/mysqlclient/nativedriver.cs 2006-06-15 13:52:34 UTC (rev 250)
+++ trunk/mysqlclient/nativedriver.cs 2006-06-16 21:32:36 UTC (rev 251)
@@ -51,7 +51,7 @@
private int warningCount;
- public NativeDriver(MySqlConnectionString settings) : base(settings)
+ public NativeDriver(MySqlConnectionStringBuilder settings) : base(settings)
{
packetSeq = 0;
isOpen = false;
@@ -170,7 +170,7 @@
try
{
#if !CF
- if (Settings.Protocol == ConnectionProtocol.SharedMemory)
+ if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
{
SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName);
str.Open(Settings.ConnectionTimeout);
@@ -180,7 +180,7 @@
{
#endif
string pipeName = Settings.PipeName;
- if (Settings.Protocol != ConnectionProtocol.NamedPipe)
+ if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
pipeName = null;
StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName);
stream = sc.GetStream(Settings.ConnectionTimeout);
@@ -355,7 +355,7 @@
public void Authenticate()
{
// write the user id to the auth packet
- writer.WriteString( connectionString.UserId );
+ writer.WriteString( connectionString.UserID );
if ( version.isAtLeast(4,1,1) )
Authenticate411();
| Thread |
|---|
| • Connector/NET commit: r251 - in trunk/mysqlclient: . common | rburnett | 16 Jun |