Added:
branches/1.0/TestSuite/SimpleTransactions.cs
Removed:
branches/1.0/TestSuite/Transactions.cs
branches/1.0/TestSuite/configs/
Modified:
branches/1.0/Installer/sources.wxs
branches/1.0/TestSuite/BaseTest.cs
branches/1.0/TestSuite/BlobTests.cs
branches/1.0/TestSuite/CharacterSetTests.cs
branches/1.0/TestSuite/CommandBuilderTests.cs
branches/1.0/TestSuite/CommandTests.cs
branches/1.0/TestSuite/ConnectionTests.cs
branches/1.0/TestSuite/CultureTests.cs
branches/1.0/TestSuite/DataAdapterTests.cs
branches/1.0/TestSuite/DataReaderTests.cs
branches/1.0/TestSuite/DataTypeTests.cs
branches/1.0/TestSuite/DateTimeTests.cs
branches/1.0/TestSuite/EventTests.cs
branches/1.0/TestSuite/LanguageTests.cs
branches/1.0/TestSuite/MySql.Data.Tests.csproj
branches/1.0/TestSuite/MySqlHelperTests.cs
branches/1.0/TestSuite/ParameterTests.cs
branches/1.0/TestSuite/PoolingTests.cs
branches/1.0/TestSuite/PreparedStatements.cs
branches/1.0/TestSuite/StoredProcedure.cs
branches/1.0/TestSuite/StressTests.cs
branches/1.0/TestSuite/Syntax.cs
branches/1.0/TestSuite/Threading.cs
branches/1.0/mysqlclient/ConnectionString.cs
branches/1.0/mysqlclient/Driver.cs
Log:
test suite is essentially identical between 1.0 and 5.0 trees now. Tests specific to 5.0 appear in files that are in the 5.0 tree only.
Modified: branches/1.0/Installer/sources.wxs
===================================================================
--- branches/1.0/Installer/sources.wxs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/Installer/sources.wxs 2006-10-01 06:48:18 UTC (rev 388)
@@ -129,7 +129,7 @@
<File Id="file436" Name="STRESS_1.CS" LongName="StressTests.cs" src="..\TestSuite\StressTests.cs" />
<File Id="file437" Name="Syntax.cs" src="..\TestSuite\Syntax.cs" />
<File Id="file438" Name="THREAD_1.CS" LongName="Threading.cs" src="..\TestSuite\Threading.cs" />
- <File Id="file439" Name="TRANSA_1.CS" LongName="Transactions.cs" src="..\TestSuite\Transactions.cs" />
+ <File Id="file439" Name="Simple_1.CS" LongName="SimpleTransactions.cs" src="..\TestSuite\SimpleTransactions.cs" />
<File Id="file440" Name="USAGEA_1.CS" LongName="UsageAdvisor.cs" src="..\TestSuite\UsageAdvisor.cs" />
<File Id="file441" Name="Utils.cs" src="..\TestSuite\Utils.cs" />
</Component>
Modified: branches/1.0/TestSuite/BaseTest.cs
===================================================================
--- branches/1.0/TestSuite/BaseTest.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/BaseTest.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -37,14 +37,13 @@
protected string host;
protected string user;
protected string password;
- protected string otherkeys;
public BaseTest()
{
csAdditions = ";pooling=false";
user = "root";
password = "";
- otherkeys = ConfigurationSettings.AppSettings["otherkeys"];
+ host = "localhost";
}
protected virtual string GetConnectionInfo()
@@ -55,20 +54,19 @@
protected string GetConnectionString(bool includedb)
{
string connStr = String.Format("server={0};user id={1};password={2};" +
- "persist security info=true;{3}{4}", host, user, password,
- otherkeys, csAdditions);
+ "persist security info=true;{3}", host, user, password, csAdditions);
if (includedb)
connStr += ";database=test";
connStr += GetConnectionInfo();
return connStr;
- }
+ }
protected void Open()
{
try
{
string connString = GetConnectionString(true);
- conn = new MySqlConnection( connString );
+ conn = new MySqlConnection(connString);
conn.Open();
}
catch (Exception ex)
@@ -98,8 +96,8 @@
{
get
{
- string ver = conn.ServerVersion;
- return ver.StartsWith("5.0") || ver.StartsWith("5.1");
+ string v = conn.ServerVersion;
+ return v.StartsWith("5.0") || v.StartsWith("5.1");
}
}
@@ -122,7 +120,7 @@
bool exists = reader.Read();
reader.Close();
if (exists)
- execSQL( "TRUNCATE TABLE Test" );
+ execSQL("TRUNCATE TABLE Test");
if (Is50)
{
execSQL("DROP PROCEDURE IF EXISTS spTest");
@@ -131,7 +129,7 @@
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
}
@@ -148,8 +146,15 @@
protected void KillConnection(MySqlConnection c)
{
int threadId = c.ServerThread;
- MySqlCommand cmd = new MySqlCommand("KILL " + threadId, c);
- cmd.ExecuteNonQuery();
+ MySqlCommand cmd = new MySqlCommand("KILL " + threadId, conn);
+ try
+ {
+ cmd.ExecuteNonQuery();
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
c.Ping(); // this final ping will cause MySQL to clean up the killed thread
}
Modified: branches/1.0/TestSuite/BlobTests.cs
===================================================================
--- branches/1.0/TestSuite/BlobTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/BlobTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -36,9 +36,6 @@
public void TestFixtureSetUp()
{
Open();
-
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))");
}
[TestFixtureTearDown]
@@ -47,6 +44,14 @@
Close();
}
+ protected override void Setup()
+ {
+ base.Setup();
+
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))");
+ }
+
[Test]
[Category("4.0")]
public void InsertBinary()
@@ -139,7 +144,7 @@
InternalGetChars(true);
}
- private void InternalGetChars( bool prepare )
+ private void InternalGetChars(bool prepare)
{
execSQL("TRUNCATE TABLE Test");
@@ -148,12 +153,13 @@
data[x] = (char)(65 + (x%20));
MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, NULL, ?text1)", conn);
- cmd.Parameters.Add( "?text1", data );
+ cmd.Parameters.Add("?text1", data);
if (prepare)
cmd.Prepare();
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT * FROM Test";
+ cmd.Parameters.Clear();
if (prepare)
cmd.Prepare();
MySqlDataReader reader = null;
@@ -168,28 +174,28 @@
int lenToRead = data.Length;
while (lenToRead > 0)
{
- int size = Math.Min( lenToRead, 1024 );
- int read = (int)reader.GetChars( 2, pos, dataOut, pos, size );
+ int size = Math.Min(lenToRead, 1024);
+ int read = (int)reader.GetChars(2, pos, dataOut, pos, size);
lenToRead -= read;
pos += read;
}
// now see if the buffer is intact
for (int x=0; x < data.Length; x++)
- Assert.AreEqual( data[x], dataOut[x], "Checking first text array at " + x );
+ Assert.AreEqual(data[x], dataOut[x], "Checking first text array at " + x);
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
- if (reader != null) reader.Close();
+ if (reader != null)
+ reader.Close();
}
}
[Test]
- [Category("4.0")]
public void InsertText()
{
InternalInsertText(false);
@@ -256,36 +262,38 @@
}
[Test]
- [Category("4.0")]
public void UpdateDataSet()
{
- execSQL("TRUNCATE TABLE Test");
- execSQL("INSERT INTO Test VALUES( 1, NULL, 'Text field' )");
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))");
+ execSQL("INSERT INTO Test VALUES( 1, NULL, 'Text field' )");
try
{
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString();
DataTable dt = new DataTable();
da.Fill(dt);
string s = (string)dt.Rows[0][2];
- Assert.AreEqual( "Text field", s );
+ Assert.AreEqual("Text field", s);
byte[] inBuf = Utils.CreateBlob(512);
+ dt.Rows[0].BeginEdit();
dt.Rows[0]["blob1"] = inBuf;
+ dt.Rows[0].EndEdit();
DataTable changes = dt.GetChanges();
- da.Update( changes );
+ da.Update(changes);
dt.AcceptChanges();
dt.Clear();
da.Fill(dt);
byte[] outBuf = (byte[])dt.Rows[0]["blob1"];
- Assert.AreEqual( inBuf.Length, outBuf.Length, "checking length of updated buffer" );
+ Assert.AreEqual(inBuf.Length, outBuf.Length,
+ "checking length of updated buffer");
for (int y=0; y < inBuf.Length; y++)
- Assert.AreEqual( inBuf[y], outBuf[y], "checking array data" );
+ Assert.AreEqual(inBuf[y], outBuf[y], "checking array data");
}
catch (Exception ex)
{
@@ -327,7 +335,7 @@
execSQL("DROP TABLE IF EXISTS test");
execSQL("CREATE TABLE test (id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, " +
"image MEDIUMBLOB NOT NULL, imageSize MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, " +
- "PRIMARY KEY (id)) DEFAULT CHARSET=latin1");
+ "PRIMARY KEY (id))");
byte[] image = new byte[2048];
for (int x = 0; x < image.Length; x++)
@@ -337,7 +345,7 @@
cmd.Parameters.Add("?size", image.Length);
cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT imageSize, image FROM test WHERE id=?id";
+ cmd.CommandText = "SELECT imageSize, length(image), image FROM test WHERE id=?id";
cmd.Parameters.Add("?id", 1);
cmd.Prepare();
@@ -346,7 +354,9 @@
{
reader = cmd.ExecuteReader();
reader.Read();
- uint size = reader.GetUInt32(reader.GetOrdinal("imageSize"));
+ uint actualsize = reader.GetUInt32(1);
+ Assert.AreEqual(image.Length, actualsize);
+ uint size = reader.GetUInt32(0);
byte[] outImage = new byte[size];
long len = reader.GetBytes(reader.GetOrdinal("image"), 0, outImage, 0, (int)size);
Assert.AreEqual(image.Length, size);
@@ -388,9 +398,8 @@
execSQL("set @@global.max_allowed_packet=1000000");
}
}
+ }
- }
-
#region Configs
[Category("Compressed")]
@@ -402,7 +411,7 @@
}
}
- [Category("Pipe")]
+ [Category("Pipe")]
public class BlobTestsPipe : BlobTests
{
protected override string GetConnectionInfo()
@@ -411,8 +420,8 @@
}
}
- [Category("Compressed")]
- [Category("Pipe")]
+ [Category("Compressed")]
+ [Category("Pipe")]
public class BlobTestsPipeCompressed : BlobTests
{
protected override string GetConnectionInfo()
@@ -421,7 +430,7 @@
}
}
- [Category("SharedMemory")]
+ [Category("SharedMemory")]
public class BlobTestsSharedMemory : BlobTests
{
protected override string GetConnectionInfo()
@@ -430,8 +439,8 @@
}
}
- [Category("Compressed")]
- [Category("SharedMemory")]
+ [Category("Compressed")]
+ [Category("SharedMemory")]
public class BlobTestsSharedMemoryCompressed : BlobTests
{
protected override string GetConnectionInfo()
@@ -442,4 +451,4 @@
#endregion
-}
+}
\ No newline at end of file
Modified: branches/1.0/TestSuite/CharacterSetTests.cs
===================================================================
--- branches/1.0/TestSuite/CharacterSetTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/CharacterSetTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -47,9 +47,9 @@
public void UseFunctions()
{
execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test ( valid char, UserCode varchar(100), password varchar(100) ) CHARSET latin1");
+ execSQL("CREATE TABLE Test (valid char, UserCode varchar(100), password varchar(100)) CHARSET latin1");
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";charset=latin1" );
+ MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=latin1");
c.Open();
MySqlCommand cmd = new MySqlCommand("SELECT valid FROM Test WHERE Valid = 'Y' AND " +
"UserCode = 'username' AND Password = AES_ENCRYPT('Password','abc')", c);
@@ -57,72 +57,71 @@
c.Close();
}
- [Test]
- [Category("4.1")]
- public void VarBinary()
- {
- execSQL("DROP TABLE IF EXISTS test");
- createTable("CREATE TABLE test (id int, name varchar(200) collate utf8_bin) charset utf8", "InnoDB");
- execSQL("INSERT INTO test VALUES (1, 'Test1')");
+ [Test]
+ [Category("4.1")]
+ public void VarBinary()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ createTable("CREATE TABLE test (id int, name varchar(200) collate utf8_bin) charset utf8", "InnoDB");
+ execSQL("INSERT INTO test VALUES (1, 'Test1')");
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- Assert.IsTrue(reader.Read());
- object o = reader.GetValue(1);
- Assert.IsTrue(o is string);
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ object o = reader.GetValue(1);
+ Assert.IsTrue(o is string);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+ [Category("4.1")]
[Test]
public void Latin1Connection()
{
- if (! Is41 && ! Is50) return;
-
execSQL("DROP TABLE IF EXISTS Test");
execSQL("CREATE TABLE Test (id INT, name VARCHAR(200)) CHARSET latin1");
execSQL("INSERT INTO Test VALUES( 1, _latin1 'Test')");
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";charset=latin1" );
+ MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=latin1");
c.Open();
MySqlCommand cmd = new MySqlCommand("SELECT id FROM Test WHERE name LIKE 'Test'", c);
object id = cmd.ExecuteScalar();
- Assert.AreEqual( 1, id );
+ Assert.AreEqual(1, id);
c.Close();
}
- /// <summary>
- /// Bug #11621 connector does not support charset cp1250
- /// </summary>
- [Test]
- [Category("NotWorking")]
- public void CP1250Connection()
- {
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (name VARCHAR(200)) CHARSET cp1250");
+ /// <summary>
+ /// Bug #11621 connector does not support charset cp1250
+ /// </summary>
+ [Test]
+ [Category("NotWorking")]
+ public void CP1250Connection()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (name VARCHAR(200)) CHARSET cp1250");
- MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=cp1250");
- c.Open();
+ MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=cp1250");
+ c.Open();
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES('€ŤŽš')", c);
- cmd.ExecuteNonQuery();
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES('+ cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT name FROM Test";
- object name = cmd.ExecuteScalar();
- Assert.AreEqual("€ŤŽš", name);
- c.Close();
- }
+ cmd.CommandText = "SELECT name FROM Test";
+ object name = cmd.ExecuteScalar();
+ Assert.AreEqual("+ c.Close();
+ }
/// <summary>
/// Bug #14592 Wrong column length returned for VARCHAR UTF8 columns
@@ -155,5 +154,5 @@
}
}
- }
+ }
}
Modified: branches/1.0/TestSuite/CommandBuilderTests.cs
===================================================================
--- branches/1.0/TestSuite/CommandBuilderTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/CommandBuilderTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -25,15 +25,12 @@
namespace MySql.Data.MySqlClient.Tests
{
[TestFixture]
- public class CommandBuilderTest : BaseTest
+ public class CommandBuilderTests : BaseTest
{
[TestFixtureSetUp]
public void FixtureSetup()
{
Open();
-
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, `multi word` int, PRIMARY KEY(id))");
}
[TestFixtureTearDown]
@@ -42,30 +39,44 @@
Close();
}
+ protected override void Setup()
+ {
+ base.Setup();
+
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, `multi word` int, PRIMARY KEY(id))");
+ }
+
[Test]
public void MultiWord()
{
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
- MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString();
- DataTable dt = new DataTable();
- da.Fill(dt);
+ try
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
+ MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
- DataRow row = dt.NewRow();
- row["id"] = 1;
- row["name"] = "Name";
- row["dt"] = DBNull.Value;
- row["tm"] = DBNull.Value;
- row["multi word"] = 2;
- dt.Rows.Add( row );
- da.Update( dt );
- Assert.AreEqual( 1, dt.Rows.Count );
- Assert.AreEqual( 2, dt.Rows[0]["multi word"] );
+ DataRow row = dt.NewRow();
+ row["id"] = 1;
+ row["name"] = "Name";
+ row["dt"] = DBNull.Value;
+ row["tm"] = DBNull.Value;
+ row["multi word"] = 2;
+ dt.Rows.Add(row);
+ da.Update(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(2, dt.Rows[0]["multi word"]);
- dt.Rows[0]["multi word"] = 3;
- da.Update( dt );
- Assert.AreEqual( 1, dt.Rows.Count );
- Assert.AreEqual( 3, dt.Rows[0]["multi word"] );
+ dt.Rows[0]["multi word"] = 3;
+ da.Update(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(3, dt.Rows[0]["multi word"]);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
}
[Test]
@@ -75,7 +86,7 @@
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da, true);
- cb.ToString(); // keep the compiler happy
+
DataTable dt = new DataTable();
da.Fill( dt );
Assert.AreEqual( 1, dt.Rows.Count );
@@ -108,7 +119,7 @@
try
{
dt.Rows[0]["name"] = "Test3";
- da.Update( dt );
+ da.Update(dt);
Assert.Fail("This should not work");
}
catch (DBConcurrencyException)
@@ -116,9 +127,9 @@
}
dt.Rows.Clear();
- da.Fill( dt );
- Assert.AreEqual( 1, dt.Rows.Count );
- Assert.AreEqual( "Test2", dt.Rows[0]["name"] );
+ da.Fill(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("Test2", dt.Rows[0]["name"]);
}
/// <summary>
@@ -222,17 +233,27 @@
execSQL("CREATE TABLE test (id INT NOT NULL, name VARCHAR(100), PRIMARY KEY(id))");
execSQL("INSERT INTO test VALUES(1, 'Data')");
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM test;", conn);
- MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- DataTable dt = new DataTable();
- da.Fill(dt);
- dt.Rows[0]["id"] = 2;
- da.Update(dt);
+ try
+ {
+ DataSet ds = new DataSet();
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM `test`;", conn);
+ da.FillSchema(ds, SchemaType.Source, "test");
- dt.Clear();
- da.Fill(dt);
- Assert.AreEqual(1, dt.Rows.Count);
- Assert.AreEqual(2, dt.Rows[0]["id"]);
+ MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ dt.Rows[0]["id"] = 2;
+ da.Update(dt);
+
+ dt.Clear();
+ da.Fill(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(2, dt.Rows[0]["id"]);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
}
}
}
Modified: branches/1.0/TestSuite/CommandTests.cs
===================================================================
--- branches/1.0/TestSuite/CommandTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/CommandTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -22,6 +22,7 @@
using System.Data;
using MySql.Data.MySqlClient;
using NUnit.Framework;
+using System.Threading;
namespace MySql.Data.MySqlClient.Tests
{
@@ -33,8 +34,6 @@
public void TestFixtureSetUp()
{
Open();
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))");
}
[TestFixtureTearDown]
@@ -43,7 +42,6 @@
Close();
}
-
protected override void Setup()
{
base.Setup();
@@ -96,35 +94,35 @@
// do the update
MySqlCommand cmd = new MySqlCommand("UPDATE Test SET name='Test3' WHERE id=10 OR id=11", conn);
MySqlConnection c = cmd.Connection;
- Assert.AreEqual( conn, c );
+ Assert.AreEqual(conn, c);
int cnt = cmd.ExecuteNonQuery();
- Assert.AreEqual( 2, cnt );
+ Assert.AreEqual(2, cnt);
// make sure we get the right value back out
cmd.CommandText = "SELECT name FROM Test WHERE id=10";
string name = (string)cmd.ExecuteScalar();
- Assert.AreEqual( "Test3", name );
+ Assert.AreEqual("Test3", name);
cmd.CommandText = "SELECT name FROM Test WHERE id=11";
name = (string)cmd.ExecuteScalar();
- Assert.AreEqual( "Test3", name );
+ Assert.AreEqual("Test3", name);
// now do the update with parameters
cmd.CommandText = "UPDATE Test SET name=?name WHERE id=?id";
cmd.Parameters.Add( new MySqlParameter("?id", 11));
cmd.Parameters.Add( new MySqlParameter("?name", "Test5"));
cnt = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, cnt, "Update with Parameters Count" );
+ Assert.AreEqual(1, cnt, "Update with Parameters Count");
// make sure we get the right value back out
cmd.Parameters.Clear();
cmd.CommandText = "SELECT name FROM Test WHERE id=11";
name = (string)cmd.ExecuteScalar();
- Assert.AreEqual( "Test5", name );
+ Assert.AreEqual("Test5", name);
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
}
@@ -139,16 +137,16 @@
// make sure we get the right value back out
MySqlCommand cmd = new MySqlCommand("DELETE FROM Test WHERE id=1 or id=2", conn);
int delcnt = cmd.ExecuteNonQuery();
- Assert.AreEqual( 2, delcnt );
+ Assert.AreEqual(2, delcnt);
// find out how many rows we have now
cmd.CommandText = "SELECT COUNT(*) FROM Test";
object after_cnt = cmd.ExecuteScalar();
- Assert.AreEqual( 0, after_cnt );
+ Assert.AreEqual(0, after_cnt);
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
}
@@ -158,11 +156,11 @@
MySqlTransaction txn = conn.BeginTransaction();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn);
- MySqlCommand clone = new MySqlCommand( cmd.CommandText, (MySqlConnection)cmd.Connection,
- (MySqlTransaction)cmd.Transaction );
- clone.Parameters.Add( "?test", 1 );
- txn.Rollback();
- }
+ MySqlCommand clone = new MySqlCommand(cmd.CommandText, (MySqlConnection)cmd.Connection,
+ (MySqlTransaction)cmd.Transaction);
+ clone.Parameters.Add("?test", 1);
+ txn.Rollback();
+ }
[Test]
public void CloneCommand()
@@ -223,7 +221,7 @@
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -297,45 +295,47 @@
}
}
- /// <summary>
- /// Bug# 8119. Unable to reproduce but left in anyway
- /// </summary>
- [Test]
- public void ReallyBigCommandString()
- {
- System.Text.StringBuilder sql = new System.Text.StringBuilder();
+ /// <summary>
+ /// Bug# 8119. Unable to reproduce but left in anyway
+ /// </summary>
+ [Category("NotWorking")]
+ [Test]
+ public void ReallyBigCommandString()
+ {
+ System.Text.StringBuilder sql = new System.Text.StringBuilder();
- for (int i=0; i < 10; i++)
- sql.Append("DROP TABLE IF EXISTS idx" + i + ";CREATE TABLE idx" + i + "(aa int not null auto_increment primary key, a int, b varchar(50), c int);");
+ for (int i = 0; i < 10; i++)
+ sql.Append("DROP TABLE IF EXISTS idx" + i + ";CREATE TABLE idx" + i + "(aa int not null auto_increment primary key, a int, b varchar(50), c int);");
- int c = 0;
- for (int z=0; z < 600; z++)
- for (int x=0; x < 10; x++, c++)
- {
- string s = String.Format("INSERT INTO idx{0} (a, b, c) values ({1}, 'field{1}', {2});",
- x, z, c);
- sql.Append(s);
- }
+ int c = 0;
+ for (int z = 0; z < 100; z++)
+ for (int x = 0; x < 10; x++, c++)
+ {
+ string s = String.Format("INSERT INTO idx{0} (a, b, c) values ({1}, 'field{1}', {2});",
+ x, z, c);
+ sql.Append(s);
+ }
- try
- {
- MySqlCommand cmd = new MySqlCommand(sql.ToString(), conn);
- cmd.ExecuteNonQuery();
-
- for (int i=0; i < 10; i++)
- {
- cmd.CommandText = "SELECT COUNT(*) FROM idx" + i;
- object count = cmd.ExecuteScalar();
- Assert.AreEqual( 600, count );
- execSQL("DROP TABLE IF EXISTS idx" + i );
- }
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- }
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand(sql.ToString(), conn);
+ cmd.ExecuteNonQuery();
+ for (int i = 0; i < 10; i++)
+ {
+ cmd.CommandText = "SELECT COUNT(*) FROM idx" + i;
+ object count = cmd.ExecuteScalar();
+ Assert.AreEqual(100, count);
+ execSQL("DROP TABLE IF EXISTS idx" + i);
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+
+ }
+
/// <summary>
/// Bug #7248 There is already an open DataReader associated with this Connection which must
/// </summary>
@@ -369,7 +369,7 @@
{
object o = cmd.ExecuteScalar();
}
- catch (Exception ex)
+ catch (Exception)
{
}
@@ -384,9 +384,10 @@
}
}
+
#region Configs
- [Category("Compressed")]
+ [Category("Compressed")]
public class CommandTestsSocketCompressed : CommandTests
{
protected override string GetConnectionInfo()
@@ -404,8 +405,8 @@
}
}
- [Category("Compressed")]
- [Category("Pipe")]
+ [Category("Compressed")]
+ [Category("Pipe")]
public class CommandTestsPipeCompressed : CommandTests
{
protected override string GetConnectionInfo()
@@ -414,7 +415,7 @@
}
}
- [Category("SharedMemory")]
+ [Category("SharedMemory")]
public class CommandTestsSharedMemory : CommandTests
{
protected override string GetConnectionInfo()
@@ -423,8 +424,8 @@
}
}
- [Category("Compressed")]
- [Category("SharedMemory")]
+ [Category("Compressed")]
+ [Category("SharedMemory")]
public class CommandTestsSharedMemoryCompressed : CommandTests
{
protected override string GetConnectionInfo()
Modified: branches/1.0/TestSuite/ConnectionTests.cs
===================================================================
--- branches/1.0/TestSuite/ConnectionTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/ConnectionTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -50,44 +50,42 @@
MySqlConnection c = new MySqlConnection();
// public properties
- Assert.AreEqual( 15, c.ConnectionTimeout, "ConnectionTimeout" );
- Assert.AreEqual( "", c.Database, "Database" );
- Assert.AreEqual( String.Empty, c.DataSource, "DataSource" );
- Assert.AreEqual( false, c.UseCompression, "Use Compression" );
- Assert.AreEqual( System.Data.ConnectionState.Closed, c.State, "State" );
+ Assert.AreEqual(15, c.ConnectionTimeout, "ConnectionTimeout");
+ Assert.AreEqual("", c.Database, "Database");
+ Assert.AreEqual(String.Empty, c.DataSource, "DataSource");
+ Assert.AreEqual(false, c.UseCompression, "Use Compression");
+ Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State");
c = new MySqlConnection("connection timeout=25; user id=myuser; " +
"password=mypass; database=Test;server=myserver; use compression=true; " +
"pooling=false;min pool size=5; max pool size=101");
// public properties
- Assert.AreEqual( 25, c.ConnectionTimeout, "ConnectionTimeout" );
- Assert.AreEqual( "Test", c.Database, "Database" );
- Assert.AreEqual( "myserver", c.DataSource, "DataSource" );
- Assert.AreEqual( true, c.UseCompression, "Use Compression" );
- Assert.AreEqual( System.Data.ConnectionState.Closed, c.State, "State" );
+ Assert.AreEqual(25, c.ConnectionTimeout, "ConnectionTimeout");
+ Assert.AreEqual("Test", c.Database, "Database");
+ Assert.AreEqual("myserver", c.DataSource, "DataSource");
+ Assert.AreEqual(true, c.UseCompression, "Use Compression");
+ Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State");
c.ConnectionString = "connection timeout=15; user id=newuser; " +
"password=newpass; port=3308; database=mydb; data source=myserver2; " +
"use compression=true; pooling=true; min pool size=3; max pool size=76";
// public properties
- Assert.AreEqual( 15, c.ConnectionTimeout, "ConnectionTimeout" );
- Assert.AreEqual( "mydb", c.Database, "Database" );
- Assert.AreEqual( "myserver2", c.DataSource, "DataSource" );
- Assert.AreEqual( true, c.UseCompression, "Use Compression" );
- Assert.AreEqual( System.Data.ConnectionState.Closed, c.State, "State" );
+ Assert.AreEqual(15, c.ConnectionTimeout, "ConnectionTimeout");
+ Assert.AreEqual("mydb", c.Database, "Database");
+ Assert.AreEqual("myserver2", c.DataSource, "DataSource");
+ Assert.AreEqual(true, c.UseCompression, "Use Compression");
+ Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State");
}
[Test]
[ExpectedException(typeof(MySqlException))]
public void TestConnectingSocketBadUserName()
{
- string host = ConfigurationSettings.AppSettings["host"];
-
execSQL("DELETE FROM mysql.user WHERE length(user) = 0");
execSQL("FLUSH PRIVILEGES");
- string connStr = "server={0};user id=dummy;password=;database=Test";
+ string connStr = "server={0};user id=dummy;password=;database=Test;pooling=false";
MySqlConnection c = new MySqlConnection(
String.Format(connStr, host));
c.Open();
@@ -98,8 +96,6 @@
[ExpectedException(typeof(MySqlException))]
public void TestConnectingSocketBadDbName()
{
- string host = ConfigurationSettings.AppSettings["host"];
-
string connStr = "server={0};user id={1};password={2};database=dummy; " +
"pooling=false";
MySqlConnection c = new MySqlConnection(
@@ -111,8 +107,6 @@
[Test]
public void TestPersistSecurityInfoCachingPasswords()
{
- string host = ConfigurationSettings.AppSettings["host"];
-
string connStr = String.Format("database=test;server={0};user id={1};Password={2}; pooling=false",
host, this.user, this.password );
MySqlConnection c = new MySqlConnection( connStr );
@@ -142,28 +136,29 @@
c.Close();
}
- [Test()]
+ [Test]
public void ChangeDatabase()
{
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";pooling=false" );
+ string connStr = GetConnectionString(true);
+ MySqlConnection c = new MySqlConnection(connStr + ";pooling=false");
c.Open();
Assert.IsTrue(c.State == ConnectionState.Open);
- Assert.AreEqual( "test", c.Database.ToLower() );
+ Assert.AreEqual("test", c.Database.ToLower());
- c.ChangeDatabase( "mysql" );
+ c.ChangeDatabase("mysql");
- Assert.AreEqual( "mysql", c.Database.ToLower() );
+ Assert.AreEqual("mysql", c.Database.ToLower());
c.Close();
}
- [Test()]
+ [Test]
public void ConnectionTimeout()
{
-
MySqlConnection c = new MySqlConnection(
- "server=1.1.1.1;user id=bogus;pwd=bogus;Connection timeout=5;pooling=false" );
+ "server=1.1.1.1;user id=bogus;pwd=bogus;Connection timeout=5;" +
+ "pooling=false");
DateTime start = DateTime.Now;
try
{
@@ -171,8 +166,8 @@
}
catch (Exception)
{
- TimeSpan diff = DateTime.Now.Subtract( start );
- Assert.IsTrue( diff.TotalSeconds < 6, "Timeout exceeded" );
+ TimeSpan diff = DateTime.Now.Subtract(start);
+ Assert.IsTrue(diff.TotalSeconds < 15, "Timeout exceeded");
}
}
@@ -184,18 +179,18 @@
string connStr = conn.ConnectionString;
// connect with no db
- string connStr2 = connStr.Replace("database=test;","");
- MySqlConnection c = new MySqlConnection( connStr2 );
+ string connStr2 = GetConnectionString(false);
+ MySqlConnection c = new MySqlConnection(connStr2);
c.Open();
c.Close();
- execSQL("GRANT ALL ON *.* to ''@'localhost'");
- execSQL("FLUSH PRIVILEGES");
+ // TODO: make anonymous login work
+ execSQL("GRANT ALL ON *.* to '' IDENTIFIED BY ''");
// connect with all defaults
if (connStr.IndexOf("localhost") != -1)
{
- c = new MySqlConnection( String.Empty );
+ c = new MySqlConnection(String.Empty);
c.Open();
c.Close();
}
@@ -204,14 +199,13 @@
execSQL("FLUSH PRIVILEGES");
// connect with no password
- string host = System.Configuration.ConfigurationSettings.AppSettings["host"];
connStr2 = "server=" + host + ";user id=nopass";
- c = new MySqlConnection( connStr2 );
+ c = new MySqlConnection(connStr2);
c.Open();
c.Close();
connStr2 += ";password=;";
- c = new MySqlConnection( connStr2 );
+ c = new MySqlConnection(connStr2);
c.Open();
c.Close();
}
@@ -251,7 +245,7 @@
MySqlConnection d = new MySqlConnection(connStr);
d.Open();
- MySqlCommand cmd2 = new MySqlCommand( "SELECT id, active FROM test", d);
+ MySqlCommand cmd2 = new MySqlCommand("SELECT id, active FROM test", d);
MySqlDataReader reader = null;
try
{
@@ -293,21 +287,28 @@
string s = GetConnectionString(true).ToLower();
int start = s.IndexOf("persist security info");
int end = s.IndexOf(";", start);
- string newConnStr = s.Substring(0, start);
- newConnStr += s.Substring(end, s.Length - (end));
- newConnStr += ";persist security info=false";
+ string connStr = s.Substring(0, start);
+ connStr += s.Substring(end, s.Length - (end));
+ string p = "password";
+ if (connStr.IndexOf("pwd") != -1)
+ p = "pwd";
+ else if (connStr.IndexOf("passwd") != -1)
+ p = "passwd";
+
+ string newConnStr = connStr + ";persist security info=true";
MySqlConnection conn2 = new MySqlConnection(newConnStr);
- string p = "password";
- if (conn2.ConnectionString.IndexOf("pwd") != -1)
- p = "pwd";
- else if (conn2.ConnectionString.IndexOf("passwd") != -1)
- p = "passwd";
-
Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1);
conn2.Open();
conn2.Close();
- Assert.IsTrue(conn2.ConnectionString.IndexOf(p) == -1);
+ Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1);
+
+ newConnStr = connStr + ";persist security info=false";
+ conn2 = new MySqlConnection(newConnStr);
+ Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1);
+ conn2.Open();
+ conn2.Close();
+ Assert.IsTrue(conn2.ConnectionString.IndexOf(p) == -1);
}
/// <summary>
@@ -330,7 +331,6 @@
public void ConnectWithQuotePassword()
{
execSQL("GRANT ALL ON *.* to 'test'@'localhost' IDENTIFIED BY '\"'");
- string host = ConfigurationSettings.AppSettings["host"];
MySqlConnection c = new MySqlConnection("server=" + host + ";uid=test;pwd='\"';pooling=false");
try
{
Modified: branches/1.0/TestSuite/CultureTests.cs
===================================================================
--- branches/1.0/TestSuite/CultureTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/CultureTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -66,21 +66,21 @@
CultureInfo c = new CultureInfo("de-DE");
Thread.CurrentThread.CurrentCulture = c;
Thread.CurrentThread.CurrentUICulture = c;
+
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (fl FLOAT, db DOUBLE, dec1 DECIMAL(5,2))");
- execSQL( "DROP TABLE IF EXISTS Test" );
- execSQL( "CREATE TABLE Test (fl FLOAT, db DOUBLE, dec1 DECIMAL(5,2))" );
-
MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?fl, ?db, ?dec)", conn);
- cmd.Parameters.Add( "?fl", MySqlDbType.Float );
- cmd.Parameters.Add( "?db", MySqlDbType.Double );
- cmd.Parameters.Add( "?dec", MySqlDbType.Decimal );
+ cmd.Parameters.Add("?fl", MySqlDbType.Float);
+ cmd.Parameters.Add("?db", MySqlDbType.Double);
+ cmd.Parameters.Add("?dec", MySqlDbType.Decimal);
cmd.Parameters[0].Value = 2.3;
cmd.Parameters[1].Value = 4.6;
cmd.Parameters[2].Value = 23.82;
if (prepared)
cmd.Prepare();
int count = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, count );
+ Assert.AreEqual(1, count);
MySqlDataReader reader = null;
try
@@ -89,13 +89,13 @@
if (prepared) cmd.Prepare();
reader = cmd.ExecuteReader();
reader.Read();
- Assert.AreEqual( 2.3, reader.GetFloat(0) );
- Assert.AreEqual( 4.6, reader.GetDouble(1) );
- Assert.AreEqual( 23.82, reader.GetDecimal(2) );
+ Assert.AreEqual(2.3, reader.GetFloat(0));
+ Assert.AreEqual(4.6, reader.GetDouble(1));
+ Assert.AreEqual(23.82, reader.GetDecimal(2));
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
Modified: branches/1.0/TestSuite/DataAdapterTests.cs
===================================================================
--- branches/1.0/TestSuite/DataAdapterTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/DataAdapterTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -45,7 +45,9 @@
base.Setup();
execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL AUTO_INCREMENT, id2 INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, ts TIMESTAMP, OriginalId INT, PRIMARY KEY(id, id2))");
+ execSQL("CREATE TABLE Test (id INT NOT NULL AUTO_INCREMENT, " +
+ "id2 INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, " +
+ "ts TIMESTAMP, OriginalId INT, PRIMARY KEY(id, id2))");
}
@@ -88,48 +90,49 @@
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
da.Fill(dt);
DataRow dr = dt.NewRow();
dr["id2"] = 2;
dr["name"] = "TestName1";
- dt.Rows.Add( dr );
-
+ dt.Rows.Add(dr);
int count = da.Update(dt);
// make sure our refresh of auto increment values worked
- Assert.AreEqual( 1, count, "checking insert count" );
- Assert.IsNotNull( dt.Rows[ dt.Rows.Count-1 ]["id"], "Checking auto increment column" );
+ Assert.AreEqual(1, count, "checking insert count");
+ Assert.IsNotNull(dt.Rows[ dt.Rows.Count-1 ]["id"],
+ "Checking auto increment column");
+ dt.Rows.Clear();
+ da.Fill(dt);
dt.Rows[0]["id2"] = 3;
dt.Rows[0]["name"] = "TestName2";
dt.Rows[0]["ts"] = DBNull.Value;
DateTime day1 = new DateTime(2003, 1, 16, 12, 24, 0);
dt.Rows[0]["dt"] = day1;
dt.Rows[0]["tm"] = day1.TimeOfDay;
- count = da.Update( dt );
+ count = da.Update(dt);
- Assert.IsNotNull( dt.Rows[0]["ts"], "checking refresh of record" );
- Assert.AreEqual( 3, dt.Rows[0]["id2"], "checking refresh of primary column" );
+ Assert.IsNotNull(dt.Rows[0]["ts"], "checking refresh of record");
+ Assert.AreEqual(3, dt.Rows[0]["id2"], "checking refresh of primary column");
dt.Rows.Clear();
- da.Fill( dt );
+ da.Fill(dt);
- Assert.AreEqual( 1, count, "checking update count" );
+ Assert.AreEqual(1, count, "checking update count");
DateTime dateTime = (DateTime)dt.Rows[0]["dt"];
- Assert.AreEqual( day1, dateTime, "checking date" );
- Assert.AreEqual( day1.TimeOfDay, dt.Rows[0]["tm"], "checking time" );
+ Assert.AreEqual(day1, dateTime, "checking date");
+ Assert.AreEqual(day1.TimeOfDay, dt.Rows[0]["tm"], "checking time");
dt.Rows[0].Delete();
- count = da.Update( dt );
+ count = da.Update(dt);
- Assert.AreEqual( 1, count, "checking insert count" );
+ Assert.AreEqual(1, count, "checking insert count");
dt.Rows.Clear();
da.Fill(dt);
- Assert.AreEqual( 0, dt.Rows.Count, "checking row count" );
+ Assert.AreEqual(0, dt.Rows.Count, "checking row count");
}
[Test]
@@ -360,7 +363,6 @@
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString(); // keep the compiler happy
DataSet ds = new DataSet();
da.Fill(ds);
Assert.AreEqual(1, ds.Tables[0].Rows[0]["id"]);
@@ -416,7 +418,7 @@
/// Bug #8514 CURRENT_TIMESTAMP default not respected
/// </summary>
[Test]
- [Category("NotWorking")]
+ [Category("NotWorking")]
public void DefaultValues()
{
execSQL("DROP TABLE IF EXISTS test");
@@ -534,7 +536,7 @@
reader.Close();
}
}
-
+
/// <summary>
/// Bug #8131 Data Adapter doesn't close connection
/// </summary>
Modified: branches/1.0/TestSuite/DataReaderTests.cs
===================================================================
--- branches/1.0/TestSuite/DataReaderTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/DataReaderTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -48,9 +48,9 @@
protected override void Setup()
{
base.Setup();
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), d DATE, dt DATETIME, b1 LONGBLOB, PRIMARY KEY(id))");
- }
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), d DATE, dt DATETIME, b1 LONGBLOB, PRIMARY KEY(id))");
+ }
[Test]
@@ -107,13 +107,15 @@
{
for (int x=0; x < 10; x++)
{
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";pooling=false" );
+ MySqlConnection c = new MySqlConnection( conn.ConnectionString +
+ ";pooling=false" );
c.Open();
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name, b1) VALUES(?val, 'Test', NULL)", c);
- cmd.Parameters.Add( new MySqlParameter("?val", x));
+ MySqlCommand cmd = new MySqlCommand(
+ "INSERT INTO Test (id, name, b1) VALUES(?val, 'Test', NULL)", c);
+ cmd.Parameters.Add(new MySqlParameter("?val", x));
int affected = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, affected );
+ Assert.AreEqual(1, affected);
cmd = new MySqlCommand("SELECT * FROM Test", c);
cmd.ExecuteReader();
@@ -125,9 +127,10 @@
public void GetBytes()
{
int len = 50000;
- byte[] bytes = Utils.CreateBlob( len );
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name, b1) VALUES(1, 'Test', ?b1)", conn);
- cmd.Parameters.Add( "?b1", bytes );
+ byte[] bytes = Utils.CreateBlob(len);
+ MySqlCommand cmd = new MySqlCommand(
+ "INSERT INTO Test (id, name, b1) VALUES(1, 'Test', ?b1)", conn);
+ cmd.Parameters.Add("?b1", bytes);
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT * FROM Test";
@@ -137,21 +140,21 @@
reader = cmd.ExecuteReader();
reader.Read();
- long sizeBytes = reader.GetBytes( 4, 0, null, 0, 0 );
- Assert.AreEqual( len, sizeBytes );
+ long sizeBytes = reader.GetBytes(4, 0, null, 0, 0);
+ Assert.AreEqual(len, sizeBytes);
byte[] buff1 = new byte[len/2];
byte[] buff2 = new byte[len - (len/2)];
- long buff1cnt = reader.GetBytes( 4, 0, buff1, 0, len /2 );
- long buff2cnt = reader.GetBytes( 4, buff1cnt, buff2, 0, buff2.Length );
- Assert.AreEqual( buff1.Length, buff1cnt );
- Assert.AreEqual( buff2.Length, buff2cnt );
+ long buff1cnt = reader.GetBytes(4, 0, buff1, 0, len /2);
+ long buff2cnt = reader.GetBytes(4, buff1cnt, buff2, 0, buff2.Length);
+ Assert.AreEqual(buff1.Length, buff1cnt);
+ Assert.AreEqual(buff2.Length, buff2cnt);
for (int i=0; i<buff1.Length; i++)
- Assert.AreEqual( bytes[i], buff1[i] );
+ Assert.AreEqual(bytes[i], buff1[i]);
for (int i=0; i<buff2.Length; i++)
- Assert.AreEqual( bytes[buff1.Length + i], buff2[i] );
+ Assert.AreEqual(bytes[buff1.Length + i], buff2[i]);
reader.Close();
@@ -163,11 +166,11 @@
int startIndex = 0;
while (mylen > 0)
{
- int readLen = Math.Min( mylen, buff.Length );
+ int readLen = Math.Min(mylen, buff.Length);
int retVal = (int)reader.GetBytes(4, startIndex, buff, 0, readLen);
- Assert.AreEqual( readLen, retVal );
+ Assert.AreEqual(readLen, retVal);
for (int i=0; i < readLen; i++)
- Assert.AreEqual( bytes[startIndex+i], buff[i] );
+ Assert.AreEqual(bytes[startIndex+i], buff[i]);
startIndex += readLen;
mylen -= readLen;
}
@@ -190,73 +193,74 @@
execSQL("INSERT INTO Test (id, name, b1) VALUES (1, 'Test1', NULL)");
execSQL("INSERT INTO Test (id, name, b1) VALUES (2, 'Test1', NULL)");
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test WHERE id=1; SELECT * FROM Test WHERE id=2", conn);
- MySqlDataReader reader = cmd.ExecuteReader( CommandBehavior.SingleResult );
+ MySqlCommand cmd = new MySqlCommand(
+ "SELECT * FROM Test WHERE id=1; SELECT * FROM Test WHERE id=2", conn);
+ MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult);
bool result = reader.Read();
- Assert.AreEqual( true, result );
+ Assert.AreEqual(true, result);
result = reader.NextResult();
- Assert.AreEqual( false, result );
+ Assert.AreEqual(false, result);
reader.Close();
}
- [Test]
- public void GetSchema()
- {
- string sql = "CREATE TABLE test2(id INT UNSIGNED AUTO_INCREMENT " +
+ [Test]
+ public void GetSchema()
+ {
+ string sql = "CREATE TABLE test2(id INT UNSIGNED AUTO_INCREMENT " +
"NOT NULL, name VARCHAR(255) NOT NULL, name2 VARCHAR(40), fl FLOAT, " +
"dt DATETIME, PRIMARY KEY(id))";
- execSQL("DROP TABLE IF EXISTS test2");
- execSQL(sql);
- execSQL("INSERT INTO test2 VALUES(1,'Test', 'Test', 1.0, now())");
+ execSQL("DROP TABLE IF EXISTS test2");
+ execSQL(sql);
+ execSQL("INSERT INTO test2 VALUES(1,'Test', 'Test', 1.0, now())");
- MySqlDataReader reader = null;
+ MySqlDataReader reader = null;
- try
- {
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM test2", conn);
- reader = cmd.ExecuteReader();
- DataTable dt = reader.GetSchemaTable();
- Assert.AreEqual(true, dt.Rows[0]["IsAutoIncrement"], "Checking auto increment");
- Assert.AreEqual(true, dt.Rows[0]["IsUnique"], "Checking IsUnique");
- Assert.AreEqual(false, dt.Rows[0]["AllowDBNull"], "Checking AllowDBNull");
- Assert.AreEqual(false, dt.Rows[1]["AllowDBNull"], "Checking AllowDBNull");
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test2", conn);
+ reader = cmd.ExecuteReader();
+ DataTable dt = reader.GetSchemaTable();
+ Assert.AreEqual(true, dt.Rows[0]["IsAutoIncrement"], "Checking auto increment");
+ Assert.AreEqual(true, dt.Rows[0]["IsUnique"], "Checking IsUnique");
+ Assert.AreEqual(false, dt.Rows[0]["AllowDBNull"], "Checking AllowDBNull");
+ Assert.AreEqual(false, dt.Rows[1]["AllowDBNull"], "Checking AllowDBNull");
Assert.AreEqual(255, dt.Rows[1]["ColumnSize"]);
Assert.AreEqual(40, dt.Rows[2]["ColumnSize"]);
}
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
- execSQL("DROP TABLE IF EXISTS test2");
- }
+ execSQL("DROP TABLE IF EXISTS test2");
+ }
[Test]
public void CloseConnectionBehavior()
{
execSQL("INSERT INTO Test(id,name) VALUES(1,'test')");
- MySqlConnection c2 = new MySqlConnection( conn.ConnectionString );
+ MySqlConnection c2 = new MySqlConnection(conn.ConnectionString);
c2.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c2);
MySqlDataReader reader = null;
try
{
- reader = cmd.ExecuteReader( CommandBehavior.CloseConnection );
- Assert.IsTrue( reader.Read() );
+ reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
+ Assert.IsTrue(reader.Read());
reader.Close();
- Assert.IsTrue( c2.State == ConnectionState.Closed );
+ Assert.IsTrue(c2.State == ConnectionState.Closed);
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -313,22 +317,22 @@
MySqlDataReader reader = null;
try
{
- reader = cmd.ExecuteReader( CommandBehavior.SingleRow );
- Assert.IsTrue( reader.Read(), "First read" );
- Assert.IsFalse( reader.Read(), "Second read" );
- Assert.IsFalse( reader.NextResult(), "Trying NextResult" );
+ reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
+ Assert.IsTrue(reader.Read(), "First read");
+ Assert.IsFalse(reader.Read(), "Second read");
+ Assert.IsFalse(reader.NextResult(), "Trying NextResult");
reader.Close();
- reader = cmd.ExecuteReader( CommandBehavior.SingleRow );
- Assert.IsTrue( reader.Read(), "First read" );
- Assert.IsFalse( reader.Read(), "Second read" );
- Assert.IsFalse( reader.NextResult(), "Trying NextResult" );
+ reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
+ Assert.IsTrue(reader.Read(), "First read");
+ Assert.IsFalse(reader.Read(), "Second read");
+ Assert.IsFalse(reader.NextResult(), "Trying NextResult");
reader.Close();
- reader = cmd.ExecuteReader( CommandBehavior.SingleRow );
- Assert.IsTrue( reader.Read(), "First read" );
- Assert.IsFalse( reader.Read(), "Second read" );
- Assert.IsFalse( reader.NextResult(), "Trying NextResult" );
+ reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
+ Assert.IsTrue(reader.Read(), "First read");
+ Assert.IsFalse(reader.Read(), "Second read");
+ Assert.IsFalse(reader.NextResult(), "Trying NextResult");
reader.Close();
}
catch (Exception ex)
@@ -351,11 +355,11 @@
try
{
reader = cmd.ExecuteReader();
- Assert.IsTrue( reader.Read(), "First read" );
- Assert.AreEqual( 1, reader.GetInt32(0) );
- Assert.AreEqual( "test1", reader.GetString(1) );
- Assert.IsFalse( reader.Read(), "Second read" );
- Assert.IsFalse( reader.NextResult(), "Trying NextResult" );
+ Assert.IsTrue(reader.Read(), "First read");
+ Assert.AreEqual(1, reader.GetInt32(0));
+ Assert.AreEqual("test1", reader.GetString(1));
+ Assert.IsFalse(reader.Read(), "Second read");
+ Assert.IsFalse(reader.NextResult(), "Trying NextResult");
}
catch (Exception ex)
{
@@ -367,26 +371,26 @@
}
}
- [Test]
- public void ConsecutiveNulls()
- {
- execSQL("INSERT INTO Test (id, name, dt) VALUES (1, 'Test', NULL)");
- execSQL("INSERT INTO Test (id, name, dt) VALUES (2, NULL, now())");
- execSQL("INSERT INTO Test (id, name, dt) VALUES (3, 'Test2', NULL)");
+ [Test]
+ public void ConsecutiveNulls()
+ {
+ execSQL("INSERT INTO Test (id, name, dt) VALUES (1, 'Test', NULL)");
+ execSQL("INSERT INTO Test (id, name, dt) VALUES (2, NULL, now())");
+ execSQL("INSERT INTO Test (id, name, dt) VALUES (3, 'Test2', NULL)");
- MySqlCommand cmd = new MySqlCommand("SELECT id, name, dt FROM Test", conn);
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- reader.Read();
- Assert.AreEqual(1, reader.GetValue(0));
- Assert.AreEqual("Test", reader.GetValue(1));
- Assert.AreEqual("Test", reader.GetString(1));
+ MySqlCommand cmd = new MySqlCommand("SELECT id, name, dt FROM Test", conn);
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ reader.Read();
+ Assert.AreEqual(1, reader.GetValue(0));
+ Assert.AreEqual("Test", reader.GetValue(1));
+ Assert.AreEqual("Test", reader.GetString(1));
Assert.AreEqual(DBNull.Value, reader.GetValue(2));
- reader.Read();
- Assert.AreEqual(2, reader.GetValue(0));
- Assert.AreEqual(DBNull.Value, reader.GetValue(1));
+ reader.Read();
+ Assert.AreEqual(2, reader.GetValue(0));
+ Assert.AreEqual(DBNull.Value, reader.GetValue(1));
try
{
reader.GetString(1);
@@ -395,9 +399,9 @@
catch (Exception) { }
Assert.IsFalse(reader.IsDBNull(2));
reader.Read();
- Assert.AreEqual(3, reader.GetValue(0));
- Assert.AreEqual("Test2", reader.GetValue(1));
- Assert.AreEqual("Test2", reader.GetString(1));
+ Assert.AreEqual(3, reader.GetValue(0));
+ Assert.AreEqual("Test2", reader.GetValue(1));
+ Assert.AreEqual("Test2", reader.GetString(1));
Assert.AreEqual(DBNull.Value, reader.GetValue(2));
try
{
@@ -406,19 +410,19 @@
}
catch (Exception) { }
Assert.IsFalse(reader.Read());
- Assert.IsFalse(reader.NextResult());
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
+ Assert.IsFalse(reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
- [Test()]
+ [Test]
public void HungDataReader()
{
MySqlCommand cmd = new MySqlCommand("USE test; SHOW TABLES", conn);
@@ -433,7 +437,7 @@
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -441,10 +445,10 @@
}
}
- /// <summary>
- /// Added test for IsDBNull from bug# 7399
+ /// <summary>
+ /// Added test for IsDBNull from bug# 7399
/// </summary>
- [Test()]
+ [Test]
public void SequentialAccessBehavior()
{
execSQL("INSERT INTO Test(id,name) VALUES(1,'test1')");
@@ -453,22 +457,22 @@
MySqlDataReader reader = null;
try
{
- reader = cmd.ExecuteReader( CommandBehavior.SequentialAccess );
- Assert.IsTrue( reader.Read() );
- Assert.IsFalse( reader.IsDBNull(0));
- int i = reader.GetInt32(0);
+ reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
+ Assert.IsTrue(reader.Read());
+ Assert.IsFalse(reader.IsDBNull(0));
+ int i = reader.GetInt32(0);
string s = reader.GetString(1);
- Assert.AreEqual(1, i);
+ Assert.AreEqual(1, i);
Assert.AreEqual("test1", s);
// this next line should throw an exception
- i = reader.GetInt32( 0 );
- Assert.Fail( "This line should not execute" );
+ i = reader.GetInt32(0);
+ Assert.Fail("This line should not execute");
}
catch (MySqlException) { }
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -823,7 +827,7 @@
string s = reader.GetString(reader.GetOrdinal("Sub_part"));
Assert.Fail("We should not get here");
}
- catch (System.Data.SqlTypes.SqlNullValueException ex1)
+ catch (System.Data.SqlTypes.SqlNullValueException)
{
}
catch (Exception ex)
Modified: branches/1.0/TestSuite/DataTypeTests.cs
===================================================================
--- branches/1.0/TestSuite/DataTypeTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/DataTypeTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -53,18 +53,18 @@
execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), d DATE, dt DATETIME, tm TIME, PRIMARY KEY(id))");
}
- [Test]
- public void BytesAndBooleans()
- {
- InternalBytesAndBooleans(false);
+ [Test]
+ public void BytesAndBooleans()
+ {
+ InternalBytesAndBooleans(false);
}
[Category("4.1")]
[Test]
public void BytesAndBooleansPrepared()
{
- InternalBytesAndBooleans(true);
- }
+ InternalBytesAndBooleans(true);
+ }
private void InternalBytesAndBooleans(bool prepare)
{
@@ -122,46 +122,48 @@
execSQL("CREATE TABLE Test (fl FLOAT, db DOUBLE, dec1 DECIMAL(5,2))");
MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?fl, ?db, ?dec)", conn);
- cmd.Parameters.Add( "?fl", MySqlDbType.Float );
- cmd.Parameters.Add( "?db", MySqlDbType.Double );
- cmd.Parameters.Add( "?dec", MySqlDbType.Decimal );
+ cmd.Parameters.Add("?fl", MySqlDbType.Float);
+ cmd.Parameters.Add("?db", MySqlDbType.Double);
+ cmd.Parameters.Add("?dec", MySqlDbType.Decimal);
cmd.Parameters[0].Value = 2.3;
cmd.Parameters[1].Value = 4.6;
cmd.Parameters[2].Value = 23.82;
if (prepared)
cmd.Prepare();
int count = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, count );
+ Assert.AreEqual(1, count);
cmd.Parameters[0].Value = 1.5;
cmd.Parameters[1].Value = 47.85;
cmd.Parameters[2].Value = 123.85;
count = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, count );
+ Assert.AreEqual(1, count);
MySqlDataReader reader = null;
try
{
cmd.CommandText = "SELECT * FROM Test";
- if (prepared) cmd.Prepare();
+ if (prepared)
+ cmd.Prepare();
reader = cmd.ExecuteReader();
- Assert.IsTrue( reader.Read() );
- Assert.AreEqual( 2.3, reader.GetFloat(0) );
- Assert.AreEqual( 4.6, reader.GetDouble(1) );
- Assert.AreEqual( 23.82, reader.GetDecimal(2) );
+ Assert.IsTrue(reader.Read());
+ Assert.AreEqual(2.3, reader.GetFloat(0));
+ Assert.AreEqual(4.6, reader.GetDouble(1));
+ Assert.AreEqual(23.82, reader.GetDecimal(2));
- Assert.IsTrue( reader.Read() );
- Assert.AreEqual( 1.5, reader.GetFloat(0) );
- Assert.AreEqual( 47.85, reader.GetDouble(1) );
- Assert.AreEqual( 123.85, reader.GetDecimal(2) );
+ Assert.IsTrue(reader.Read());
+ Assert.AreEqual(1.5, reader.GetFloat(0));
+ Assert.AreEqual(47.85, reader.GetDouble(1));
+ Assert.AreEqual(123.85, reader.GetDecimal(2));
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
- if (reader != null) reader.Close();
+ if (reader != null)
+ reader.Close();
}
}
@@ -278,6 +280,7 @@
execSQL("INSERT INTO Test VALUES (98)");
execSQL("INSERT INTO Test VALUES (1990)");
execSQL("INSERT INTO Test VALUES (2004)");
+ execSQL("SET SQL_MODE=''");
execSQL("INSERT INTO Test VALUES (111111111111111111111)");
MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn);
@@ -286,21 +289,22 @@
{
reader = cmd.ExecuteReader();
reader.Read();
- Assert.AreEqual( 1998, reader.GetUInt32(0) );
+ Assert.AreEqual(1998, reader.GetUInt32(0));
reader.Read();
- Assert.AreEqual( 1990, reader.GetUInt32(0) );
+ Assert.AreEqual(1990, reader.GetUInt32(0));
reader.Read();
- Assert.AreEqual( 2004, reader.GetUInt32(0) );
+ Assert.AreEqual(2004, reader.GetUInt32(0));
reader.Read();
- Assert.AreEqual( 0, reader.GetUInt32(0) );
+ Assert.AreEqual(0, reader.GetUInt32(0));
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
- if (reader != null) reader.Close();
+ if (reader != null)
+ reader.Close();
}
}
@@ -470,73 +474,156 @@
}
}*/
- /// <summary>
- /// Bug #10486 MySqlDataAdapter.Update error for decimal column
- /// </summary>
- [Test]
- public void UpdateDecimalColumns()
- {
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE test (id int not null auto_increment primary key, " +
- "dec1 decimal(10,1))");
+ [Test]
+ public void BitAndDecimal()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (bt1 BIT, bt4 BIT(4), bt11 BIT(11), bt23 BIT(23), bt32 BIT(32)) engine=myisam");
+ execSQL("INSERT INTO test VALUES (1, 2, 120, 240, 1000)");
+ execSQL("INSERT INTO test VALUES (NULL, NULL, 100, NULL, NULL)");
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM test", conn);
- MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString(); // keep the compiler happy
- DataTable dt = new DataTable();
- da.Fill(dt);
- DataRow row = dt.NewRow();
- row["id"] = DBNull.Value;
- row["dec1"] = 23.4;
- dt.Rows.Add(row);
- da.Update(dt);
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ Assert.AreEqual(1, reader.GetInt32(0));
+ Assert.AreEqual(2, reader.GetInt32(1));
+ Assert.AreEqual(120, reader.GetInt32(2));
+ if (Is50)
+ {
+ Assert.AreEqual(240, reader.GetInt32(3));
+ Assert.AreEqual(1000, reader.GetInt32(4));
+ }
+ else
+ {
+ Assert.AreEqual(127, reader.GetInt32(3));
+ Assert.AreEqual(127, reader.GetInt32(4));
+ }
- dt.Clear();
- da.Fill(dt);
- Assert.AreEqual(1, dt.Rows.Count);
- Assert.AreEqual(1, dt.Rows[0]["id"]);
- Assert.AreEqual(23.4, dt.Rows[0]["dec1"]);
- }
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader.IsDBNull(0));
+ Assert.IsTrue(reader.IsDBNull(1));
+ Assert.AreEqual(100, reader.GetInt32(2));
+ Assert.IsTrue(reader.IsDBNull(3));
+ Assert.IsTrue(reader.IsDBNull(4));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
- [Test]
- public void DecimalTests()
- {
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE test (val decimal(10,1))");
+ /// <summary>
+ /// Bug #10486 MySqlDataAdapter.Update error for decimal column
+ /// </summary>
+ [Test]
+ public void UpdateDecimalColumns()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int not null auto_increment primary key, " +
+ "dec1 decimal(10,1))");
- MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(?dec)", conn);
- cmd.Parameters.Add("?dec", (decimal)2.4);
- Assert.AreEqual(1, cmd.ExecuteNonQuery());
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM test", conn);
+ MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ DataRow row = dt.NewRow();
+ row["id"] = DBNull.Value;
+ row["dec1"] = 23.4;
+ dt.Rows.Add(row);
+ da.Update(dt);
- cmd.Prepare();
- Assert.AreEqual(1, cmd.ExecuteNonQuery());
+ dt.Clear();
+ da.Fill(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(1, dt.Rows[0]["id"]);
+ Assert.AreEqual(23.4, dt.Rows[0]["dec1"]);
+ }
- cmd.CommandText = "SELECT * FROM test";
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- Assert.IsTrue(reader.Read());
- Assert.IsTrue(reader[0] is Decimal);
- Assert.AreEqual(2.4, reader[0]);
+ [Test]
+ public void DecimalTests()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (val decimal(10,1))");
- Assert.IsTrue(reader.Read());
- Assert.IsTrue(reader[0] is Decimal);
- Assert.AreEqual(2.4, reader[0]);
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(?dec)", conn);
+ cmd.Parameters.Add("?dec", (decimal)2.4);
+ Assert.AreEqual(1, cmd.ExecuteNonQuery());
- Assert.IsFalse(reader.Read());
- Assert.IsFalse(reader.NextResult());
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
+ cmd.Prepare();
+ Assert.AreEqual(1, cmd.ExecuteNonQuery());
+ cmd.CommandText = "SELECT * FROM test";
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader[0] is Decimal);
+ Assert.AreEqual(2.4, reader[0]);
+
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader[0] is Decimal);
+ Assert.AreEqual(2.4, reader[0]);
+
+ Assert.IsFalse(reader.Read());
+ Assert.IsFalse(reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ [Test]
+ public void DecimalTests2()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (val decimal(10,1))");
+
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(?dec)", conn);
+ cmd.Parameters.Add("?dec", (decimal)2.4);
+ Assert.AreEqual(1, cmd.ExecuteNonQuery());
+
+ cmd.Prepare();
+ Assert.AreEqual(1, cmd.ExecuteNonQuery());
+
+ cmd.CommandText = "SELECT * FROM test";
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader[0] is Decimal);
+ Assert.AreEqual(2.4, reader[0]);
+
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader[0] is Decimal);
+ Assert.AreEqual(2.4, reader[0]);
+
+ Assert.IsFalse(reader.Read());
+ Assert.IsFalse(reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
[Test]
[Category("5.0")]
public void Bit()
@@ -626,5 +713,6 @@
dr.Close();
}
}
+
}
}
Modified: branches/1.0/TestSuite/DateTimeTests.cs
===================================================================
--- branches/1.0/TestSuite/DateTimeTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/DateTimeTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -37,9 +37,6 @@
public void TestFixtureSetUp()
{
Open();
-
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, dt DATETIME, d DATE, t TIME, ts TIMESTAMP, PRIMARY KEY(id))");
}
[TestFixtureTearDown]
@@ -55,11 +52,12 @@
execSQL("CREATE TABLE Test (id INT NOT NULL, dt DATETIME, d DATE, " +
"t TIME, ts TIMESTAMP, PRIMARY KEY(id))");
}
-
+
[Test]
public void ConvertZeroDateTime()
{
- execSQL("INSERT INTO Test VALUES(1, '0000-00-00', '0000-00-00', '00:00:00', NULL)");
+ execSQL("INSERT INTO Test VALUES(1, '0000-00-00', '0000-00-00', " +
+ "'00:00:00', NULL)");
MySqlConnection c;
MySqlDataReader reader = null;
@@ -92,6 +90,7 @@
[Test]
public void TestNotAllowZerDateAndTime()
{
+ execSQL("SET SQL_MODE=''");
execSQL("INSERT INTO Test VALUES(1, 'Test', '0000-00-00', '0000-00-00', '00:00:00')");
execSQL("INSERT INTO Test VALUES(2, 'Test', '2004-11-11', '2004-11-11', '06:06:06')");
@@ -103,12 +102,12 @@
Assert.IsTrue(reader.Read());
MySqlDateTime testDate = reader.GetMySqlDateTime(2);
- Assert.IsFalse(testDate.IsValidDateTime, "IsZero is false" );
+ Assert.IsFalse(testDate.IsValidDateTime, "IsZero is false");
try
{
- reader.GetValue(2);
- Assert.Fail("This should not work");
+ reader.GetValue(2);
+ Assert.Fail("This should not work");
}
catch (MySqlConversionException) { }
@@ -131,21 +130,22 @@
[Test]
public void DateAdd()
{
- MySqlCommand cmd = new MySqlCommand( "select date_add(?someday, interval 1 hour)", conn);
+ MySqlCommand cmd = new MySqlCommand( "select date_add(?someday, interval 1 hour)",
+ conn);
DateTime now = DateTime.Now;
DateTime later = now.AddHours(1);
- later = later.AddMilliseconds( later.Millisecond * -1 );
+ later = later.AddMilliseconds(later.Millisecond * -1);
cmd.Parameters.Add("?someday", now );
MySqlDataReader reader = null;
try
{
reader = cmd.ExecuteReader();
- Assert.IsTrue( reader.Read() );
+ Assert.IsTrue(reader.Read());
DateTime dt = reader.GetDateTime(0);
- Assert.AreEqual( later.Date, dt.Date );
- Assert.AreEqual( later.Hour, dt.Hour );
- Assert.AreEqual( later.Minute, dt.Minute );
- Assert.AreEqual( later.Second, dt.Second );
+ Assert.AreEqual(later.Date, dt.Date);
+ Assert.AreEqual(later.Hour, dt.Hour);
+ Assert.AreEqual(later.Minute, dt.Minute);
+ Assert.AreEqual(later.Second, dt.Second);
}
catch (Exception ex)
{
@@ -161,33 +161,33 @@
/// Bug #9619 Cannot update row using DbDataAdapter when row contains an invalid date
/// Bug #15112 MySqlDateTime Constructor
/// </summary>
- [Test]
- public void TestAllowZeroDateTime()
- {
- execSQL("INSERT INTO Test (id, d, dt) VALUES (1, '0000-00-00', '0000-00-00 00:00:00')");
+ [Test]
+ public void TestAllowZeroDateTime()
+ {
+ execSQL("INSERT INTO Test (id, d, dt) VALUES (1, '0000-00-00', '0000-00-00 00:00:00')");
- MySqlConnection c = new MySqlConnection(
- conn.ConnectionString + ";pooling=false;AllowZeroDatetime=true");
- c.Open();
- MySqlDataReader reader = null;
- try
- {
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c);
- reader = cmd.ExecuteReader();
- reader.Read();
+ MySqlConnection c = new MySqlConnection(
+ conn.ConnectionString + ";pooling=false;AllowZeroDatetime=true");
+ c.Open();
+ MySqlDataReader reader = null;
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c);
+ reader = cmd.ExecuteReader();
+ reader.Read();
- Assert.IsTrue(reader.GetValue(1) is MySqlDateTime);
- Assert.IsTrue(reader.GetValue(2) is MySqlDateTime);
+ Assert.IsTrue(reader.GetValue(1) is MySqlDateTime);
+ Assert.IsTrue(reader.GetValue(2) is MySqlDateTime);
- Assert.IsFalse(reader.GetMySqlDateTime(1).IsValidDateTime);
- Assert.IsFalse(reader.GetMySqlDateTime(2).IsValidDateTime);
+ Assert.IsFalse(reader.GetMySqlDateTime(1).IsValidDateTime);
+ Assert.IsFalse(reader.GetMySqlDateTime(2).IsValidDateTime);
- try
- {
- reader.GetDateTime(1);
- Assert.Fail("This should not succeed");
- }
- catch (MySqlConversionException) { }
+ try
+ {
+ reader.GetDateTime(1);
+ Assert.Fail("This should not succeed");
+ }
+ catch (MySqlConversionException) {}
reader.Close();
reader = null;
@@ -211,28 +211,28 @@
Assert.AreEqual(2003, date.Year);
Assert.AreEqual(9, date.Month);
Assert.AreEqual(24, date.Day);
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- c.Close();
- }
- }
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ c.Close();
+ }
+ }
[Test]
public void InsertDateTimeValue()
{
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";allow zero datetime=yes");
+ MySqlConnection c = new MySqlConnection( conn.ConnectionString +
+ ";allow zero datetime=yes");
try
{
c.Open();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, dt FROM Test", c);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("id", typeof(int)));
@@ -324,7 +324,7 @@
}
}
- /// <summary>
+ /// <summary>
/// Bug #8929 Timestamp values with a date > 10/29/9997 cause problems
/// </summary>
[Test]
@@ -436,7 +436,7 @@
reader.Close();
}
}
-
+
[Test]
public void DateTimeInDataTable()
{
@@ -473,7 +473,7 @@
if (c != null)
c.Close();
}
- }
+ }
}
}
Modified: branches/1.0/TestSuite/EventTests.cs
===================================================================
--- branches/1.0/TestSuite/EventTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/EventTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -73,7 +73,7 @@
{
Assert.AreEqual(1, args.errors.Length);
}
-
+
[Test]
public void StateChange()
{
@@ -85,6 +85,6 @@
private void StateChangeHandler(object sender, StateChangeEventArgs e)
{
- }
+ }
}
}
Modified: branches/1.0/TestSuite/LanguageTests.cs
===================================================================
--- branches/1.0/TestSuite/LanguageTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/LanguageTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -43,7 +43,7 @@
}
[Test]
- [category("4.1")]
+ [Category("4.1")]
public void Unicode()
{
execSQL( "DROP TABLE IF EXISTS Test" );
Modified: branches/1.0/TestSuite/MySql.Data.Tests.csproj
===================================================================
--- branches/1.0/TestSuite/MySql.Data.Tests.csproj 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/MySql.Data.Tests.csproj 2006-10-01 06:48:18 UTC (rev 388)
@@ -151,6 +151,7 @@
<Compile Include="PreparedStatements.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="SimpleTransactions.cs" />
<Compile Include="StoredProcedure.cs">
<SubType>Code</SubType>
</Compile>
@@ -161,16 +162,10 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Threading.cs" />
- <Compile Include="Transactions.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Utils.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Modified: branches/1.0/TestSuite/MySqlHelperTests.cs
===================================================================
--- branches/1.0/TestSuite/MySqlHelperTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/MySqlHelperTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -57,7 +57,7 @@
try
{
reader = MySqlHelper.ExecuteReader(this.GetConnectionString(true),
- "SELECT * FROM mysql.host WHERE TIME('06/21/2005')");
+ "SELECT * FROM mysql.host WHERE TIME('2005/6/21')");
}
catch (Exception ex)
{
Modified: branches/1.0/TestSuite/ParameterTests.cs
===================================================================
--- branches/1.0/TestSuite/ParameterTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/ParameterTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -35,7 +35,6 @@
public void SetUp()
{
Open();
- execSQL("DROP TABLE IF EXISTS Test; CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, ts TIMESTAMP, PRIMARY KEY(id))");
}
[TestFixtureTearDown]
@@ -50,7 +49,7 @@
execSQL("DROP TABLE IF EXISTS Test");
execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, ts TIMESTAMP, PRIMARY KEY(id))");
}
-
+
[Test]
public void TestUserVariables()
{
@@ -181,35 +180,37 @@
[Test]
public void NestedQuoting()
{
- MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES(1, 'this is ?\"my value\"')", conn);
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) " +
+ "VALUES(1, 'this is ?\"my value\"')", conn);
int count = cmd.ExecuteNonQuery();
- Assert.AreEqual( 1, count );
+ Assert.AreEqual(1, count);
}
- [Test]
- public void SetDbType()
- {
- try
- {
- IDbCommand cmd = conn.CreateCommand();
- IDbDataParameter prm = cmd.CreateParameter();
- prm.DbType = DbType.Int64;
- Assert.AreEqual(DbType.Int64, prm.DbType);
- prm.Value = 3;
- Assert.AreEqual(DbType.Int64, prm.DbType);
+ [Test]
+ public void SetDbType()
+ {
+ try
+ {
+ IDbConnection conn2 = (IDbConnection)conn;
+ IDbCommand cmd = conn.CreateCommand();
+ IDbDataParameter prm = cmd.CreateParameter();
+ prm.DbType = DbType.Int64;
+ Assert.AreEqual(DbType.Int64, prm.DbType);
+ prm.Value = 3;
+ Assert.AreEqual(DbType.Int64, prm.DbType);
- MySqlParameter p = new MySqlParameter("name", MySqlDbType.Int64);
- Assert.AreEqual(DbType.Int64, p.DbType);
- Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType);
- p.Value = 3;
- Assert.AreEqual(DbType.Int64, p.DbType);
- Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType);
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- }
+ MySqlParameter p = new MySqlParameter("name", MySqlDbType.Int64);
+ Assert.AreEqual(DbType.Int64, p.DbType);
+ Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType);
+ p.Value = 3;
+ Assert.AreEqual(DbType.Int64, p.DbType);
+ Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ }
[Test]
public void UseOldSyntax()
@@ -243,7 +244,7 @@
}
}
- [Test()]
+ [Test]
[ExpectedException(typeof(ArgumentException))]
public void NullParameterObject()
{
Modified: branches/1.0/TestSuite/PoolingTests.cs
===================================================================
--- branches/1.0/TestSuite/PoolingTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/PoolingTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -33,7 +33,7 @@
{
public PoolingTests() : base()
{
- csAdditions = ";pooling=true";
+ csAdditions = ";pooling=true; connection reset=true";
}
[TestFixtureSetUp]
@@ -61,9 +61,9 @@
// first test that only a single connection get's used
for (int i=0; i < 10; i++)
{
- c = new MySqlConnection( connStr );
+ c = new MySqlConnection(connStr);
c.Open();
- Assert.AreEqual( serverThread, c.ServerThread );
+ Assert.AreEqual(serverThread, c.ServerThread);
c.Close();
}
@@ -75,7 +75,7 @@
MySqlConnection[] connArray = new MySqlConnection[10];
for (int i=0; i < connArray.Length; i++)
{
- connArray[i] = new MySqlConnection( connStr );
+ connArray[i] = new MySqlConnection(connStr);
connArray[i].Open();
}
@@ -85,7 +85,7 @@
for (int j=0; j < connArray.Length; j++)
{
if (i != j)
- Assert.IsTrue( connArray[i].ServerThread != connArray[j].ServerThread );
+ Assert.IsTrue(connArray[i].ServerThread != connArray[j].ServerThread);
}
}
@@ -132,15 +132,15 @@
string connStr = conn.ConnectionString + ";max pool size=1";
// now use up that connection
- MySqlConnection c = new MySqlConnection( connStr );
+ MySqlConnection c = new MySqlConnection(connStr);
c.Open();
// now attempting to open a connection should fail
try
{
- MySqlConnection c2 = new MySqlConnection( connStr );
+ MySqlConnection c2 = new MySqlConnection(connStr);
c2.Open();
- Assert.Fail( "Open after using up pool should fail" );
+ Assert.Fail("Open after using up pool should fail");
}
catch (Exception) { }
@@ -158,13 +158,13 @@
// Opening a connection now should work
try
{
- MySqlConnection c2 = new MySqlConnection( connStr );
+ MySqlConnection c2 = new MySqlConnection(connStr);
c2.Open();
c2.Close();
}
catch (Exception ex)
{
- Assert.Fail( ex.Message);
+ Assert.Fail(ex.Message);
}
}
@@ -174,53 +174,40 @@
execSQL("SET @testvar='5'");
MySqlCommand cmd = new MySqlCommand("SELECT @testvar", conn);
object var = cmd.ExecuteScalar();
- Assert.AreEqual("5", var );
+ Assert.AreEqual("5", var);
conn.Close();
conn.Open();
object var2 = cmd.ExecuteScalar();
- Assert.AreEqual( DBNull.Value, var2 );
+ Assert.AreEqual(DBNull.Value, var2);
}
- [Test]
- public void ExceedMaxAllowedPacket()
- {
- MySqlConnection c = null;
+ [Test]
+ public void ExceedMaxAllowedPacket()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (b1 LONGBLOB)");
- execSQL("set @@global.max_allowed_packet=1000000");
- execSQL("DROP TABLE IF EXISTS test");
- try
- {
- execSQL("CREATE TABLE test (b1 LONGBLOB)");
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand("select @@global.max_allowed_packet", conn);
+ object maxPacketSize = cmd.ExecuteScalar();
- 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)
- {
- 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();
- }
- }
+ byte[] buffer = new byte[(UInt64)maxPacketSize + 100];
+ cmd.CommandText = "INSERT INTO test vALUES (?b1)";
+ cmd.Parameters.Add("b1", buffer);
+ cmd.ExecuteNonQuery();
+ }
+ catch (MySqlException mex)
+ {
+ Assert.IsTrue(conn.State == ConnectionState.Open);
+ Assert.AreEqual((int)MySqlErrorCode.PacketTooLarge, mex.Number);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ }
+
}
}
Modified: branches/1.0/TestSuite/PreparedStatements.cs
===================================================================
--- branches/1.0/TestSuite/PreparedStatements.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/PreparedStatements.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -53,14 +53,14 @@
try
{
reader = cmd.ExecuteReader();
- Assert.IsTrue( reader.Read() );
- Assert.AreEqual( 1, reader.GetInt32(0) );
- Assert.AreEqual( 345.12, reader.GetDecimal(1) );
- Assert.AreEqual( "abcd", reader.GetString(2) );
+ Assert.IsTrue(reader.Read());
+ Assert.AreEqual(1, reader.GetInt32(0));
+ Assert.AreEqual(345.12, reader.GetDecimal(1));
+ Assert.AreEqual("abcd", reader.GetString(2));
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -559,6 +559,7 @@
[Category("4.1")]
public void ParameterLengths()
{
+ execSQL("DROP TABLE test");
execSQL("CREATE TABLE test (id int, name VARCHAR(255))");
MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (?id, ?name)", conn);
@@ -694,9 +695,9 @@
public void CompoundStatements()
{
execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE IF NOT EXISTS test (" +
- "id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT," +
- "test1 INT UNSIGNED, test2 INT UNSIGNED)");
+ execSQL("CREATE TABLE IF NOT EXISTS test ("+
+ "id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT," +
+ "test1 INT UNSIGNED, test2 INT UNSIGNED)");
try
{
@@ -716,7 +717,7 @@
#region Configs
- [Category("Compressed")]
+ [Category("Compressed")]
public class PreparedStatementsSocketCompressed : PreparedStatements
{
protected override string GetConnectionInfo()
@@ -725,7 +726,7 @@
}
}
- [Category("Pipe")]
+ [Category("Pipe")]
public class PreparedStatementsPipe : PreparedStatements
{
protected override string GetConnectionInfo()
@@ -734,8 +735,8 @@
}
}
- [Category("Compressed")]
- [Category("Pipe")]
+ [Category("Compressed")]
+ [Category("Pipe")]
public class PreparedStatementsPipeCompressed : PreparedStatements
{
protected override string GetConnectionInfo()
@@ -744,7 +745,7 @@
}
}
- [Category("SharedMemory")]
+ [Category("SharedMemory")]
public class PreparedStatementsSharedMemory : PreparedStatements
{
protected override string GetConnectionInfo()
@@ -753,8 +754,8 @@
}
}
- [Category("Compressed")]
- [Category("SharedMemory")]
+ [Category("Compressed")]
+ [Category("SharedMemory")]
public class PreparedStatementsSharedMemoryCompressed : PreparedStatements
{
protected override string GetConnectionInfo()
@@ -764,4 +765,5 @@
}
#endregion
+
}
Added: branches/1.0/TestSuite/SimpleTransactions.cs
===================================================================
--- branches/1.0/TestSuite/SimpleTransactions.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/SimpleTransactions.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -0,0 +1,108 @@
+// Copyright (C) 2004-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
+// 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.Data;
+using System.IO;
+using NUnit.Framework;
+#if NET20
+using System.Transactions;
+using System.Data.Common;
+#endif
+
+namespace MySql.Data.MySqlClient.Tests
+{
+ [TestFixture]
+ public class SimpleTransactions : BaseTest
+ {
+ [TestFixtureSetUp]
+ public void FixtureSetup()
+ {
+ Open();
+
+ execSQL("DROP TABLE IF EXISTS Test");
+ createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB");
+ }
+
+ [TestFixtureTearDown]
+ public void FixtureTeardown()
+ {
+ Close();
+ }
+
+ [Test]
+ public void TestReader()
+ {
+ execSQL("INSERT INTO Test VALUES('P', 'Test1', 'Test2')");
+
+ MySqlTransaction txn = conn.BeginTransaction();
+ MySqlConnection c = txn.Connection;
+ Assert.AreEqual( conn, c );
+ MySqlCommand cmd = new MySqlCommand("SELECT name, name2 FROM Test WHERE key2='P'",
+ conn, txn);
+ MySqlTransaction t2 = cmd.Transaction;
+ Assert.AreEqual( txn, t2 );
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ reader.Close();
+ txn.Commit();
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail( ex.Message );
+ txn.Rollback();
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ /// <summary>
+ /// Bug #22400 Nested transactions
+ /// </summary>
+ [Category("NotWorking")]
+ [Test]
+ public void NestedTransactions()
+ {
+ MySqlTransaction t1 = conn.BeginTransaction();
+ try
+ {
+ MySqlTransaction t2 = conn.BeginTransaction();
+ t2.Rollback();
+ Assert.Fail("Exception should have been thrown");
+ }
+ catch (NotSupportedException)
+ {
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ t1.Rollback();
+ }
+ }
+
+ }
+}
Modified: branches/1.0/TestSuite/StoredProcedure.cs
===================================================================
--- branches/1.0/TestSuite/StoredProcedure.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/StoredProcedure.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -17,6 +17,7 @@
// 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.Data;
using MySql.Data.MySqlClient;
@@ -31,7 +32,7 @@
/// Summary description for StoredProcedure.
/// </summary>
[Category("5.0")]
- [TestFixture]
+ [TestFixture]
public class StoredProcedure : BaseTest
{
private static string fillError = null;
@@ -41,7 +42,6 @@
{
csAdditions = ";pooling=false;procedure cache size=0";
Open();
- execSQL("DROP TABLE IF EXISTS Test; CREATE TABLE Test (id INT, name VARCHAR(100))");
}
[TestFixtureTearDown]
@@ -64,7 +64,7 @@
public void ReturningResultset()
{
// create our procedure
- execSQL( "CREATE PROCEDURE spTest(val decimal(10,3)) begin select val; end");
+ execSQL("CREATE PROCEDURE spTest(val decimal(10,3)) begin select val; end");
using (MySqlCommand cmd = new MySqlCommand("spTest", conn))
{
@@ -76,7 +76,7 @@
p.Value = 21;
decimal id = (decimal)cmd.ExecuteScalar();
- Assert.AreEqual( 21, id );
+ Assert.AreEqual(21, id);
}
}
@@ -122,12 +122,12 @@
public void OutputParameters()
{
// create our procedure
- execSQL( "DROP PROCEDURE IF EXISTS spCount" );
- execSQL( "CREATE PROCEDURE spCount(out value VARCHAR(50), OUT intVal INT, " +
+ execSQL("DROP PROCEDURE IF EXISTS spCount");
+ execSQL("CREATE PROCEDURE spCount(out value VARCHAR(50), OUT intVal INT, " +
"OUT dateVal TIMESTAMP, OUT floatVal FLOAT, OUT noTypeVarChar VARCHAR(20), " +
"OUT noTypeInt INT) " +
"BEGIN SET value='42'; SET intVal=33; SET dateVal='2004-06-05 07:58:09'; " +
- "SET floatVal = 1.2; SET noTypeVarChar='test'; SET noTypeInt=66; END" );
+ "SET floatVal = 1.2; SET noTypeVarChar='test'; SET noTypeInt=66; END");
MySqlCommand cmd = new MySqlCommand("spCount", conn);
cmd.CommandType = CommandType.StoredProcedure;
@@ -171,7 +171,7 @@
cmd.ExecuteNonQuery();
Assert.Fail("Should have thrown an exception");
}
- catch (MySqlException)
+ catch (Exception)
{
}
}
@@ -179,17 +179,18 @@
[Test]
public void WrongParameters()
{
- try
- {
- MySqlCommand cmd = new MySqlCommand("spTest", conn);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.Add( "?p2", 1 );
- cmd.ExecuteNonQuery();
- Assert.Fail("Should have thrown an exception");
- }
- catch (MySqlException)
- {
- }
+ execSQL("CREATE PROCEDURE spTest(p1 INT) BEGIN SELECT 1; END");
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand("spTest", conn);
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.Parameters.Add("?p2", 1);
+ cmd.ExecuteNonQuery();
+ Assert.Fail("Should have thrown an exception");
+ }
+ catch (Exception)
+ {
+ }
}
[Test]
@@ -276,24 +277,24 @@
Assert.IsTrue(result is Int32);
}
- [Test]
- public void ExecuteReader()
- {
- // create our procedure
- execSQL("CREATE PROCEDURE spTest(OUT p INT) " +
- "BEGIN SELECT * FROM mysql.db; SET p=2; END");
+ [Test]
+ public void ExecuteReader()
+ {
+ // create our procedure
+ execSQL( "CREATE PROCEDURE spTest(OUT p INT) " +
+ "BEGIN SELECT * FROM mysql.db; SET p=2; END" );
- MySqlCommand cmd = new MySqlCommand("spTest", conn);
+ MySqlCommand cmd = new MySqlCommand("spTest", conn);
cmd.Parameters.Add("?p", MySqlDbType.Int32);
cmd.Parameters[0].Direction = ParameterDirection.Output;
- cmd.CommandType = CommandType.StoredProcedure;
- MySqlDataReader reader = cmd.ExecuteReader();
- Assert.AreEqual(true, reader.Read());
- Assert.AreEqual(false, reader.NextResult());
- Assert.AreEqual(false, reader.Read());
- reader.Close();
+ cmd.CommandType = CommandType.StoredProcedure;
+ MySqlDataReader reader = cmd.ExecuteReader();
+ Assert.AreEqual(true, reader.Read());
+ Assert.AreEqual(false, reader.NextResult());
+ Assert.AreEqual(false, reader.Read());
+ reader.Close();
Assert.AreEqual(2, cmd.Parameters[0].Value);
- }
+ }
[Test]
public void MultipleResultsets()
@@ -401,11 +402,11 @@
/// Bug #9722 Connector does not recognize parameters separated by a linefeed
/// </summary>
[Test]
-= public void OtherProcSigs()
+ public void OtherProcSigs()
{
// create our procedure
- execSQL( "CREATE PROCEDURE spTest(IN \r\nvalin DECIMAL(10,2),\nIN val2 INT) " +
- "SQL SECURITY INVOKER BEGIN SELECT valin; END" );
+ execSQL("CREATE PROCEDURE spTest(IN \r\nvalin DECIMAL(10,2),\nIN val2 INT) " +
+ "SQL SECURITY INVOKER BEGIN SELECT valin; END");
MySqlCommand cmd = new MySqlCommand("spTest", conn);
cmd.CommandType = CommandType.StoredProcedure;
@@ -433,7 +434,7 @@
{
execSQL("CREATE FUNCTION fnTest(valin int) RETURNS INT BEGIN return valin * 2; END");
MySqlCommand cmd = new MySqlCommand("fnTest", conn);
- cmd.CommandType = CommandType.StoredProcedure;
+ cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("?valin", 22);
cmd.Parameters.Add("retval", MySqlDbType.Int32);
cmd.Parameters[1].Direction = ParameterDirection.ReturnValue;
@@ -488,7 +489,7 @@
public void TestSelectingInts()
{
execSQL("CREATE PROCEDURE spTest() BEGIN DECLARE myVar INT; " +
- "SET MyVar := 1; SELECT CAST(myVar as INT); END");
+ "SET MyVar := 1; SELECT CAST(myVar as SIGNED); END");
MySqlCommand cmd = new MySqlCommand("spTest", conn);
cmd.CommandType = CommandType.StoredProcedure;
@@ -677,10 +678,11 @@
/// Bug #13927 Multiple Records to same Table in Transaction Problem
/// </summary>
[Test]
- public void MultileRecords()
+ public void MultipleRecords()
{
execSQL("DROP PROCEDURE IF EXISTS spTest");
- execSQL("CREATE PROCEDURE spTest(id int, str VARCHAR(45)) BEGIN INSERT INTO test VALUES(id, str); END");
+ execSQL("CREATE PROCEDURE spTest(id int, str VARCHAR(45)) " +
+ "BEGIN INSERT INTO test VALUES(id, str); END");
MySqlCommand cmd = new MySqlCommand("spTest", conn);
cmd.CommandType = CommandType.StoredProcedure;
@@ -762,7 +764,14 @@
DataSet ds = new DataSet();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- da.Fill(ds);
+ try
+ {
+ da.Fill(ds);
+ }
+ catch (MySqlException)
+ {
+ // on 5.1 this throws an exception that no rows were returned.
+ }
}
[Test]
Modified: branches/1.0/TestSuite/StressTests.cs
===================================================================
--- branches/1.0/TestSuite/StressTests.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/StressTests.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -36,47 +36,46 @@
[TestFixtureSetUp]
public void FixtureSetup()
{
- Open();
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, name varchar(100), blob1 LONGBLOB, text1 TEXT, " +
- "PRIMARY KEY(id))");
- }
+ Open();
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, name varchar(100), blob1 LONGBLOB, text1 TEXT, " +
+ "PRIMARY KEY(id))");
+ }
[TestFixtureTearDown]
public void FixtureTearDown()
{
- Close();
- }
+ Close();
+ }
[Test]
public void TestMultiPacket()
{
- int len = 20000000;
+ int len = 20000000;
// currently do not test this with compression
if (conn.UseCompression) return;
execSQL("set @@global.max_allowed_packet=35000000");
- MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";pooling=false" );
+ MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";pooling=false");
c.Open();
- byte[] dataIn = Utils.CreateBlob( len );
- byte[] dataIn2 = Utils.CreateBlob( len );
+ byte[] dataIn = Utils.CreateBlob(len);
+ byte[] dataIn2 = Utils.CreateBlob(len);
MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )", c);
- cmd.Parameters.Add( new MySqlParameter("?id", 1));
- cmd.Parameters.Add( new MySqlParameter("?blob", dataIn));
+ cmd.Parameters.Add(new MySqlParameter("?id", 1));
+ cmd.Parameters.Add(new MySqlParameter("?blob", dataIn));
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
-
cmd.Parameters[0].Value = 2;
cmd.Parameters[1].Value = dataIn2;
cmd.ExecuteNonQuery();
@@ -90,22 +89,22 @@
reader = cmd.ExecuteReader();
reader.Read();
byte[] dataOut = new byte[ len ];
- long count = reader.GetBytes( 2, 0, dataOut, 0, len );
- Assert.AreEqual( len, count );
+ long count = reader.GetBytes(2, 0, dataOut, 0, len);
+ Assert.AreEqual(len, count);
for (int i=0; i < len; i++)
- Assert.AreEqual( dataIn[i], dataOut[i] );
+ Assert.AreEqual(dataIn[i], dataOut[i]);
reader.Read();
- count = reader.GetBytes( 2, 0, dataOut, 0, len );
- Assert.AreEqual( len, count );
+ count = reader.GetBytes(2, 0, dataOut, 0, len);
+ Assert.AreEqual(len, count);
for (int i=0; i < len; i++)
- Assert.AreEqual( dataIn2[i], dataOut[i] );
+ Assert.AreEqual(dataIn2[i], dataOut[i]);
}
catch (Exception ex)
{
- Assert.Fail( ex.Message );
+ Assert.Fail(ex.Message);
}
finally
{
@@ -175,8 +174,8 @@
}
}
- [Category("Compressed")]
- [Category("Pipe")]
+ [Category("Compressed")]
+ [Category("Pipe")]
public class StressTestsPipeCompressed : StressTests
{
protected override string GetConnectionInfo()
@@ -185,7 +184,7 @@
}
}
- [Category("SharedMemory")]
+ [Category("SharedMemory")]
public class StressTestsSharedMemory : StressTests
{
protected override string GetConnectionInfo()
@@ -194,8 +193,8 @@
}
}
- [Category("Compressed")]
- [Category("SharedMemory")]
+ [Category("Compressed")]
+ [Category("SharedMemory")]
public class StressTestsSharedMemoryCompressed : StressTests
{
protected override string GetConnectionInfo()
@@ -205,4 +204,5 @@
}
#endregion
+
}
Modified: branches/1.0/TestSuite/Syntax.cs
===================================================================
--- branches/1.0/TestSuite/Syntax.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/Syntax.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -1,383 +1,383 @@
-// Copyright (C) 2004-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
-// 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.Data;
-using System.IO;
-using NUnit.Framework;
-
-namespace MySql.Data.MySqlClient.Tests
-{
- [TestFixture]
- public class Syntax : BaseTest
- {
- [TestFixtureSetUp]
- public void FixtureSetup()
- {
- Open();
- }
-
- [TestFixtureTearDown]
- public void FixtureTeardown()
- {
- Close();
- }
-
- [SetUp]
- protected override void Setup()
- {
- base.Setup ();
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))");
- }
-
-
- [Test]
- public void ShowCreateTable()
- {
- MySqlDataAdapter da = new MySqlDataAdapter("SHOW CREATE TABLE test", conn);
- DataTable dt = new DataTable();
- da.Fill(dt);
-
- Assert.AreEqual( 1, dt.Rows.Count );
- Assert.AreEqual( 2, dt.Columns.Count );
- }
-
- [Test]
- [Category("4.1")]
- public void ProblemCharsInSQL()
- {
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), mt MEDIUMTEXT, PRIMARY KEY(id)) CHAR SET utf8");
-
- MySqlCommand cmd = new MySqlCommand( "INSERT INTO Test VALUES (?id, ?text, ?mt)", conn);
- cmd.Parameters.Add( "?id", 1 );
- cmd.Parameters.Add( "?text", "This is my;test ? string- cmd.Parameters.Add( "?mt", "My MT string: - cmd.ExecuteNonQuery();
-
- cmd.CommandText = "SELECT * FROM Test";
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- Assert.IsTrue( reader.Read() );
- Assert.AreEqual( 1, reader.GetInt32(0));
- if (Is40)
- Assert.AreEqual( "This is my;test ? string-'''\"\".", reader.GetString(1));
- else
- Assert.AreEqual( "This is my;test ? string- Assert.AreEqual( "My MT string: - }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- [Test]
- public void LoadDataLocalInfile()
- {
- execSQL("set @@global.max_allowed_packet=250000000");
-
- string connString = conn.ConnectionString + ";pooling=false";
- MySqlConnection c = new MySqlConnection( connString );
- c.Open();
-
- string path = Path.GetTempFileName();
- StreamWriter sw = new StreamWriter( path );
- for (int i=0; i < 2000000; i++)
- sw.WriteLine(i + ",'Test'");
- sw.Flush();
- sw.Close();
-
- path = path.Replace(@"\", @"\\");
- MySqlCommand cmd = new MySqlCommand("LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE Test FIELDS TERMINATED BY ','", c);
-
- object cnt = 0;
- try
- {
- cnt = cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- Assert.AreEqual( 2000000, cnt );
-
- cmd.CommandText = "SELECT COUNT(*) FROM Test";
- cnt = cmd.ExecuteScalar();
- Assert.AreEqual( 2000000, cnt );
-
- c.Close();
- execSQL("set @@global.max_allowed_packet=1047256");
- }
-
- [Test]
- public void ShowTablesInNonExistentDb()
- {
- MySqlCommand cmd = new MySqlCommand("SHOW TABLES FROM dummy", conn);
- MySqlDataReader reader =null;
- try
- {
- reader = cmd.ExecuteReader();
- Assert.Fail("ExecuteReader should not succeed");
- }
- catch (MySqlException)
- {
- Assert.AreEqual( ConnectionState.Open, conn.State );
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- [Test]
- public void Bug6135()
- {
- execSQL("DROP TABLE IF EXISTS KLANT");
- string sql = "CREATE TABLE `KLANT` (`KlantNummer` int(11) NOT NULL auto_increment, " +
- "`Username` varchar(50) NOT NULL default '', `Password` varchar(100) NOT NULL default '', " +
- "`Naam` varchar(100) NOT NULL default '', `Voornaam` varchar(100) NOT NULL default '', " +
- "`Straat` varchar(100) NOT NULL default '', `StraatNr` varchar(10) NOT NULL default '', " +
- "`Gemeente` varchar(100) NOT NULL default '', `Postcode` varchar(10) NOT NULL default '', " +
- "`DefaultMail` varchar(255) default '', `BtwNr` varchar(50) default '', " +
- "`ReceiveMail` tinyint(1) NOT NULL default '0', `Online` tinyint(1) NOT NULL default '0', " +
- "`LastVisit` timestamp(14) NOT NULL, `Categorie` int(11) NOT NULL default '0', " +
- "PRIMARY KEY (`KlantNummer`), UNIQUE KEY `UniqueUsername` (`Username`), " +
- "UNIQUE KEY `UniqueDefaultMail` (`DefaultMail`) )";
- createTable( sql, "MyISAM" );
-
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM KLANT", conn);
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- while (reader.Read()) { }
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- [Test]
- public void CharFunction()
- {
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id tinyint,val1 tinyint,val2 tinyint)");
- execSQL("INSERT INTO Test VALUES (65,1,1),(65,1,1)");
-
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT CHAR(id) FROM Test GROUP BY val1,val2", conn);
- DataTable dt = new DataTable();
- da.Fill(dt);
- Assert.AreEqual( "A", dt.Rows[0][0] );
- }
-
- [Test]
- public void Sum()
- {
- execSQL("DROP TABLE IF EXISTS test");
-
- execSQL("CREATE TABLE test (field1 mediumint(9) default '0', field2 float(9,3) " +
- "default '0.000', field3 double(15,3) default '0.000') engine=innodb ");
- execSQL("INSERT INTO test values (1,1,1)");
-
- MySqlDataReader reader = null;
-
- MySqlCommand cmd2 = new MySqlCommand("SELECT sum(field2) FROM test", conn);
- try
- {
- reader = cmd2.ExecuteReader();
- reader.Read();
- object o = reader[0];
- Assert.AreEqual(1, o);
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null) reader.Close();
- reader = null;
- }
-
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE Test (id int, count int)");
- execSQL("INSERT INTO Test VALUES (1, 21)");
- execSQL("INSERT INTO Test VALUES (1, 33)");
- execSQL("INSERT INTO Test VALUES (1, 16)");
- execSQL("INSERT INTO Test VALUES (1, 40)");
-
- MySqlCommand cmd = new MySqlCommand("SELECT id, SUM(count) FROM Test GROUP BY id", conn);
- try
- {
- reader = cmd.ExecuteReader();
- reader.Read();
- Assert.AreEqual( 1, reader.GetInt32(0) );
- Assert.AreEqual( 110, reader.GetDouble(1) );
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- finally
- {
- if (reader != null)
- reader.Close();
- }
- }
-
- [Category("4.1")]
- [Test]
- public void ForceWarnings()
- {
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM test; DROP TABLE IF EXISTS test2; SELECT * FROM test", conn);
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- while (reader.NextResult()) { }
- }
- catch( Exception ex)
- {
- Assert.Fail( ex.Message );
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- [Test]
- public void SettingAutoIncrementColumns()
- {
- execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id int auto_increment, name varchar(100), primary key(id))");
- execSQL("INSERT INTO Test VALUES (1, 'One')");
- execSQL("INSERT INTO Test VALUES (3, 'Two')");
-
- MySqlCommand cmd = new MySqlCommand("SELECT name FROM Test WHERE id=1", conn);
- object name = cmd.ExecuteScalar();
- Assert.AreEqual( "One", name );
-
- cmd.CommandText = "SELECT name FROM Test WHERE id=3";
- name = cmd.ExecuteScalar();
- Assert.AreEqual( "Two", name );
-
- try
- {
- execSQL("INSERT INTO Test (id, name2) values (5, 'Three')");
- Assert.Fail( "This should have failed" );
- }
- catch (MySqlException) {}
- catch (Exception ex) { Assert.Fail( ex.Message); }
- }
-
- /// <summary>
- /// Bug #16645 FOUND_ROWS() Bug
- /// </summary>
- [Test]
- public void FoundRows()
- {
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " +
- "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1");
- MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (NULL, 'test')", conn);
- for (int i=0; i < 1000; i++)
- cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT SQL_CALC_FOUND_ROWS * FROM test LIMIT 0, 10";
- cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT FOUND_ROWS()";
- object cnt = cmd.ExecuteScalar();
- Assert.AreEqual(1000, cnt);
- }
-
- [Test]
- public void AutoIncrement()
- {
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " +
- "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1");
- MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (NULL, 'test')", conn);
- cmd.ExecuteNonQuery();
- cmd.CommandText = "SELECT @@IDENTITY as 'Identity'";
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- reader.Read();
- int ident = Int32.Parse(reader.GetValue(0).ToString());
- Assert.AreEqual(1, ident);
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- if (reader != null)
- reader.Close();
- }
- }
-
- /// <summary>
- /// Bug #21521 # Symbols not allowed in column/table names.
- /// </summary>
- [Test]
- public void CommentSymbolInTableName()
- {
- try
- {
- execSQL("DROP TABLE IF EXISTS test");
- execSQL("CREATE TABLE test (`PO#` int(11) NOT NULL auto_increment, " +
- "`PODate` date default NULL, PRIMARY KEY (`PO#`))");
- execSQL("INSERT INTO test ( `PO#`, `PODate` ) " +
- "VALUES ( NULL, '2006-01-01' )");
-
- string sql = "SELECT `PO#` AS PurchaseOrderNumber, " +
- "`PODate` AS OrderDate FROM test";
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
- Assert.AreEqual(1, dt.Rows.Count);
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- }
- }
-}
+// Copyright (C) 2004-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
+// 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.Data;
+using System.IO;
+using NUnit.Framework;
+
+namespace MySql.Data.MySqlClient.Tests
+{
+ [TestFixture]
+ public class Syntax : BaseTest
+ {
+ [TestFixtureSetUp]
+ public void FixtureSetup()
+ {
+ Open();
+ }
+
+ [TestFixtureTearDown]
+ public void FixtureTeardown()
+ {
+ Close();
+ }
+
+ [SetUp]
+ protected override void Setup()
+ {
+ base.Setup ();
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))");
+ }
+
+
+ [Test]
+ public void ShowCreateTable()
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter("SHOW CREATE TABLE test", conn);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual(2, dt.Columns.Count);
+ }
+
+ [Test]
+ [Category("4.1")]
+ public void ProblemCharsInSQL()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), mt MEDIUMTEXT, PRIMARY KEY(id)) CHAR SET utf8");
+
+ MySqlCommand cmd = new MySqlCommand( "INSERT INTO Test VALUES (?id, ?text, ?mt)", conn);
+ cmd.Parameters.Add("?id", 1);
+ cmd.Parameters.Add("?text", "This is my;test ? string+ cmd.Parameters.Add("?mt", "My MT string: + cmd.ExecuteNonQuery();
+
+ cmd.CommandText = "SELECT * FROM Test";
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.IsTrue(reader.Read());
+ Assert.AreEqual(1, reader.GetInt32(0));
+ if (Is40)
+ Assert.AreEqual("This is my;test ? string-'''\"\".", reader.GetString(1));
+ else
+ Assert.AreEqual("This is my;test ? string+ Assert.AreEqual("My MT string: + }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ [Test]
+ public void LoadDataLocalInfile()
+ {
+ execSQL("set @@global.max_allowed_packet=250000000");
+
+ string connString = conn.ConnectionString + ";pooling=false";
+ MySqlConnection c = new MySqlConnection(connString);
+ c.Open();
+
+ string path = Path.GetTempFileName();
+ StreamWriter sw = new StreamWriter(path);
+ for (int i=0; i < 2000000; i++)
+ sw.WriteLine(i + ",'Test'");
+ sw.Flush();
+ sw.Close();
+
+ path = path.Replace(@"\", @"\\");
+ MySqlCommand cmd = new MySqlCommand("LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE Test FIELDS TERMINATED BY ','", c);
+
+ object cnt = 0;
+ try
+ {
+ cnt = cmd.ExecuteNonQuery();
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ Assert.AreEqual(2000000, cnt);
+
+ cmd.CommandText = "SELECT COUNT(*) FROM Test";
+ cnt = cmd.ExecuteScalar();
+ Assert.AreEqual(2000000, cnt);
+
+ c.Close();
+ execSQL("set @@global.max_allowed_packet=1047256");
+ }
+
+ [Test]
+ public void ShowTablesInNonExistentDb()
+ {
+ MySqlCommand cmd = new MySqlCommand("SHOW TABLES FROM dummy", conn);
+ MySqlDataReader reader =null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ Assert.Fail("ExecuteReader should not succeed");
+ }
+ catch (MySqlException)
+ {
+ Assert.AreEqual(ConnectionState.Open, conn.State);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ [Test]
+ public void Bug6135()
+ {
+ execSQL("DROP TABLE IF EXISTS KLANT");
+ string sql = "CREATE TABLE `KLANT` (`KlantNummer` int(11) NOT NULL auto_increment, " +
+ "`Username` varchar(50) NOT NULL default '', `Password` varchar(100) NOT NULL default '', " +
+ "`Naam` varchar(100) NOT NULL default '', `Voornaam` varchar(100) NOT NULL default '', " +
+ "`Straat` varchar(100) NOT NULL default '', `StraatNr` varchar(10) NOT NULL default '', " +
+ "`Gemeente` varchar(100) NOT NULL default '', `Postcode` varchar(10) NOT NULL default '', " +
+ "`DefaultMail` varchar(255) default '', `BtwNr` varchar(50) default '', " +
+ "`ReceiveMail` tinyint(1) NOT NULL default '0', `Online` tinyint(1) NOT NULL default '0', " +
+ "`LastVisit` timestamp(14) NOT NULL, `Categorie` int(11) NOT NULL default '0', " +
+ "PRIMARY KEY (`KlantNummer`), UNIQUE KEY `UniqueUsername` (`Username`), " +
+ "UNIQUE KEY `UniqueDefaultMail` (`DefaultMail`) )";
+ createTable(sql, "MyISAM");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM KLANT", conn);
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ while (reader.Read()) { }
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ [Test]
+ public void CharFunction()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id tinyint,val1 tinyint,val2 tinyint)");
+ execSQL("INSERT INTO Test VALUES (65,1,1),(65,1,1)");
+
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT CHAR(id) FROM Test GROUP BY val1,val2", conn);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ Assert.AreEqual( "A", dt.Rows[0][0] );
+ }
+
+ [Test]
+ public void Sum()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+
+ execSQL("CREATE TABLE test (field1 mediumint(9) default '0', field2 float(9,3) " +
+ "default '0.000', field3 double(15,3) default '0.000') engine=innodb ");
+ execSQL("INSERT INTO test values (1,1,1)");
+
+ MySqlDataReader reader = null;
+
+ MySqlCommand cmd2 = new MySqlCommand("SELECT sum(field2) FROM test", conn);
+ try
+ {
+ reader = cmd2.ExecuteReader();
+ reader.Read();
+ object o = reader[0];
+ Assert.AreEqual(1, o);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ reader = null;
+ }
+
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE Test (id int, count int)");
+ execSQL("INSERT INTO Test VALUES (1, 21)");
+ execSQL("INSERT INTO Test VALUES (1, 33)");
+ execSQL("INSERT INTO Test VALUES (1, 16)");
+ execSQL("INSERT INTO Test VALUES (1, 40)");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT id, SUM(count) FROM Test GROUP BY id", conn);
+ try
+ {
+ reader = cmd.ExecuteReader();
+ reader.Read();
+ Assert.AreEqual( 1, reader.GetInt32(0) );
+ Assert.AreEqual( 110, reader.GetDouble(1) );
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail( ex.Message );
+ }
+ finally
+ {
+ if (reader != null)
+ reader.Close();
+ }
+ }
+
+ [Category("4.1")]
+ [Test]
+ public void ForceWarnings()
+ {
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM test; DROP TABLE IF EXISTS test2; SELECT * FROM test", conn);
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ while (reader.NextResult()) { }
+ }
+ catch( Exception ex)
+ {
+ Assert.Fail( ex.Message );
+ }
+ finally
+ {
+ if (reader != null) reader.Close();
+ }
+ }
+
+ [Test]
+ public void SettingAutoIncrementColumns()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id int auto_increment, name varchar(100), primary key(id))");
+ execSQL("INSERT INTO Test VALUES (1, 'One')");
+ execSQL("INSERT INTO Test VALUES (3, 'Two')");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT name FROM Test WHERE id=1", conn);
+ object name = cmd.ExecuteScalar();
+ Assert.AreEqual( "One", name );
+
+ cmd.CommandText = "SELECT name FROM Test WHERE id=3";
+ name = cmd.ExecuteScalar();
+ Assert.AreEqual( "Two", name );
+
+ try
+ {
+ execSQL("INSERT INTO Test (id, name2) values (5, 'Three')");
+ Assert.Fail( "This should have failed" );
+ }
+ catch (MySqlException) {}
+ catch (Exception ex) { Assert.Fail( ex.Message); }
+ }
+
+ /// <summary>
+ /// Bug #16645 FOUND_ROWS() Bug
+ /// </summary>
+ [Test]
+ public void FoundRows()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " +
+ "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1");
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (NULL, 'test')", conn);
+ for (int i=0; i < 1000; i++)
+ cmd.ExecuteNonQuery();
+ cmd.CommandText = "SELECT SQL_CALC_FOUND_ROWS * FROM test LIMIT 0, 10";
+ cmd.ExecuteNonQuery();
+ cmd.CommandText = "SELECT FOUND_ROWS()";
+ object cnt = cmd.ExecuteScalar();
+ Assert.AreEqual(1000, cnt);
+ }
+
+ [Test]
+ public void AutoIncrement()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " +
+ "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1");
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (NULL, 'test')", conn);
+ cmd.ExecuteNonQuery();
+ cmd.CommandText = "SELECT @@IDENTITY as 'Identity'";
+ MySqlDataReader reader = null;
+ try
+ {
+ reader = cmd.ExecuteReader();
+ reader.Read();
+ int ident = Int32.Parse(reader.GetValue(0).ToString());
+ Assert.AreEqual(1, ident);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
+ if (reader != null)
+ reader.Close();
+ }
+ }
+
+ /// <summary>
+ /// Bug #21521 # Symbols not allowed in column/table names.
+ /// </summary>
+ [Test]
+ public void CommentSymbolInTableName()
+ {
+ try
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (`PO#` int(11) NOT NULL auto_increment, " +
+ "`PODate` date default NULL, PRIMARY KEY (`PO#`))");
+ execSQL("INSERT INTO test ( `PO#`, `PODate` ) " +
+ "VALUES ( NULL, '2006-01-01' )");
+
+ string sql = "SELECT `PO#` AS PurchaseOrderNumber, " +
+ "`PODate` AS OrderDate FROM test";
+ MySqlCommand cmd = new MySqlCommand(sql, conn);
+ MySqlDataAdapter da = new MySqlDataAdapter(cmd);
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ Assert.AreEqual(1, dt.Rows.Count);
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ }
+ }
+}
Modified: branches/1.0/TestSuite/Threading.cs
===================================================================
--- branches/1.0/TestSuite/Threading.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/Threading.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -25,16 +25,19 @@
using System.Threading;
using System.Collections;
using System.Diagnostics;
+using System.Text;
namespace MySql.Data.MySqlClient.Tests
{
class GenericListener : TraceListener
{
System.Collections.Specialized.StringCollection strings;
+ StringBuilder partial;
public GenericListener()
{
strings = new System.Collections.Specialized.StringCollection();
+ partial = new StringBuilder();
}
public int Find(string sToFind)
@@ -46,14 +49,22 @@
return count;
}
+ public void Clear()
+ {
+ partial.Remove(0, partial.Length);
+ strings.Clear();
+ }
+
public override void Write(string message)
{
- strings.Add(message);
+ partial.Append(message);
}
public override void WriteLine(string message)
{
- strings.Add(message);
+ Write(message);
+ strings.Add(partial.ToString());
+ partial.Remove(0, partial.Length);
}
}
Deleted: branches/1.0/TestSuite/Transactions.cs
===================================================================
--- branches/1.0/TestSuite/Transactions.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/TestSuite/Transactions.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -1,102 +0,0 @@
-// Copyright (C) 2004-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
-// 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.Data;
-using System.IO;
-using NUnit.Framework;
-
-namespace MySql.Data.MySqlClient.Tests
-{
- [TestFixture]
- public class Transactions : BaseTest
- {
- [TestFixtureSetUp]
- public void FixtureSetup()
- {
- Open();
-
- execSQL("DROP TABLE IF EXISTS Test");
- createTable( "CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB" );
- }
-
- [TestFixtureTearDown]
- public void FixtureTeardown()
- {
- Close();
- }
-
- [Test]
- public void TestReader()
- {
- execSQL("INSERT INTO Test VALUES('P', 'Test1', 'Test2')");
-
- MySqlTransaction txn = conn.BeginTransaction();
- MySqlConnection c = txn.Connection;
- Assert.AreEqual( conn, c );
- MySqlCommand cmd = new MySqlCommand("SELECT name, name2 FROM Test WHERE key2='P'",
- conn, txn);
- MySqlTransaction t2 = cmd.Transaction;
- Assert.AreEqual( txn, t2 );
- MySqlDataReader reader = null;
- try
- {
- reader = cmd.ExecuteReader();
- reader.Close();
- txn.Commit();
- }
- catch (Exception ex)
- {
- Assert.Fail( ex.Message );
- txn.Rollback();
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- /// <summary>
- /// Bug #22400 Nested transactions
- /// </summary>
- [Test]
- public void NestedTransactions()
- {
- MySqlTransaction t1 = conn.BeginTransaction();
- try
- {
- MySqlTransaction t2 = conn.BeginTransaction();
- t2.Rollback();
- Assert.Fail("Exception should have been thrown");
- }
- catch (NotSupportedException)
- {
- }
- catch (Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- t1.Rollback();
- }
- }
- }
-}
Modified: branches/1.0/mysqlclient/ConnectionString.cs
===================================================================
--- branches/1.0/mysqlclient/ConnectionString.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/mysqlclient/ConnectionString.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -220,13 +220,6 @@
get { return GetBool("reset_pooled_conn"); }
}
- [Category("Pooling")]
- [Description("Should connections pulled from connection pools use cached server configuration")]
- [DefaultValue(false)]
- public bool CacheServerConfig
- {
- get { return GetBool("cache_server_config"); }
- }
#endregion
@@ -270,27 +263,13 @@
/// <returns></returns>
public string GetConnectionString(bool includePass)
{
- if (connectString == null) return String.Empty;//CreateConnectionString();
+ if (connectString == null) return String.Empty;
string connStr = connectString;
if (! PersistSecurityInfo && !includePass)
connStr = RemovePassword(connStr);
return connStr;
-/*
- StringBuilder str = new StringBuilder();
- Hashtable ht = ParseKeyValuePairs( connectString );
-
- if (! PersistSecurityInfo)
- ht.Remove("password");
-
- foreach( string key in ht.Keys)
- str.AppendFormat("{0}={1};", key, ht[key]);
-
- if (str.Length > 0)
- str.Remove( str.Length-1, 1 );
-
- return str.ToString();*/
}
@@ -359,7 +338,6 @@
defaults["allowzerodatetime"] = false;
defaults["convertzerodatetime"] = false;
defaults["reset_pooled_conn"] = true;
- defaults["cache_server_config"] = false;
defaults["procedure cache size"] = 25;
}
return (Hashtable)defaults.Clone();
@@ -377,15 +355,7 @@
hash["procedure cache size"] = Int32.Parse(lowerCaseValue);
break;
- case "cache server configuration":
- case "cacheserverconfig":
- case "cacheserverconfiguration":
- hash["cache_server_config"] = boolVal;
- break;
-
- case "reset pooled connections":
- case "resetpooledconnections":
- case "reset connections":
+ case "connection reset":
hash["reset_pooled_conn"] = boolVal;
break;
Modified: branches/1.0/mysqlclient/Driver.cs
===================================================================
--- branches/1.0/mysqlclient/Driver.cs 2006-10-01 06:43:25 UTC (rev 387)
+++ branches/1.0/mysqlclient/Driver.cs 2006-10-01 06:48:18 UTC (rev 388)
@@ -148,7 +148,7 @@
// if we have already configured this driver and we are supposed
// to cache server config, then exit
- if (serverProps != null && connectionString.CacheServerConfig)
+ if (serverProps != null)
return;
// load server properties
| Thread |
|---|
| • Connector/NET commit: r388 - in branches/1.0: Installer TestSuite mysqlclient | rburnett | 1 Oct |