#At file:///H:/connector_net/6.1/ based on revid:vvaintroub@stripped
838 Vladislav Vaintroub 2010-08-03
Bug #55701: fix calculation of lockAge in SessionProvider .
Do not use datimetime arithmetic in SQL, because it is either
- buggy (like TIME_TO_SEC(d1 - d2) returns NULL sometimes)
or
- works only for restricted ranges
TIME_TO_SEC(TIMEDIFF(d1, d2) would throw a warning
if d1 and d2 have more than 800+ hours difference
or
- non-portable
TIMESTAMPDIFF() works only with version 5.0 and later
Instead, do datetime calculations entirely in .NET
modified:
CHANGES
MySql.Web/Providers/Source/SessionProvider.cs
=== modified file 'CHANGES'
--- a/CHANGES 2010-08-03 15:58:24 +0000
+++ b/CHANGES 2010-08-03 21:22:30 +0000
@@ -1,3 +1,4 @@
+- Fix calculation of lockAge in SessionProvider (Bug #55701)
- Handle cases where server returns unparsable (out-of-range) double values
(Bug#55644)
- Improve performance of write operations (e.g insert) if compression is enabled
=== modified file 'MySql.Web/Providers/Source/SessionProvider.cs'
--- a/MySql.Web/Providers/Source/SessionProvider.cs 2010-04-21 15:17:05 +0000
+++ b/MySql.Web/Providers/Source/SessionProvider.cs 2010-08-03 21:22:30 +0000
@@ -520,8 +520,8 @@ namespace MySql.Web.SessionState
// Retrieve the current session item information.
cmd = new MySqlCommand(
- "SELECT (NOW() > Expires) as Expired, SessionItems, LockId, Flags, Timeout, " +
- " TIMESTAMPDIFF(SECOND, LockDate, NOW()) as lockAge " +
+ "SELECT NOW(), Expires , SessionItems, LockId, Flags, Timeout, " +
+ " LockDate " +
" FROM my_aspnet_Sessions" +
" WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId", conn);
@@ -533,8 +533,9 @@ namespace MySql.Web.SessionState
{
if (reader.Read())
{
- bool expired = reader.GetBoolean(0);
- if (expired)
+ DateTime now = reader.GetDateTime(0);
+ DateTime expires = reader.GetDateTime(1);
+ if (now.CompareTo(expires) > 0)
{
//The record was expired. Mark it as not locked.
locked = false;
@@ -546,17 +547,18 @@ namespace MySql.Web.SessionState
foundRecord = true;
}
- object items = reader.GetValue(1);
+ object items = reader.GetValue(2);
serializedItems = (items is DBNull) ? null : (byte[])items;
- lockId = reader.GetValue(2);
+ lockId = reader.GetValue(3);
if (lockId is DBNull)
{
lockId = (int)0;
}
- actionFlags = (SessionStateActions)(reader.GetInt32(3));
- timeout = reader.GetInt32(4);
- lockAge = new TimeSpan(0, 0, 0, reader.GetInt32(5));
+ actionFlags = (SessionStateActions)(reader.GetInt32(4));
+ timeout = reader.GetInt32(5);
+ DateTime lockDate = reader.GetDateTime(6);
+ lockAge = now.Subtract(lockDate);
}
}
Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20100803212230-wy27310n14bncbun.bundle
| Thread |
|---|
| • bzr commit into connector-net-6.1 branch (vvaintroub:838) Bug#55701 | Vladislav Vaintroub | 3 Aug |