Modified:
trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl
trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl
trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl
trunk/MySql.Data/Provider/Source/Field.cs
trunk/MySql.Data/Provider/Source/MySqlPacket.cs
trunk/MySql.Data/Provider/Source/NativeDriver.cs
trunk/MySql.Data/Provider/Source/PreparableStatement.cs
trunk/MySql.Data/Provider/Source/Statement.cs
trunk/MySql.Data/Provider/Source/StoredProcedure.cs
trunk/MySql.Data/Provider/Source/Types/MySqlGuid.cs
trunk/MySql.Data/Provider/Source/command.cs
trunk/MySql.Data/Provider/Source/datareader.cs
trunk/MySql.Data/Provider/Source/parameter.cs
trunk/MySql.Data/Tests/MySql.Data.CF.Tests.csproj
trunk/MySql.Data/Tests/Source/BaseTest.cs
trunk/MySql.Data/Tests/Source/DataTypeTests.cs
trunk/MySql.Data/Tests/Source/PreparedStatements.cs
trunk/MySql.Data/Tests/Source/ProcedureParameters.cs
trunk/MySql.Data/Tests/Source/StoredProcedure.cs
trunk/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs
trunk/MySql.Web/Providers/Properties/Resources.Designer.cs
trunk/MySql.Web/Providers/Properties/Resources.resx
trunk/MySql.Web/Providers/Source/SessionProvider.cs
trunk/MySql.Web/Tests/SchemaTests.cs
trunk/Release Notes.txt
Log:
testing looking good and updated release notes
Modified: trunk/MySql.Data/Provider/Source/Field.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/Field.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/Field.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -263,7 +263,7 @@
if (connection.Settings.RespectBinaryFlags)
CheckForExceptions();
- if (Type == MySqlDbType.String && ColumnLength == 32 && !connection.Settings.OldGuids)
+ if (Type == MySqlDbType.String && ColumnLength == 36 && !connection.Settings.OldGuids)
mySqlDbType = MySqlDbType.Guid;
if (!IsBinary) return;
@@ -304,6 +304,12 @@
b.TreatAsBoolean = true;
v = b;
}
+ else if (v is MySqlGuid)
+ {
+ MySqlGuid g = (MySqlGuid)v;
+ g.OldGuids = connection.Settings.OldGuids;
+ v = g;
+ }
return v;
}
Modified: trunk/MySql.Data/Provider/Source/MySqlPacket.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/MySqlPacket.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/MySqlPacket.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -193,7 +193,6 @@
public int ReadInteger(int numbytes)
{
- Debug.Assert(numbytes <= 4);
return (int)ReadULong(numbytes);
}
Modified: trunk/MySql.Data/Provider/Source/NativeDriver.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/NativeDriver.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/NativeDriver.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -563,7 +563,15 @@
if ((serverStatus & (ServerStatusFlags.AnotherQuery | ServerStatusFlags.MoreResults)) == 0)
return -1;
- packet = stream.ReadPacket();
+ try
+ {
+ packet = stream.ReadPacket();
+ }
+ catch (Exception)
+ {
+ serverStatus = 0;
+ throw;
+ }
long fieldCount = packet.ReadFieldLength();
if (fieldCount > 0)
Modified: trunk/MySql.Data/Provider/Source/PreparableStatement.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/PreparableStatement.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/PreparableStatement.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -151,7 +151,7 @@
p.Direction == ParameterDirection.Output;
if (nullMap[i]) continue;
packet.Encoding = p.Encoding;
- p.Serialize(packet, true);
+ p.Serialize(packet, true, Connection.Settings);
}
if (nullMap != null)
nullMap.CopyTo(packet.Buffer, nullMapPosition);
Modified: trunk/MySql.Data/Provider/Source/Statement.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/Statement.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/Statement.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -231,7 +231,7 @@
throw new MySqlException(
String.Format(Resources.ParameterMustBeDefined, parmName));
}
- parameter.Serialize(packet, false);
+ parameter.Serialize(packet, false, Connection.Settings);
return true;
}
}
Modified: trunk/MySql.Data/Provider/Source/StoredProcedure.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/StoredProcedure.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/StoredProcedure.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -173,26 +173,33 @@
foreach (DataRow param in parametersTable.Rows)
{
MySqlParameter p = GetAndFixParameter(param, realAsFloat);
+ if (p == null) continue;
string baseName = p.ParameterName;
+ string pName = baseName;
if (baseName.StartsWith("@") || baseName.StartsWith("?"))
baseName = baseName.Substring(1);
+ else
+ pName = "@" + pName;
- // if input then we just send the parameter normally
- if (p.Direction == ParameterDirection.Input ||
- (Connection.driver.SupportsOutputParameters && preparing))
+ string inputVar = pName;
+ if (p.Direction != ParameterDirection.Input &&
+ !(Connection.driver.SupportsOutputParameters || preparing))
{
- sqlStr.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1}", sqlDelimiter, baseName);
- sqlDelimiter = ", ";
- }
- else
- {
- Connection.driver.ExecuteDirect(String.Format(
- "SET @{0}{1}={2}", parameterHash, baseName,
- p.Direction == ParameterDirection.Output ? "NULL" : p.Value.ToString()));
- outSql.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1}{2}", outDelimiter, parameterHash, baseName);
+ // set a user variable to our current value
+ string sql = String.Format("SET @{0}{1}={2}", parameterHash, baseName, pName);
+ MySqlCommand cmd = new MySqlCommand(sql, Connection);
+ cmd.parameterHash = command.parameterHash;
+ cmd.Parameters.Add(p);
+ cmd.ExecuteNonQuery();
+
+ inputVar = String.Format("@{0}{1}", parameterHash, baseName);
+
+ outSql.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}", outDelimiter, inputVar);
outDelimiter = ", ";
}
+ sqlStr.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}", sqlDelimiter, inputVar);
+ sqlDelimiter = ", ";
}
string sqlCmd = sqlStr.ToString().TrimEnd(' ', ',');
@@ -236,7 +243,11 @@
MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true);
results.SetValueObject(i, MySqlField.GetIMySqlValue(parameter.MySqlDbType));
}
- if (!reader.Read()) return null;
+ if (!reader.Read())
+ {
+ reader.Close();
+ return null;
+ }
return reader;
}
@@ -253,13 +264,19 @@
reader = rdr;
}
- for (int i = 0; i < reader.FieldCount; i++)
+ using (reader)
{
- string fieldName = reader.GetName(i);
- if (fieldName.StartsWith(command.parameterHash))
- fieldName = fieldName.Remove(0, command.parameterHash.Length + 1);
- MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true);
- parameter.Value = reader.GetValue(i);
+ string hash = "@" + command.parameterHash;
+
+ for (int i = 0; i < reader.FieldCount; i++)
+ {
+ string fieldName = reader.GetName(i);
+ if (fieldName.StartsWith(hash))
+ fieldName = fieldName.Remove(0, hash.Length);
+ MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true);
+ parameter.Value = reader.GetValue(i);
+ }
+ reader.Close();
}
}
}
Modified: trunk/MySql.Data/Provider/Source/Types/MySqlGuid.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/Types/MySqlGuid.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/Types/MySqlGuid.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -31,9 +31,11 @@
Guid mValue;
private bool isNull;
private byte[] bytes;
+ private bool oldGuids;
public MySqlGuid(byte[] buff)
{
+ oldGuids = false;
mValue = new Guid(buff);
isNull = false;
bytes = buff;
@@ -44,6 +46,12 @@
get { return bytes; }
}
+ public bool OldGuids
+ {
+ get { return oldGuids; }
+ set { oldGuids = value; }
+ }
+
#region IMySqlValue Members
public bool IsNull
@@ -78,7 +86,7 @@
string IMySqlValue.MySqlTypeName
{
- get { return "BINARY(16)"; }
+ get { return OldGuids ? "BINARY(16)" : "CHAR(36)"; }
}
void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
@@ -104,23 +112,38 @@
}
}
+ if (OldGuids)
+ WriteOldGuid(packet, guid, binary);
+ else
+ {
+ guid.ToString("D");
+
+ if (binary)
+ packet.WriteLenString(guid.ToString("D"));
+ else
+ packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(guid.ToString("D")) + "'");
+ }
+ }
+
+ private void WriteOldGuid(MySqlPacket packet, Guid guid, bool binary)
+ {
byte[] bytes = guid.ToByteArray();
- if (binary)
- {
+ if (binary)
+ {
packet.WriteLength(bytes.Length);
packet.Write(bytes);
- }
- else
- {
+ }
+ else
+ {
if (packet.Version.isAtLeast(4, 1, 0))
packet.WriteStringNoNull("_binary ");
packet.WriteByte((byte)'\'');
- EscapeByteArray(bytes, bytes.Length, packet);
+ EscapeByteArray(bytes, bytes.Length, packet);
packet.WriteByte((byte)'\'');
- }
- }
+ }
+ }
private static void EscapeByteArray(byte[] bytes, int length, MySqlPacket packet)
{
@@ -143,18 +166,34 @@
}
}
+ private MySqlGuid ReadOldGuid(MySqlPacket packet, long length)
+ {
+ if (length == -1)
+ length = (long)packet.ReadFieldLength();
+
+ byte[] buff = new byte[length];
+ packet.Read(buff, 0, (int)length);
+ MySqlGuid g = new MySqlGuid(buff);
+ g.OldGuids = OldGuids;
+ return g;
+ }
+
IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal)
{
MySqlGuid g = new MySqlGuid();
g.isNull = true;
if (!nullVal)
{
+ if (OldGuids)
+ return ReadOldGuid(packet, length);
+ string s = String.Empty;
if (length == -1)
- length = (long)packet.ReadFieldLength();
-
- byte[] buff = new byte[length];
- packet.Read(buff, 0, (int)length);
- g = new MySqlGuid(buff);
+ s = packet.ReadLenString();
+ else
+ s = packet.ReadString(length);
+ g.mValue = new Guid(s);
+ g.OldGuids = OldGuids;
+ g.isNull = false;
}
return g;
}
Modified: trunk/MySql.Data/Provider/Source/command.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/command.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/command.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -413,7 +413,7 @@
// start a timeout timer
if (connection.driver.Version.isAtLeast(5, 0, 0) &&
- commandTimeout == 0)
+ commandTimeout > 0)
{
TimerCallback timerDelegate =
new TimerCallback(TimeoutExpired);
Modified: trunk/MySql.Data/Provider/Source/datareader.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/datareader.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/datareader.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -157,9 +157,6 @@
{
if (!isOpen) return;
- Command.lastInsertedId = driver.LastInsertedId;
- affectedRows = driver.AffectedRows;
-
bool shouldCloseConnection = (commandBehavior & CommandBehavior.CloseConnection) != 0;
commandBehavior = CommandBehavior.Default;
connection.Reader = null;
Modified: trunk/MySql.Data/Provider/Source/parameter.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/parameter.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Provider/Source/parameter.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -370,12 +370,20 @@
}
}
- internal void Serialize(MySqlPacket packet, bool binary)
+ internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings)
{
if (!binary && (paramValue == null || paramValue == DBNull.Value))
packet.WriteStringNoNull("NULL");
else
+ {
+ if (ValueObject.MySqlDbType == MySqlDbType.Guid)
+ {
+ MySqlGuid g = (MySqlGuid)ValueObject;
+ g.OldGuids = settings.OldGuids;
+ valueObject = g;
+ }
ValueObject.WriteValue(packet, binary, paramValue, size);
+ }
}
private void SetMySqlDbType(MySqlDbType mysql_dbtype)
Modified: trunk/MySql.Data/Tests/MySql.Data.CF.Tests.csproj
===================================================================
--- trunk/MySql.Data/Tests/MySql.Data.CF.Tests.csproj 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/MySql.Data.CF.Tests.csproj 2009-07-13 19:01:18 UTC (rev 1696)
@@ -78,8 +78,6 @@
<Compile Include="Source\GetSchemaTests.cs" />
<Compile Include="Source\InterfaceTests.cs" />
<Compile Include="Source\LanguageTests.cs" />
- <Compile Include="Source\MicroPerfTests.cs" />
- <Compile Include="Source\MySqlHelperTests.cs" />
<Compile Include="Source\ParameterTests.cs" />
<Compile Include="Source\PoolingTests.cs" />
<Compile Include="Source\PreparedStatements.cs" />
Modified: trunk/MySql.Data/Tests/Source/BaseTest.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/BaseTest.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/BaseTest.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -175,6 +175,12 @@
protected void SetAccountPerms(bool includeProc)
{
+ try
+ {
+ suExecSQL("DROP USER 'test'@'localhost'");
+ }
+ catch (Exception) { }
+
// now allow our user to access them
suExecSQL(String.Format(@"GRANT ALL ON `{0}`.* to 'test'@'localhost'
identified by 'test'", database0));
Modified: trunk/MySql.Data/Tests/Source/DataTypeTests.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/DataTypeTests.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/DataTypeTests.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -650,37 +650,42 @@
execSQL("DROP TABLE IF EXISTS Test");
execSQL("CREATE TABLE Test (id INT, g BINARY(16), c VARBINARY(16), c1 BINARY(255))");
- Guid g = Guid.NewGuid();
- byte[] bytes = g.ToByteArray();
+ string connStr = GetConnectionString(true) + ";old guids=true";
+ using (MySqlConnection c = new MySqlConnection(connStr))
+ {
+ c.Open();
+ Guid g = Guid.NewGuid();
+ byte[] bytes = g.ToByteArray();
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, @g, @c, @c1)", conn);
- cmd.Parameters.AddWithValue("@g", bytes);
- cmd.Parameters.AddWithValue("@c", bytes);
- cmd.Parameters.AddWithValue("@c1", g.ToString());
- cmd.ExecuteNonQuery();
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, @g, @c, @c1)", c);
+ cmd.Parameters.AddWithValue("@g", bytes);
+ cmd.Parameters.AddWithValue("@c", bytes);
+ cmd.Parameters.AddWithValue("@c1", g.ToString());
+ cmd.ExecuteNonQuery();
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
- DataTable dt = new DataTable();
- da.Fill(dt);
- Assert.IsTrue(dt.Rows[0][1] is Guid);
- Assert.IsTrue(dt.Rows[0][2] is byte[]);
- Assert.IsTrue(dt.Rows[0][3] is byte[]);
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ Assert.IsTrue(dt.Rows[0][1] is Guid);
+ Assert.IsTrue(dt.Rows[0][2] is byte[]);
+ Assert.IsTrue(dt.Rows[0][3] is byte[]);
- Assert.AreEqual(g, dt.Rows[0][1]);
+ Assert.AreEqual(g, dt.Rows[0][1]);
- string s = BitConverter.ToString(bytes);
+ string s = BitConverter.ToString(bytes);
- s = s.Replace("-", "");
- string sql = String.Format("TRUNCATE TABLE Test;INSERT INTO Test VALUES(1,0x{0},NULL,NULL)", s);
- execSQL(sql);
+ s = s.Replace("-", "");
+ string sql = String.Format("TRUNCATE TABLE Test;INSERT INTO Test VALUES(1,0x{0},NULL,NULL)", s);
+ execSQL(sql);
- cmd.CommandText = "SELECT * FROM Test";
- cmd.Parameters.Clear();
- using (MySqlDataReader reader = cmd.ExecuteReader())
- {
- reader.Read();
- Guid g1 = reader.GetGuid(1);
- Assert.AreEqual(g, g1);
+ cmd.CommandText = "SELECT * FROM Test";
+ cmd.Parameters.Clear();
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ Guid g1 = reader.GetGuid(1);
+ Assert.AreEqual(g, g1);
+ }
}
}
@@ -813,18 +818,23 @@
{
execSQL("CREATE TABLE Test(id INT, g BINARY(16))");
- Guid guid = Guid.NewGuid();
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", conn);
- cmd.Parameters.Add(new MySqlParameter("@g", MySqlDbType.Guid));
- cmd.Parameters[0].Value = guid;
- cmd.ExecuteNonQuery();
+ string connStr = GetConnectionString(true) + ";old guids=true";
+ using (MySqlConnection c = new MySqlConnection(connStr))
+ {
+ c.Open();
+ Guid guid = Guid.NewGuid();
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", c);
+ cmd.Parameters.Add(new MySqlParameter("@g", MySqlDbType.Guid));
+ cmd.Parameters[0].Value = guid;
+ cmd.ExecuteNonQuery();
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
- da.Fill(dt);
- Assert.AreEqual(1, dt.Rows.Count);
- Assert.AreEqual(1, dt.Rows[0]["id"]);
- Assert.AreEqual(guid, dt.Rows[0]["g"]);
+ DataTable dt = new DataTable();
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c);
+ da.Fill(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(1, dt.Rows[0]["id"]);
+ Assert.AreEqual(guid, dt.Rows[0]["g"]);
+ }
}
/// <summary>
@@ -836,27 +846,65 @@
execSQL("DROP TABLE IF EXISTS Test");
execSQL("CREATE TABLE Test (id INT, guid BINARY(16))");
- Guid g = new Guid("32A48AC5-285A-46c6-A0D4-158E6E39729C");
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?guid)", conn);
- MySqlParameter p = new MySqlParameter();
- p.ParameterName = "guid";
- p.Value = Guid.NewGuid();
- cmd.Parameters.Add(p);
- cmd.ExecuteNonQuery();
-
- cmd.CommandText = "SELECT * FROM Test";
- cmd.Parameters.Clear();
- using (MySqlDataReader reader = cmd.ExecuteReader())
+ string connStr = GetConnectionString(true) + ";old guids=true";
+ using (MySqlConnection c = new MySqlConnection(connStr))
{
- reader.Read();
+ c.Open();
- object o = reader.GetValue(1);
- Assert.IsTrue(o is Guid);
+ Guid g = new Guid("32A48AC5-285A-46c6-A0D4-158E6E39729C");
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?guid)", c);
+ MySqlParameter p = new MySqlParameter();
+ p.ParameterName = "guid";
+ p.Value = Guid.NewGuid();
+ cmd.Parameters.Add(p);
+ cmd.ExecuteNonQuery();
- byte[] bytes = new byte[16];
- long size = reader.GetBytes(1, 0, bytes, 0, 16);
- Assert.AreEqual(16, size);
+ cmd.CommandText = "SELECT * FROM Test";
+ cmd.Parameters.Clear();
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+
+ object o = reader.GetValue(1);
+ Assert.IsTrue(o is Guid);
+
+ byte[] bytes = new byte[16];
+ long size = reader.GetBytes(1, 0, bytes, 0, 16);
+ Assert.AreEqual(16, size);
+ }
}
}
+
+ [Test]
+ public void ReadingUUIDAsGuid()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT, guid CHAR(36))");
+ execSQL("INSERT INTO Test VALUES (1, UUID())");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT CONCAT('A', guid) FROM Test", conn);
+ string serverGuidStr = cmd.ExecuteScalar().ToString().Substring(1);
+ Guid serverGuid = new Guid(serverGuidStr);
+
+ cmd.CommandText = "SELECT guid FROM Test";
+ Guid g = (Guid)cmd.ExecuteScalar();
+ Assert.AreEqual(serverGuid, g);
+ }
+
+ [Test]
+ public void NewGuidType()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT, guid CHAR(36))");
+
+ Guid g = Guid.NewGuid();
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", conn);
+ cmd.Parameters.AddWithValue("@g", g);
+ cmd.ExecuteNonQuery();
+
+ cmd.CommandText = "SELECT guid FROM Test";
+ Guid readG = (Guid)cmd.ExecuteScalar();
+ Assert.AreEqual(g, readG);
+ }
}
}
Modified: trunk/MySql.Data/Tests/Source/PreparedStatements.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/PreparedStatements.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/PreparedStatements.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -777,7 +777,7 @@
[Test]
public void SprocOutputParams()
{
- if (Version < new Version(5, 4, 0)) return;
+ if (Version < new Version(6, 0, 8)) return;
execSQL("CREATE PROCEDURE spTest(id INT, OUT age INT) BEGIN SET age=id; END");
Modified: trunk/MySql.Data/Tests/Source/ProcedureParameters.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/ProcedureParameters.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/ProcedureParameters.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -28,15 +28,6 @@
[TestFixture]
public class ProcedureParameterTests : BaseTest
{
- protected override string GetConnectionInfo()
- {
- string info = base.GetConnectionInfo();
- if (rootConn != null)
- if (Version.Major == 5)
- info = info.Replace("use procedure bodies=false", "");
- return info;
- }
-
[Test]
public void ProcedureParameters()
{
Modified: trunk/MySql.Data/Tests/Source/StoredProcedure.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/StoredProcedure.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/StoredProcedure.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -36,11 +36,13 @@
public class StoredProcedure : BaseTest
{
private static string fillError = null;
+ protected bool hasAccess;
public StoredProcedure()
{
pooling = false;
- csAdditions = ";procedure cache size=0;logging=true;";
+ hasAccess = false;
+ csAdditions = ";procedure cache size=0;";
}
/// <summary>
@@ -1266,17 +1268,23 @@
if (Version < new Version(5, 0)) return;
if (Version > new Version(6, 0, 6)) return;
- execSQL(@"CREATE PROCEDURE spTest (id INT, name VARCHAR(20))
+ rootConn.ChangeDatabase(database1);
+ suExecSQL(@"CREATE PROCEDURE spTest (id INT, name VARCHAR(20))
BEGIN SELECT name; END");
- MySqlCommand cmd = new MySqlCommand("spTest", conn);
+ rootConn.ChangeDatabase(database0);
+
+ MySqlCommand cmd = new MySqlCommand(database1 + ".spTest", conn);
cmd.CommandType = CommandType.StoredProcedure;
try
{
MySqlCommandBuilder.DeriveParameters(cmd);
- Assert.Fail("This should have failed");
+ if (!hasAccess)
+ Assert.Fail("This should have failed");
}
catch (MySqlException ex)
{
+ if (hasAccess)
+ Assert.Fail("This should have not failed");
}
}
}
Modified: trunk/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -32,6 +32,11 @@
[TestFixture]
public class StoredProcedureAccess : StoredProcedure
{
+ public StoredProcedureAccess() : base()
+ {
+ hasAccess = true;
+ }
+
public override void Setup()
{
base.Setup();
Modified: trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl
===================================================================
--- trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl 2009-07-13 19:01:18 UTC (rev 1696)
@@ -28,7 +28,7 @@
ORDINAL_POSITION AS `Ordinal`,
CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool',
- IF (LEFT(COLUMN_TYPE,10) = 'binary(16)', 'guid',
+ IF (LEFT(COLUMN_TYPE,10) = 'binary(16)' OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid',
IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE,
CONCAT('u', DATA_TYPE)))) AS `TypeName`,
IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
Modified: trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl
===================================================================
--- trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl 2009-07-13 19:01:18 UTC (rev 1696)
@@ -28,7 +28,7 @@
ORDINAL_POSITION AS `Ordinal`,
CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool',
- IF (LEFT(COLUMN_TYPE,10) = 'binary(16)', 'guid',
+ IF (LEFT(COLUMN_TYPE,10) = 'binary(16)' OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid',
IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE,
CONCAT('u', DATA_TYPE)))) AS `TypeName`,
IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
Modified: trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl
===================================================================
--- trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl 2009-07-13 19:01:18 UTC (rev 1696)
@@ -28,7 +28,7 @@
ORDINAL_POSITION AS `Ordinal`,
CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool',
- IF (LEFT(COLUMN_TYPE,10) = 'binary(16)', 'guid',
+ IF (LEFT(COLUMN_TYPE,10) = 'binary(16)' OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid',
IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE,
CONCAT('u', DATA_TYPE)))) AS `TypeName`,
NUMERIC_PRECISION AS `Precision`,
Modified: trunk/MySql.Web/Providers/Properties/Resources.Designer.cs
===================================================================
--- trunk/MySql.Web/Providers/Properties/Resources.Designer.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Web/Providers/Properties/Resources.Designer.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -19,7 +19,7 @@
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@@ -358,6 +358,31 @@
}
/// <summary>
+ /// Looks up a localized string similar to CREATE TABLE my_aspnet_Sessions
+ ///(
+ /// SessionId varchar(255) NOT NULL,
+ /// ApplicationId int NOT NULL,
+ /// Created datetime NOT NULL,
+ /// Expires datetime NOT NULL,
+ /// LockDate datetime NOT NULL,
+ /// LockId int NOT NULL,
+ /// Timeout int NOT NULL,
+ /// Locked tinyint(1) NOT NULL,
+ /// SessionItems BLOB,
+ /// Flags int NOT NULL,
+ /// primary key (SessionId,ApplicationId)
+ ///) DEFAULT CHARSET=latin1;
+ ///
+ ////*
+ /// Cleaning up timed ou [rest of string was truncated]";.
+ /// </summary>
+ public static string schema5 {
+ get {
+ return ResourceManager.GetString("schema5", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unable to create application..
/// </summary>
public static string UnableToCreateApplication {
Modified: trunk/MySql.Web/Providers/Properties/Resources.resx
===================================================================
--- trunk/MySql.Web/Providers/Properties/Resources.resx 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Web/Providers/Properties/Resources.resx 2009-07-13 19:01:18 UTC (rev 1696)
@@ -241,4 +241,7 @@
<data name="MonoDoesNotSupportHash" xml:space="preserve">
<value>The mono runtime did not support hashed passwords. Please use clear or encrypted passwords.</value>
</data>
+ <data name="schema5" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>schema5.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/MySql.Web/Providers/Source/SessionProvider.cs
===================================================================
--- trunk/MySql.Web/Providers/Source/SessionProvider.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Web/Providers/Source/SessionProvider.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -1,750 +1,74 @@
-// Copyright (c) 2009 Sun Microsystems, Inc.
-//
-// 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.Configuration;
-using System.Collections.Specialized;
-using System.Web.Hosting;
-using MySql.Data.MySqlClient;
-using System.Configuration.Provider;
-using System.IO;
-using MySql.Web.Common;
-using MySql.Web.General;
-using System.Web.SessionState;
-using System.Web.Configuration;
+using System;
using System.Web;
-using System.Diagnostics;
-using System.Threading;
-using System.Security;
+using System.Web.SessionState;
namespace MySql.Web.SessionState
{
- /// <summary>
- /// This class allows ASP.NET applications to store and manage session state information in a
- /// MySQL database.
- /// Expired session data is periodically deleted from the database.
- /// </summary>
- public class MySqlSessionStateStore : SessionStateStoreProviderBase
+ class SessionProvider : SessionStateStoreProviderBase
{
- string connectionString;
- ConnectionStringSettings connectionStringSettings;
- string eventSource = "MySQLSessionStateStore";
- string eventLog = "Application";
- string exceptionMessage = "An exception occurred. Please check the event log.";
- Application app;
-
- SessionStateSection sessionStateConfig;
-
- // cleanup old session
- Timer cleanupTimer;
- int cleanupInterval;
- bool cleanupRunning;
-
-
- bool writeExceptionsToEventLog = false;
-
- /// <summary>
- /// Indicates whether to write exceptions to event log
- /// </summary>
- public bool WriteExceptionsToEventLog
+ public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
- get { return writeExceptionsToEventLog; }
- set { writeExceptionsToEventLog = value; }
- }
-
- public string ApplicationName
- {
- get { return app.Name; }
- set { app.Name = value; }
- }
-
- private int ApplicationId
- {
- get { return app.Id; }
- }
-
-
- /// <summary>
- /// Handles MySql exception.
- /// If WriteExceptionsToEventLog is set, will write exception info
- /// to event log.
- /// It throws provider exception (original exception is stored as inner exception)
- /// </summary>
- /// <param name="e">exception</param>
- /// <param name="action"> name of the function that throwed the exception</param>
- private void HandleMySqlException(MySqlException e, string action)
- {
- if (WriteExceptionsToEventLog)
- {
- EventLog log = new EventLog();
- log.Source = eventSource;
- log.Log = eventLog;
-
- string message = "An exception occurred communicating with the data source.\n\n";
- message += "Action: " + action;
- message += "Exception: " + e.ToString();
- log.WriteEntry(message);
- }
- throw new ProviderException(exceptionMessage, e);
- }
-
-
-
- /// <summary>
- /// Initializes the provider with the property values specified in the ASP.NET application configuration file
- /// </summary>
- /// <param name="name">The name of the provider instance to initialize.</param>
- /// <param name="config">Object that contains the names and values of configuration options for the provider.
- /// </param>
- public override void Initialize(string name, NameValueCollection config)
- {
- //Initialize values from web.config.
- if (config == null)
- throw new ArgumentException("config");
- if (name == null || name.Length == 0)
- throw new ArgumentException("name");
- if (String.IsNullOrEmpty(config["description"]))
- {
- config.Remove("description");
- config["description"] = "MySQL Session State Store Provider";
- }
base.Initialize(name, config);
- string applicationName = HostingEnvironment.ApplicationVirtualPath;
- if (!String.IsNullOrEmpty(config["applicationName"]))
- applicationName = config["applicationName"];
-
- // Get <sessionState> configuration element.
- sessionStateConfig = (SessionStateSection)WebConfigurationManager.OpenWebConfiguration(applicationName).
- GetSection("system.web/sessionState");
-
- // Initialize connection.
- connectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];
- if (connectionStringSettings == null || connectionStringSettings.ConnectionString.Trim() == "")
- throw new HttpException("Connection string can not be blank");
- connectionString = connectionStringSettings.ConnectionString;
-
- writeExceptionsToEventLog = false;
- if (config["writeExceptionsToEventLog"] != null)
- {
- writeExceptionsToEventLog = (config["writeExceptionsToEventLog"].ToUpper() == "TRUE");
- }
-
-
- // Make sure we have the correct schema.
- SchemaManager.CheckSchema(connectionString, config);
- app = new Application(applicationName, base.Description);
-
- // Get the application id.
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- conn.Open();
- app.EnsureId(conn);
- CheckStorageEngine(conn);
- cleanupInterval = GetCleanupInterval(conn);
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "Initialize");
- }
-
- // Setup the cleanup timer
- if (cleanupInterval <= 0)
- cleanupInterval = 1;
- cleanupTimer = new Timer(new TimerCallback(CleanupOldSessions), null, 0,
- cleanupInterval * 1000 * 60);
}
- /// <summary>
- /// This method creates a new SessionStateStoreData object for the current request.
- /// </summary>
- /// <param name="context">
- /// The HttpContext object for the current request.
- /// </param>
- /// <param name="timeout">
- /// The timeout value (in minutes) for the SessionStateStoreData object that is created.
- /// </param>
- public override SessionStateStoreData CreateNewStoreData(System.Web.HttpContext context, int timeout)
+ public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout)
{
-
- return new SessionStateStoreData(new SessionStateItemCollection(),
- SessionStateUtility.GetSessionStaticObjects(context), timeout);
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method adds a new session state item to the database.
- /// </summary>
- /// <param name="context">
- /// The HttpContext object for the current request.
- /// </param>
- /// <param name="id">
- /// The session ID for the current request.
- /// </param>
- /// <param name="timeout">
- /// The timeout value for the current request.
- /// </param>
- public override void CreateUninitializedItem(System.Web.HttpContext context, string id, int timeout)
+ public override void CreateUninitializedItem(HttpContext context, string id, int timeout)
{
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- MySqlCommand cmd = new MySqlCommand(
- "INSERT INTO my_aspnet_Sessions" +
- " (SessionId, ApplicationId, Created, Expires, LockDate," +
- " LockId, Timeout, Locked, SessionItems, Flags)" +
- " Values (@SessionId, @ApplicationId, NOW(), NOW() + INTERVAL @Timeout MINUTE, NOW()," +
- " @LockId , @Timeout, @Locked, @SessionItems, @Flags)",
- conn);
-
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.Parameters.AddWithValue("@LockId", 0);
- cmd.Parameters.AddWithValue("@Timeout", timeout);
- cmd.Parameters.AddWithValue("@Locked", 0);
- cmd.Parameters.AddWithValue("@SessionItems", null);
- cmd.Parameters.AddWithValue("@Flags", 1);
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "CreateUninitializedItem");
- }
+ throw new NotImplementedException();
}
-
- /// <summary>
- /// This method releases all the resources for this instance.
- /// </summary>
public override void Dispose()
{
- if (cleanupTimer != null)
- cleanupTimer.Dispose();
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method allows the MySqlSessionStateStore object to perform any cleanup that may be
- /// required for the current request.
- /// </summary>
- /// <param name="context">The HttpContext object for the current request</param>
public override void EndRequest(System.Web.HttpContext context)
{
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method returns a read-only session item from the database.
- /// </summary>
- public override SessionStateStoreData GetItem(System.Web.HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
+ public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
{
- return GetSessionStoreItem(false, context, id, out locked, out lockAge, out lockId, out actions);
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method locks a session item and returns it from the database
- /// </summary>
- /// <param name="context">The HttpContext object for the current request</param>
- /// <param name="id">The session ID for the current request</param>
- /// <param name="locked">
- /// true if the session item is locked in the database; otherwise, it is false.
- /// </param>
- /// <param name="lockAge">
- /// TimeSpan object that indicates the amount of time the session item has been locked in the database.
- /// </param>
- /// <param name="lockId">
- /// A lock identifier object.
- /// </param>
- /// <param name="actions">
- /// A SessionStateActions enumeration value that indicates whether or
- /// not the session is uninitialized and cookieless.
- /// </param>
- /// <returns></returns>
- public override SessionStateStoreData GetItemExclusive(System.Web.HttpContext context, string id,
- out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
+ public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
{
- return GetSessionStoreItem(true, context, id, out locked, out lockAge, out lockId, out actions);
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method performs any per-request initializations that the MySqlSessionStateStore provider requires.
- /// </summary>
- public override void InitializeRequest(System.Web.HttpContext context)
+ public override void InitializeRequest(HttpContext context)
{
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method forcibly releases the lock on a session item in the database, if multiple attempts to
- /// retrieve the session item fail.
- /// </summary>
- /// <param name="context">The HttpContext object for the current request.</param>
- /// <param name="id">The session ID for the current request.</param>
- /// <param name="lockId">The lock identifier for the current request.</param>
- public override void ReleaseItemExclusive(System.Web.HttpContext context, string id, object lockId)
+ public override void ReleaseItemExclusive(HttpContext context, string id, object lockId)
{
-
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- MySqlCommand cmd = new MySqlCommand(
- "UPDATE my_aspnet_Sessions SET Locked = 0, Expires = NOW() + INTERVAL @Timeout MINUTE" +
- "WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId AND LockId = @LockId",
- conn);
-
- cmd.Parameters.AddWithValue("@Timeout", sessionStateConfig.Timeout.TotalMinutes);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.Parameters.AddWithValue("@LockId", lockId);
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "ReleaseItemExclusive");
- }
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method removes the specified session item from the database
- /// </summary>
- /// <param name="context">The HttpContext object for the current request</param>
- /// <param name="id">The session ID for the current request</param>
- /// <param name="lockId">The lock identifier for the current request.</param>
- /// <param name="item">The session item to remove from the database.</param>
- public override void RemoveItem(System.Web.HttpContext context, string id, object lockId, SessionStateStoreData item)
+ public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item)
{
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- MySqlCommand cmd = new MySqlCommand("DELETE FROM my_aspnet_Sessions " +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId AND LockId = @LockId",
- conn);
-
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.Parameters.AddWithValue("@LockId", lockId);
-
- conn.Open();
- cmd.ExecuteNonQuery();
- }
-
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "RemoveItem");
- }
+ throw new NotImplementedException();
}
-
- /// <summary>
- /// This method resets the expiration date and timeout for a session item in the database.
- /// </summary>
- /// <param name="context">The HttpContext object for the current request</param>
- /// <param name="id">The session ID for the current request</param>
- public override void ResetItemTimeout(System.Web.HttpContext context, string id)
+ public override void ResetItemTimeout(HttpContext context, string id)
{
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- MySqlCommand cmd = new MySqlCommand(
- "UPDATE my_aspnet_Sessions SET Expires = NOW() + INTERVAL @Timeout MINUTE" +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId", conn);
-
- cmd.Parameters.AddWithValue("@Timeout", sessionStateConfig.Timeout.TotalMinutes);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "ResetItemTimeout");
- }
+ throw new NotImplementedException();
}
- /// <summary>
- /// This method updates the session time information in the database with the specified session item,
- /// and releases the lock.
- /// </summary>
- /// <param name="context">The HttpContext object for the current request</param>
- /// <param name="id">The session ID for the current request</param>
- /// <param name="item">The session item containing new values to update the session item in the database with.
- /// </param>
- /// <param name="lockId">The lock identifier for the current request.</param>
- /// <param name="newItem">A Boolean value that indicates whether or not the session item is new in the database.
- /// A false value indicates an existing item.
- /// </param>
- public override void SetAndReleaseItemExclusive(System.Web.HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
+ public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
{
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- // Serialize the SessionStateItemCollection as a byte array
- byte[] sessItems = Serialize((SessionStateItemCollection)item.Items);
- MySqlCommand cmd;
- if (newItem)
- {
- //Insert the new session item . If there was expired session
- //with the same SessionId and Application id, it will be removed
-
- cmd = new MySqlCommand(
- "REPLACE INTO my_aspnet_Sessions (SessionId, ApplicationId, Created, Expires," +
- " LockDate, LockId, Timeout, Locked, SessionItems, Flags)" +
- " Values(@SessionId, @ApplicationId, NOW(), NOW() + INTERVAL @Timeout MINUTE, NOW()," +
- " @LockId , @Timeout, @Locked, @SessionItems, @Flags)", conn);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.Parameters.AddWithValue("@Timeout", item.Timeout);
- cmd.Parameters.AddWithValue("@LockId", 0);
- cmd.Parameters.AddWithValue("@Locked", 0);
- cmd.Parameters.AddWithValue("@SessionItems", sessItems);
- cmd.Parameters.AddWithValue("@Flags", 0);
- }
- else
- {
- //Update the existing session item.
- cmd = new MySqlCommand(
- "UPDATE my_aspnet_Sessions SET Expires = NOW() + INTERVAL @Timeout MINUTE," +
- " SessionItems = @SessionItems, Locked = @Locked " +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId AND LockId = @LockId",
- conn);
-
- cmd.Parameters.AddWithValue("@Timeout", item.Timeout);
- cmd.Parameters.AddWithValue("@SessionItems", sessItems);
- cmd.Parameters.AddWithValue("@Locked", 0);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.Parameters.AddWithValue("@LockId", lockId);
- }
-
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "SetAndReleaseItemExclusive");
- }
+ throw new NotImplementedException();
}
-
- /// <summary>
- /// GetSessionStoreItem is called by both the GetItem and GetItemExclusive methods. GetSessionStoreItem
- /// retrieves the session data from the data source. If the lockRecord parameter is true (in the case of
- /// GetItemExclusive), then GetSessionStoreItem locks the record and sets a New LockId and LockDate.
- /// </summary>
- private SessionStateStoreData GetSessionStoreItem(bool lockRecord,
- HttpContext context,
- string id,
- out bool locked,
- out TimeSpan lockAge,
- out object lockId,
- out SessionStateActions actionFlags)
- {
-
- // Initial values for return value and out parameters.
- SessionStateStoreData item = null;
- lockAge = TimeSpan.Zero;
- lockId = null;
- locked = false;
- actionFlags = SessionStateActions.None;
-
- // MySqlCommand for database commands.
- MySqlCommand cmd = null;
- // serialized SessionStateItemCollection.
- byte[] serializedItems = null;
- // True if a record is found in the database.
- bool foundRecord = false;
- // True if the returned session item is expired and needs to be deleted.
- bool deleteData = false;
- // Timeout value from the data store.
- int timeout = 0;
-
- try
- {
- using (MySqlConnection conn = new MySqlConnection(connectionString))
- {
- conn.Open();
-
- // lockRecord is True when called from GetItemExclusive and
- // False when called from GetItem.
- // Obtain a lock if possible. Ignore the record if it is expired.
- if (lockRecord)
- {
- cmd = new MySqlCommand(
- "UPDATE my_aspnet_Sessions SET " +
- " Locked = 1, LockDate = NOW()" +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId AND" +
- " Locked = 0 AND Expires > NOW()", conn);
-
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
-
- if (cmd.ExecuteNonQuery() == 0)
- {
- // No record was updated because the record was locked or not found.
- locked = true;
- }
- else
- {
- // The record was updated.
- locked = false;
- }
- }
-
- // Retrieve the current session item information.
- cmd = new MySqlCommand(
- "SELECT (NOW() > Expires) as Expired, SessionItems, LockId, Flags, Timeout, " +
- " TIMESTAMPDIFF(SECOND, LockDate, NOW()) as lockAge " +
- " FROM my_aspnet_Sessions" +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId", conn);
-
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
-
- // Retrieve session item data from the data source.
- using (MySqlDataReader reader = cmd.ExecuteReader())
- {
- if (reader.Read())
- {
- bool expired = reader.GetBoolean(0);
- if (expired)
- {
- //The record was expired. Mark it as not locked.
- locked = false;
- // The session was expired. Mark the data for deletion.
- deleteData = true;
- }
- else
- {
- foundRecord = true;
- }
-
- object items = reader.GetValue(1);
- serializedItems = (items is DBNull) ? null : (byte[])items;
- lockId = reader.GetInt32(2);
- actionFlags = (SessionStateActions)(reader.GetInt32(3));
- timeout = reader.GetInt32(4);
- lockAge = new TimeSpan(0, 0, 0, reader.GetInt32(5));
- }
- }
-
- //If the returned session item is expired,
- // delete the record from the data source.
- if (deleteData)
- {
- cmd = new MySqlCommand("DELETE FROM my_aspnet_Sessions" +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId", conn);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
- cmd.ExecuteNonQuery();
- }
-
- // The record was not found. Ensure that locked is false.
- if (!foundRecord)
- locked = false;
-
- // If the record was found and you obtained a lock, then set
- // the lockId, clear the actionFlags,
- // and create the SessionStateStoreItem to return.
- if (foundRecord && !locked)
- {
- lockId = (int)(lockId) + 1;
-
- cmd = new MySqlCommand("UPDATE my_aspnet_Sessions SET" +
- " LockId = @LockId, Flags = 0 " +
- " WHERE SessionId = @SessionId AND ApplicationId = @ApplicationId", conn);
-
- cmd.Parameters.AddWithValue("@LockId", lockId);
- cmd.Parameters.AddWithValue("@SessionId", id);
- cmd.Parameters.AddWithValue("@ApplicationId", ApplicationId);
-
- cmd.ExecuteNonQuery();
-
- // If the actionFlags parameter is not InitializeItem,
- // deserialize the stored SessionStateItemCollection.
- if (actionFlags == SessionStateActions.InitializeItem)
- {
- item = CreateNewStoreData(context, (int)sessionStateConfig.Timeout.TotalMinutes);
- }
- else
- {
- item = Deserialize(context, serializedItems, timeout);
- }
- }
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "GetSessionStoreItem");
- }
- return item;
- }
-
- /// <summary>
- /// This method returns a false value to indicate that callbacks for expired sessions are not supported.
- /// </summary>
- /// <param name="expireCallback"></param>
- /// <returns>false </returns>
public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback)
{
- return false;
+ throw new NotImplementedException();
}
-
- ///<summary>
- /// Serialize is called by the SetAndReleaseItemExclusive method to
- /// convert the SessionStateItemCollection into a byte array to
- /// be stored in the blob field.
- /// </summary>
- private byte[] Serialize(SessionStateItemCollection items)
- {
- MemoryStream ms = new MemoryStream();
- BinaryWriter writer = new BinaryWriter(ms);
- if (items != null)
- {
- items.Serialize(writer);
- }
- writer.Close();
- return ms.ToArray();
- }
-
- ///<summary>
- /// Deserialize is called by the GetSessionStoreItem method to
- /// convert the byte array stored in the blob field to a
- /// SessionStateItemCollection.
- /// </summary>
- private SessionStateStoreData Deserialize(HttpContext context,
- byte[] serializedItems, int timeout)
- {
-
- SessionStateItemCollection sessionItems = new SessionStateItemCollection();
-
- if (serializedItems != null)
- {
- MemoryStream ms = new MemoryStream(serializedItems);
- if (ms.Length > 0)
- {
- BinaryReader reader = new BinaryReader(ms);
- sessionItems = SessionStateItemCollection.Deserialize(reader);
- }
- }
-
- return new SessionStateStoreData(sessionItems, SessionStateUtility.GetSessionStaticObjects(context),
- timeout);
- }
-
- private void CleanupOldSessions(object o)
- {
- if (cleanupRunning)
- return;
-
- cleanupRunning = true;
- try
- {
- using (MySqlConnection con = new MySqlConnection(connectionString))
- {
- con.Open();
- MySqlCommand cmd = new MySqlCommand(
- "UPDATE my_aspnet_SessionCleanup SET LastRun=NOW() where" +
- " LastRun + INTERVAL IntervalMinutes MINUTE < NOW()", con);
-
- if (cmd.ExecuteNonQuery() > 0)
- {
- cmd = new MySqlCommand(
- "DELETE FROM my_aspnet_Sessions WHERE Expires < NOW()",
- con);
- cmd.ExecuteNonQuery();
- }
- }
- }
- catch (MySqlException e)
- {
- HandleMySqlException(e, "CleanupOldSessions");
- }
- finally
- {
- cleanupRunning = false;
- }
- }
-
- int GetCleanupInterval(MySqlConnection con)
- {
- MySqlCommand cmd = new MySqlCommand("SELECT IntervalMinutes from my_aspnet_SessionCleanup", con);
- return (int)cmd.ExecuteScalar();
- }
-
- /// <summary>
- /// Check storage engine used by my_aspnet_Sessions.
- /// Warn if MyISAM is used - it does not handle concurrent updates well
- /// which is important for session provider, as each access to session
- /// does an update to "expires" field.
- /// </summary>
- /// <param name="con"></param>
- private void CheckStorageEngine(MySqlConnection con)
- {
-
- try
- {
- MySqlCommand cmd = new MySqlCommand(
- "SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='my_aspnet_Sessions'",
- con);
- using (MySqlDataReader reader = cmd.ExecuteReader())
- {
- if (reader.Read())
- {
- string engine = reader.GetString(0);
- if (engine == "MyISAM")
- {
- string message =
- "Storage engine for table my_aspnet_Sessions is MyISAM." +
- "If possible, please change it to a transactional storage engine " +
- "to improve performance,e.g with 'alter table my_aspnet_Sessions engine innodb'\n";
- try
- {
- EventLog log = new EventLog();
- log.Source = eventSource;
- log.Log = eventLog;
- log.WriteEntry(message);
- }
- catch (SecurityException)
- {
- // Can't write to event log due to security restrictions
- Trace.WriteLine(message);
- }
- }
- }
- }
- }
- catch (MySqlException e)
- {
- Trace.Write("got exception while checking for engine" + e);
- }
- }
}
-}
\ No newline at end of file
+}
Modified: trunk/MySql.Web/Tests/SchemaTests.cs
===================================================================
--- trunk/MySql.Web/Tests/SchemaTests.cs 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/MySql.Web/Tests/SchemaTests.cs 2009-07-13 19:01:18 UTC (rev 1696)
@@ -149,9 +149,33 @@
try
{
provider.Initialize(null, config);
+ Assert.Fail("Should have failed");
}
catch (ProviderException)
{
+ }
+ }
+
+ [Test]
+ public void SchemaV5Present()
+ {
+ MySQLMembershipProvider provider = new MySQLMembershipProvider();
+ NameValueCollection config = new NameValueCollection();
+ config.Add("connectionStringName", "LocalMySqlServer");
+ config.Add("applicationName", "/");
+ config.Add("passwordFormat", "Clear");
+
+ LoadSchema(1);
+ LoadSchema(2);
+ LoadSchema(3);
+ LoadSchema(4);
+ LoadSchema(5);
+ try
+ {
+ provider.Initialize(null, config);
+ }
+ catch (ProviderException)
+ {
Assert.Fail("Should not have failed");
}
}
Modified: trunk/Release Notes.txt
===================================================================
--- trunk/Release Notes.txt 2009-07-13 04:08:01 UTC (rev 1695)
+++ trunk/Release Notes.txt 2009-07-13 19:01:18 UTC (rev 1696)
@@ -5,4 +5,35 @@
What's new in 6.1
--------------------
-<to be written>
+This release introduces a couple of exciting new features.
+
+Website Configuration Dialog -- This is a new wizard that is activated by clicking
+a button on the toolbar at the top of the solution explorer. It is meant to work in
+conjunction with the ASP.Net administration pages. It makes it easier to activate
+and set advanced options for the different web providers we include.
+
+Session State Provider -- We are now including a session state provider that allows
+you to store your websites state in a MySql server.
+
+Support for native output parameters -- With this release we now support native output
+parameters when connected to a server that supports them. Currently we know that includes
+6.0.8 and later servers. It also will include 5.4 servers.
+
+Changed GUID type -- We have changed our backend representation of a guid type to be
+CHAR(36). We are doing this because we feel users will want to use the server UUID() function
+to populate a guid table and UUID generates a 36 character string. Developers of older
+applications can add 'old guids=true' to the connection string and the old binary(16) type will be used.
+
+What we know may be broken
+----------------------------
+- Documentation is not updated yet.
+- Although the session provider is included in the web providers it is currently not
+ included in the website configuration wizard.
+- Our entity framework support currently treats both binary(16) and char(36) columns as
+ guids.
+- We have refactored a good bit of the internal piping to support output parameters but
+ also to set us up for future features such as client side query caching. What I saying
+ is that we may have broken some fairly major stuff so be sure and test against safe
+ data and please don't deploy until we are GA and you are confident.
+
+Please let us know what else we broke and how we can make it better!
\ No newline at end of file
| Thread |
|---|
| • Connector/NET commit: r1696 - in trunk: . MySql.Data/Provider/Source MySql.Data/Provider/Source/Types MySql.Data/Tests MySql.Data/Tests/Source MySql.D... | rburnett | 13 Jul |