Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/PoolingTests.cs
branches/1.0/mysqlclient/CommandResult.cs
branches/1.0/mysqlclient/Driver.cs
branches/1.0/mysqlclient/Exception.cs
branches/1.0/mysqlclient/MySqlError.cs
branches/1.0/mysqlclient/MySqlPool.cs
branches/1.0/mysqlclient/PacketReader.cs
branches/1.0/mysqlclient/Strings.resx
branches/1.0/mysqlclient/nativedriver.cs
Log:
Refactored pooling code to avoid skipped Ping() problem. Basically now only idle connections are checked for fulfulling an open request.
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/CHANGES 2005-11-15 01:27:48 UTC (rev 195)
@@ -9,11 +9,13 @@
Bug #13541 Prepare breaks if a parameter is used more than once [fixed]
Bug #13632 the MySQLCommandBuilder.deriveparameters has not been updated for MySQL 5
Bug #13753 Exception calling stored procedure with special characters in parameters
+ Bug #11386 Numeric parameters with Precision and Scale not taken into account by Connector [added test case]
+ Bug #6902 Errors in parsing stored procedure parameters [fixed before, refixed]
Other changes
-------------------------
Failure to provide parameters for out and inout values is now detected
-
+ Changed pooling code to remove issue of skipping Ping() on bogus connnections
9-27-05 - Version 1.0.6
Modified: branches/1.0/TestSuite/PoolingTests.cs
===================================================================
--- branches/1.0/TestSuite/PoolingTests.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/TestSuite/PoolingTests.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -31,6 +31,11 @@
[TestFixture]
public class PoolingTests : BaseTest
{
+ public PoolingTests() : base()
+ {
+ csAdditions = ";pooling=true";
+ }
+
[TestFixtureSetUp]
public void FixtureSetup()
{
@@ -170,5 +175,45 @@
conn.Close();
}
+ [Test]
+ public void ExceedMaxAllowedPacket()
+ {
+ MySqlConnection c = null;
+
+ execSQL("set @@global.max_allowed_packet=1000000");
+ execSQL("DROP TABLE IF EXISTS test");
+ try
+ {
+ execSQL("CREATE TABLE test (b1 LONGBLOB)");
+
+ string connStr = GetConnectionString(true) + ";max pool size=1";
+ c = new MySqlConnection(connStr);
+ c.Open();
+
+ byte[] b1 = new byte[2500000];
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (?b1)", c);
+ cmd.Parameters.Add("?b1", b1);
+ cmd.ExecuteNonQuery();
+ }
+ catch (Exception ex1)
+ {
+ Assert.IsTrue(c.State == ConnectionState.Closed);
+
+ try
+ {
+ c.Open();
+ c.ChangeDatabase("mysql");
+ }
+ catch (Exception ex2)
+ {
+ Assert.Fail(ex2.Message);
+ }
+ }
+ finally
+ {
+ if (c != null)
+ c.Close();
+ }
+ }
}
}
Modified: branches/1.0/mysqlclient/CommandResult.cs
===================================================================
--- branches/1.0/mysqlclient/CommandResult.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/CommandResult.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -142,7 +142,6 @@
if (driver.HasWarnings)
driver.ReportWarnings();
- driver.IsProcessing = false;
return false;
}
Modified: branches/1.0/mysqlclient/Driver.cs
===================================================================
--- branches/1.0/mysqlclient/Driver.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/Driver.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -42,9 +42,9 @@
protected int serverLanguage;
protected Hashtable serverProps;
protected MySqlConnection connection;
- protected bool processing;
protected Hashtable charSets;
protected bool hasWarnings;
+ protected long maxPacketSize;
public Driver(MySqlConnectionString settings)
{
@@ -55,6 +55,11 @@
#region Properties
+ internal long MaxPacketSize
+ {
+ get { return maxPacketSize; }
+ }
+
public int ThreadID
{
get { return threadId; }
@@ -77,13 +82,6 @@
set { encoding = value; }
}
- public bool IsProcessing
- {
- //TODO: remove comment
- // get { return processing; }
- set { processing = value; }
- }
-
public ServerStatusFlags ServerStatus
{
get { return serverStatus; }
@@ -170,6 +168,9 @@
throw;
}
+ if (serverProps.Contains( "max_allowed_packet"))
+ maxPacketSize = Convert.ToInt64(serverProps["max_allowed_packet"]);
+
#if AUTHENTICATED
string licenseType = (string)serverProps["license"];
if (licenseType == null || licenseType.Length == 0 ||
@@ -259,7 +260,7 @@
while (reader.Read())
{
errors.Add(new MySqlError(reader.GetString(0),
- reader.GetUInt32(1), reader.GetString(2)));
+ reader.GetInt32(1), reader.GetString(2)));
}
reader.Close();
Modified: branches/1.0/mysqlclient/Exception.cs
===================================================================
--- branches/1.0/mysqlclient/Exception.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/Exception.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -30,18 +30,18 @@
[Serializable]
public sealed class MySqlException : SystemException
{
- private int errorCode;
- private bool isFatal;
+ private int errorCode;
+ private bool isFatal;
- internal MySqlException(string msg) : base(msg)
+ internal MySqlException()
{
}
-
- internal MySqlException(string msg, Exception ex) : base(msg, ex)
+
+ internal MySqlException(string msg) : base(msg)
{
}
- internal MySqlException()
+ internal MySqlException(string msg, Exception ex) : base(msg, ex)
{
}
@@ -52,11 +52,11 @@
internal MySqlException(string msg, int errno) : this(msg)
{
- errorCode = errno;
+ errorCode = errno;
}
private MySqlException(SerializationInfo info,
- StreamingContext context) : base(info, context)
+ StreamingContext context) : base(info, context)
{
}
@@ -65,14 +65,13 @@
/// </summary>
public int Number
{
- get { return errorCode; }
+ get { return errorCode; }
}
-
/// <summary>
/// True if this exception was fatal and cause the closing of the connection, false otherwise.
/// </summary>
- public bool IsFatal
+ internal bool IsFatal
{
get { return isFatal; }
}
Modified: branches/1.0/mysqlclient/MySqlError.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlError.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/MySqlError.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -27,20 +27,15 @@
/// </summary>
public class MySqlError
{
- /// <summary></summary>
private string level;
-
- /// <summary></summary>
- private uint code;
-
- /// <summary></summary>
+ private int code;
private string message;
/// <summary></summary>
/// <param name="level"></param>
/// <param name="code"></param>
/// <param name="message"></param>
- public MySqlError(string level, uint code, string message)
+ public MySqlError(string level, int code, string message)
{
this.level = level;
this.code = code;
@@ -50,7 +45,7 @@
/// <summary>
/// Error level
/// </summary>
- public string Level
+ public string Level
{
get { return level; }
}
@@ -58,7 +53,7 @@
/// <summary>
/// Error code
/// </summary>
- public uint Code
+ public int Code
{
get { return code; }
}
@@ -70,7 +65,10 @@
{
get { return message; }
}
+ };
+ public enum MySqlErrorCode
+ {
/* ER_HASHCHK=1000,
ER_NISAMCHK=1001,
ER_NO=1002,
@@ -93,56 +91,51 @@
ER_CANT_SET_WD 1019
ER_CHECKREAD 1020
ER_DISK_FULL 1021
- */
- /// <summary>Duplicate key was found</summary>
- public const int DuplicateKey = 1022;
+ */
+ DuplicateKey = 1022,
-/* ER_ERROR_ON_CLOSE 1023
- ER_ERROR_ON_READ 1024
- ER_ERROR_ON_RENAME 1025
- ER_ERROR_ON_WRITE 1026
- ER_FILE_USED 1027
- ER_FILSORT_ABORT 1028
- ER_FORM_NOT_FOUND 1029
- ER_GET_ERRNO 1030
- ER_ILLEGAL_HA 1031*/
- /// <summary>Key was not found</summary>
- public const int KeyNotFound = 1032;
-/* ER_NOT_FORM_FILE 1033
- ER_NOT_KEYFILE 1034
- ER_OLD_KEYFILE 1035
- ER_OPEN_AS_READONLY 1036
- ER_OUTOFMEMORY 1037
- ER_OUT_OF_SORTMEMORY 1038
- ER_UNEXPECTED_EOF 1039
- ER_CON_COUNT_ERROR 1040
- ER_OUT_OF_RESOURCES 1041
- ER_BAD_HOST_ERROR 1042
- ER_HANDSHAKE_ERROR 1043
- ER_DBACCESS_DENIED_ERROR 1044
- ER_ACCESS_DENIED_ERROR 1045
- ER_NO_DB_ERROR 1046
- ER_UNKNOWN_COM_ERROR 1047
- ER_BAD_NULL_ERROR 1048
- ER_BAD_DB_ERROR 1049
- ER_TABLE_EXISTS_ERROR 1050
- ER_BAD_TABLE_ERROR 1051
- ER_NON_UNIQ_ERROR 1052
- ER_SERVER_SHUTDOWN 1053
- ER_BAD_FIELD_ERROR 1054
- ER_WRONG_FIELD_WITH_GROUP 1055
- ER_WRONG_GROUP_FIELD 1056
- ER_WRONG_SUM_SELECT 1057
- ER_WRONG_VALUE_COUNT 1058
- ER_TOO_LONG_IDENT 1059
- ER_DUP_FIELDNAME 1060*/
- /// <summary>Duplicate key name</summary>
- public const int DuplicateKeyName = 1061;
+ /* ER_ERROR_ON_CLOSE 1023
+ ER_ERROR_ON_READ 1024
+ ER_ERROR_ON_RENAME 1025
+ ER_ERROR_ON_WRITE 1026
+ ER_FILE_USED 1027
+ ER_FILSORT_ABORT 1028
+ ER_FORM_NOT_FOUND 1029
+ ER_GET_ERRNO 1030
+ ER_ILLEGAL_HA 1031*/
+ KeyNotFound = 1032,
+ /* ER_NOT_FORM_FILE 1033
+ ER_NOT_KEYFILE 1034
+ ER_OLD_KEYFILE 1035
+ ER_OPEN_AS_READONLY 1036
+ ER_OUTOFMEMORY 1037
+ ER_OUT_OF_SORTMEMORY 1038
+ ER_UNEXPECTED_EOF 1039
+ ER_CON_COUNT_ERROR 1040
+ ER_OUT_OF_RESOURCES 1041
+ ER_BAD_HOST_ERROR 1042
+ ER_HANDSHAKE_ERROR 1043
+ ER_DBACCESS_DENIED_ERROR 1044
+ ER_ACCESS_DENIED_ERROR 1045
+ ER_NO_DB_ERROR 1046
+ ER_UNKNOWN_COM_ERROR 1047
+ ER_BAD_NULL_ERROR 1048
+ ER_BAD_DB_ERROR 1049
+ ER_TABLE_EXISTS_ERROR 1050
+ ER_BAD_TABLE_ERROR 1051
+ ER_NON_UNIQ_ERROR 1052
+ ER_SERVER_SHUTDOWN 1053
+ ER_BAD_FIELD_ERROR 1054
+ ER_WRONG_FIELD_WITH_GROUP 1055
+ ER_WRONG_GROUP_FIELD 1056
+ ER_WRONG_SUM_SELECT 1057
+ ER_WRONG_VALUE_COUNT 1058
+ ER_TOO_LONG_IDENT 1059
+ ER_DUP_FIELDNAME 1060*/
+ DuplicateKeyName = 1061,
+ DuplicateKeyEntry = 1062,
- /// <summary>Duplicate key entry</summary>
- public const int DuplicateKeyEntry = 1062;
-
- /* ER_WRONG_FIELD_SPEC 1063
+ /* ER_WRONG_FIELD_SPEC 1063
ER_PARSE_ERROR 1064
ER_EMPTY_QUERY 1065
ER_NONUNIQ_TABLE 1066
@@ -210,122 +203,116 @@
ER_FUNCTION_NOT_DEFINED 1128
ER_HOST_IS_BLOCKED 1129
*/
- /// <summary>Host not privileged</summary>
- public const int HostNotPrivileged = 1130;
-
- /// <summary>Not sure</summary>
- public const int AnonymousUser = 1131;
-
- /// <summary>Passwords are not allowed on this account</summary>
- public const int PasswordNotAllowed = 1132;
-
- /// <summary>Passwords do not match</summary>
- public const int PasswordNoMatch = 1133;
-/* ER_UPDATE_INFO 1134
- ER_CANT_CREATE_THREAD 1135
- ER_WRONG_VALUE_COUNT_ON_ROW 1136
- ER_CANT_REOPEN_TABLE 1137
- ER_INVALID_USE_OF_NULL 1138
- ER_REGEXP_ERROR 1139
- ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
- ER_NONEXISTING_GRANT 1141
- ER_TABLEACCESS_DENIED_ERROR 1142
- ER_COLUMNACCESS_DENIED_ERROR 1143
- ER_ILLEGAL_GRANT_FOR_TABLE 1144
- ER_GRANT_WRONG_HOST_OR_USER 1145
- ER_NO_SUCH_TABLE 1146
- ER_NONEXISTING_TABLE_GRANT 1147
- ER_NOT_ALLOWED_COMMAND 1148
- ER_SYNTAX_ERROR 1149
- ER_DELAYED_CANT_CHANGE_LOCK 1150
- ER_TOO_MANY_DELAYED_THREADS 1151
- ER_ABORTING_CONNECTION 1152
- ER_NET_PACKET_TOO_LARGE 1153
- ER_NET_READ_ERROR_FROM_PIPE 1154
- ER_NET_FCNTL_ERROR 1155
- ER_NET_PACKETS_OUT_OF_ORDER 1156
- ER_NET_UNCOMPRESS_ERROR 1157
- ER_NET_READ_ERROR 1158
- ER_NET_READ_INTERRUPTED 1159
- ER_NET_ERROR_ON_WRITE 1160
- ER_NET_WRITE_INTERRUPTED 1161
- ER_TOO_LONG_STRING 1162
- ER_TABLE_CANT_HANDLE_BLOB 1163
- ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
- ER_DELAYED_INSERT_TABLE_LOCKED 1165
- ER_WRONG_COLUMN_NAME 1166
- ER_WRONG_KEY_COLUMN 1167
- ER_WRONG_MRG_TABLE 1168
- ER_DUP_UNIQUE 1169
- ER_BLOB_KEY_WITHOUT_LENGTH 1170
- ER_PRIMARY_CANT_HAVE_NULL 1171
- ER_TOO_MANY_ROWS 1172
- ER_REQUIRES_PRIMARY_KEY 1173
- ER_NO_RAID_COMPILED 1174
- ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
- ER_KEY_DOES_NOT_EXITS 1176
- ER_CHECK_NO_SUCH_TABLE 1177
- ER_CHECK_NOT_IMPLEMENTED 1178
- ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
- ER_ERROR_DURING_COMMIT 1180
- ER_ERROR_DURING_ROLLBACK 1181
- ER_ERROR_DURING_FLUSH_LOGS 1182
- ER_ERROR_DURING_CHECKPOINT 1183
- ER_NEW_ABORTING_CONNECTION 1184
- ER_DUMP_NOT_IMPLEMENTED 1185
- ER_FLUSH_MASTER_BINLOG_CLOSED 1186
- ER_INDEX_REBUILD 1187
- ER_MASTER 1188
- ER_MASTER_NET_READ 1189
- ER_MASTER_NET_WRITE 1190
- ER_FT_MATCHING_KEY_NOT_FOUND 1191
- ER_LOCK_OR_ACTIVE_TRANSACTION 1192
- ER_UNKNOWN_SYSTEM_VARIABLE 1193
- ER_CRASHED_ON_USAGE 1194
- ER_CRASHED_ON_REPAIR 1195
- ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
- ER_TRANS_CACHE_FULL 1197
- ER_SLAVE_MUST_STOP 1198
- ER_SLAVE_NOT_RUNNING 1199
- ER_BAD_SLAVE 1200
- ER_MASTER_INFO 1201
- ER_SLAVE_THREAD 1202
- ER_TOO_MANY_USER_CONNECTIONS 1203
- ER_SET_CONSTANTS_ONLY 1204
- ER_LOCK_WAIT_TIMEOUT 1205
- ER_LOCK_TABLE_FULL 1206
- ER_READ_ONLY_TRANSACTION 1207
- ER_DROP_DB_WITH_READ_LOCK 1208
- ER_CREATE_DB_WITH_READ_LOCK 1209
- ER_WRONG_ARGUMENTS 1210
- ER_NO_PERMISSION_TO_CREATE_USER 1211
- ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
- ER_LOCK_DEADLOCK 1213
- ER_TABLE_CANT_HANDLE_FULLTEXT 1214
- ER_CANNOT_ADD_FOREIGN 1215
- ER_NO_REFERENCED_ROW 1216
- ER_ROW_IS_REFERENCED 1217
- ER_CONNECT_TO_MASTER 1218
- ER_QUERY_ON_MASTER 1219
- ER_ERROR_WHEN_EXECUTING_COMMAND 1220
- ER_WRONG_USAGE 1221
- ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222
- ER_CANT_UPDATE_WITH_READLOCK 1223
- ER_MIXING_NOT_ALLOWED 1224
- ER_DUP_ARGUMENT 1225
- ER_USER_LIMIT_REACHED 1226
- ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
- ER_LOCAL_VARIABLE 1228
- ER_GLOBAL_VARIABLE 1229
- ER_NO_DEFAULT 1230
- ER_WRONG_VALUE_FOR_VAR 1231
- ER_WRONG_TYPE_FOR_VAR 1232
- ER_VAR_CANT_BE_READ 1233
- ER_CANT_USE_OPTION_HERE 1234
- ER_NOT_SUPPORTED_YET 1235
- ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
- ER_SLAVE_IGNORED_TABLE 1237 // only the slave SQL thread can be sent this
- ER_ERROR_MESSAGES 238*/
-
- };
+ HostNotPrivileged = 1130,
+ AnonymousUser = 1131,
+ PasswordNotAllowed = 1132,
+ PasswordNoMatch = 1133,
+ /* ER_UPDATE_INFO 1134
+ ER_CANT_CREATE_THREAD 1135
+ ER_WRONG_VALUE_COUNT_ON_ROW 1136
+ ER_CANT_REOPEN_TABLE 1137
+ ER_INVALID_USE_OF_NULL 1138
+ ER_REGEXP_ERROR 1139
+ ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
+ ER_NONEXISTING_GRANT 1141
+ ER_TABLEACCESS_DENIED_ERROR 1142
+ ER_COLUMNACCESS_DENIED_ERROR 1143
+ ER_ILLEGAL_GRANT_FOR_TABLE 1144
+ ER_GRANT_WRONG_HOST_OR_USER 1145
+ ER_NO_SUCH_TABLE 1146
+ ER_NONEXISTING_TABLE_GRANT 1147
+ ER_NOT_ALLOWED_COMMAND 1148
+ ER_SYNTAX_ERROR 1149
+ ER_DELAYED_CANT_CHANGE_LOCK 1150
+ ER_TOO_MANY_DELAYED_THREADS 1151
+ ER_ABORTING_CONNECTION 1152
+ */
+ PacketTooLarge=1153
+ /*
+ ER_NET_READ_ERROR_FROM_PIPE 1154
+ ER_NET_FCNTL_ERROR 1155
+ ER_NET_PACKETS_OUT_OF_ORDER 1156
+ ER_NET_UNCOMPRESS_ERROR 1157
+ ER_NET_READ_ERROR 1158
+ ER_NET_READ_INTERRUPTED 1159
+ ER_NET_ERROR_ON_WRITE 1160
+ ER_NET_WRITE_INTERRUPTED 1161
+ ER_TOO_LONG_STRING 1162
+ ER_TABLE_CANT_HANDLE_BLOB 1163
+ ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
+ ER_DELAYED_INSERT_TABLE_LOCKED 1165
+ ER_WRONG_COLUMN_NAME 1166
+ ER_WRONG_KEY_COLUMN 1167
+ ER_WRONG_MRG_TABLE 1168
+ ER_DUP_UNIQUE 1169
+ ER_BLOB_KEY_WITHOUT_LENGTH 1170
+ ER_PRIMARY_CANT_HAVE_NULL 1171
+ ER_TOO_MANY_ROWS 1172
+ ER_REQUIRES_PRIMARY_KEY 1173
+ ER_NO_RAID_COMPILED 1174
+ ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
+ ER_KEY_DOES_NOT_EXITS 1176
+ ER_CHECK_NO_SUCH_TABLE 1177
+ ER_CHECK_NOT_IMPLEMENTED 1178
+ ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
+ ER_ERROR_DURING_COMMIT 1180
+ ER_ERROR_DURING_ROLLBACK 1181
+ ER_ERROR_DURING_FLUSH_LOGS 1182
+ ER_ERROR_DURING_CHECKPOINT 1183
+ ER_NEW_ABORTING_CONNECTION 1184
+ ER_DUMP_NOT_IMPLEMENTED 1185
+ ER_FLUSH_MASTER_BINLOG_CLOSED 1186
+ ER_INDEX_REBUILD 1187
+ ER_MASTER 1188
+ ER_MASTER_NET_READ 1189
+ ER_MASTER_NET_WRITE 1190
+ ER_FT_MATCHING_KEY_NOT_FOUND 1191
+ ER_LOCK_OR_ACTIVE_TRANSACTION 1192
+ ER_UNKNOWN_SYSTEM_VARIABLE 1193
+ ER_CRASHED_ON_USAGE 1194
+ ER_CRASHED_ON_REPAIR 1195
+ ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
+ ER_TRANS_CACHE_FULL 1197
+ ER_SLAVE_MUST_STOP 1198
+ ER_SLAVE_NOT_RUNNING 1199
+ ER_BAD_SLAVE 1200
+ ER_MASTER_INFO 1201
+ ER_SLAVE_THREAD 1202
+ ER_TOO_MANY_USER_CONNECTIONS 1203
+ ER_SET_CONSTANTS_ONLY 1204
+ ER_LOCK_WAIT_TIMEOUT 1205
+ ER_LOCK_TABLE_FULL 1206
+ ER_READ_ONLY_TRANSACTION 1207
+ ER_DROP_DB_WITH_READ_LOCK 1208
+ ER_CREATE_DB_WITH_READ_LOCK 1209
+ ER_WRONG_ARGUMENTS 1210
+ ER_NO_PERMISSION_TO_CREATE_USER 1211
+ ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
+ ER_LOCK_DEADLOCK 1213
+ ER_TABLE_CANT_HANDLE_FULLTEXT 1214
+ ER_CANNOT_ADD_FOREIGN 1215
+ ER_NO_REFERENCED_ROW 1216
+ ER_ROW_IS_REFERENCED 1217
+ ER_CONNECT_TO_MASTER 1218
+ ER_QUERY_ON_MASTER 1219
+ ER_ERROR_WHEN_EXECUTING_COMMAND 1220
+ ER_WRONG_USAGE 1221
+ ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222
+ ER_CANT_UPDATE_WITH_READLOCK 1223
+ ER_MIXING_NOT_ALLOWED 1224
+ ER_DUP_ARGUMENT 1225
+ ER_USER_LIMIT_REACHED 1226
+ ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
+ ER_LOCAL_VARIABLE 1228
+ ER_GLOBAL_VARIABLE 1229
+ ER_NO_DEFAULT 1230
+ ER_WRONG_VALUE_FOR_VAR 1231
+ ER_WRONG_TYPE_FOR_VAR 1232
+ ER_VAR_CANT_BE_READ 1233
+ ER_CANT_USE_OPTION_HERE 1234
+ ER_NOT_SUPPORTED_YET 1235
+ ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
+ ER_SLAVE_IGNORED_TABLE 1237 // only the slave SQL thread can be sent this
+ ER_ERROR_MESSAGES 238*/
+ }
}
Modified: branches/1.0/mysqlclient/MySqlPool.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlPool.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/MySqlPool.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -30,7 +30,7 @@
internal sealed class MySqlPool
{
private ArrayList inUsePool;
- private ArrayList idlePool;
+ private Queue idlePool;
private MySqlConnectionString settings;
private int minSize;
private int maxSize;
@@ -40,8 +40,8 @@
minSize = settings.MinPoolSize;
maxSize = settings.MaxPoolSize;
this.settings = settings;
- inUsePool =new ArrayList();
- idlePool = new ArrayList( settings.MinPoolSize );
+ inUsePool =new ArrayList(maxSize);
+ idlePool = new Queue(maxSize);
// prepopulate the idle pool to minSize
for (int i=0; i < minSize; i++)
@@ -54,7 +54,7 @@
set { settings = value; }
}
- private int CheckConnections()
+/* private int CheckConnections()
{
int freed = 0;
lock (inUsePool.SyncRoot)
@@ -71,85 +71,61 @@
}
return freed;
}
-
- private Driver GetPooledConnection()
+*/
+ private Driver CheckoutConnection()
{
- 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)
+ lock(idlePool.SyncRoot)
{
- int freed = CheckConnections();
+ if (idlePool.Count == 0) return null;
+ Driver driver = (Driver)idlePool.Dequeue();
- // 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--)
+ // if the user asks us to ping/reset pooled connections
+ // do so now
+ if (settings.ResetPooledConnections)
{
- driver = (idlePool[i] as Driver);
- if (!settings.ResetPooledConnections)
- break;
-
- if (driver.Ping())
+ if (!driver.Ping())
{
- driver.Reset();
- break;
+ driver.Close();
+ return null;
}
-
- driver.SafeClose();
- idlePool.RemoveAt(i);
- driver = null;
+ driver.Reset();
}
- if (driver != null)
+
+ lock (inUsePool.SyncRoot)
{
- idlePool.Remove(driver);
- lock (inUsePool)
- {
- inUsePool.Add(driver);
- }
+ inUsePool.Add(driver);
}
+ return driver;
}
+ }
- if (driver == null && (idlePool.Count+inUsePool.Count) < maxSize)
+ private Driver GetPooledConnection()
+ {
+ while (true)
{
- // 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 );
- }
- }
- }
+ if (idlePool.Count > 0)
+ return CheckoutConnection();
- // make sure we stay at least minSize in our combined pools
- while ((idlePool.Count + inUsePool.Count) < minSize)
- CreateNewPooledConnection();
+ // if idlepool == 0 and inusepool == max, then we can't create a new one
+ if (inUsePool.Count == maxSize)
+ return null;
- return driver;
+ CreateNewPooledConnection();
+ }
}
- private Driver CreateNewPooledConnection()
+ private void 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;
+ if ((inUsePool.Count + idlePool.Count) == maxSize)
+ return;
- Driver driver = Driver.Create( settings );
- idlePool.Add( driver );
- return driver;
+ Driver driver = Driver.Create(settings);
+
+ idlePool.Enqueue(driver);
}
}
@@ -158,11 +134,11 @@
lock (idlePool.SyncRoot)
lock (inUsePool.SyncRoot)
{
- inUsePool.Remove( driver );
+ inUsePool.Remove(driver);
if (driver.Settings.ConnectionLifetime != 0 && driver.IsTooOld())
driver.Close();
else
- idlePool.Add( driver );
+ idlePool.Enqueue(driver);
}
}
Modified: branches/1.0/mysqlclient/PacketReader.cs
===================================================================
--- branches/1.0/mysqlclient/PacketReader.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/PacketReader.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -146,7 +146,7 @@
ReadByte();
int errorCode = ReadInteger(2);
string msg = ReadString();
- throw new MySqlException( msg, errorCode );
+ throw new MySqlException(msg, errorCode);
}
}
Modified: branches/1.0/mysqlclient/Strings.resx
===================================================================
--- branches/1.0/mysqlclient/Strings.resx 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/Strings.resx 2005-11-15 01:27:48 UTC (rev 195)
@@ -151,4 +151,7 @@
<data name="ReadFromStreamFailed">
<value>Reading from the stream has failed.</value>
</data>
+ <data name="QueryTooLarge">
+ <value>Packets larger than max_allowed_packet are not allowed.</value>
+ </data>
</root>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/nativedriver.cs
===================================================================
--- branches/1.0/mysqlclient/nativedriver.cs 2005-10-20 14:41:41 UTC (rev 194)
+++ branches/1.0/mysqlclient/nativedriver.cs 2005-11-15 01:27:48 UTC (rev 195)
@@ -39,7 +39,6 @@
{
public int MaxSinglePacket = 255 * 255 * 255;
protected byte packetSeq;
- protected long maxPacketSize;
protected int protocol;
protected String encryptionSeed;
@@ -67,12 +66,6 @@
get { return packetSeq; }
}
- public long MaxPacketSize
- {
- get { return maxPacketSize; }
- set { maxPacketSize = value; }
- }
-
/// <summary>
/// Returns true if this connection can handle batch SQL natively
/// This means MySQL 4.1.1 or later.
@@ -94,14 +87,6 @@
}
}
- public override void Configure( MySqlConnection connection )
- {
- base.Configure( connection );
-
- if ( serverProps.Contains( "max_allowed_packet" ))
- maxPacketSize = Convert.ToInt64( serverProps["max_allowed_packet"] );
- }
-
private void ExecuteCommand( DBCmd cmd, byte[] bytes, int length )
{
SequenceByte = 0;
@@ -337,8 +322,6 @@
public override CommandResult SendQuery( byte[] bytes, int length, bool consume )
{
- IsProcessing = true;
-
if (Settings.Logging)
Logger.LogCommand( DBCmd.QUERY, encoding.GetString( bytes, 0, length ) );
@@ -351,10 +334,12 @@
public override void Close()
{
if (isOpen)
+ {
ExecuteCommand(DBCmd.QUIT, null, 0);
- writer.Stream.Close();
- reader.Stream.Close();
+ writer.Stream.Close();
+ reader.Stream.Close();
+ }
base.Close();
}
@@ -366,9 +351,9 @@
{
// if we are processing a command, we can't send a command since MySQL doesn't
// support interleaved commands
- if (processing) return true;
+ //if (processing) return true;
- ExecuteCommand( DBCmd.PING, null, 0 );
+ ExecuteCommand(DBCmd.PING, null, 0);
return reader.ReadOk();
}
catch (Exception)
| Thread |
|---|
| • Connector/NET commit: r195 - in branches/1.0: . TestSuite mysqlclient | rburnett | 15 Nov |