Modified:
trunk/CHANGES
trunk/TestSuite/GetSchemaTests.cs
trunk/mysqlclient/ISSchemaProvider.cs
trunk/mysqlclient/MySql.Data.2005.csproj
trunk/mysqlclient/MySqlStream.cs
trunk/mysqlclient/SchemaProvider.cs
Log:
MySqlStream - Fixed problem in GetString where a zero length string was still calling
Read(..)
Schema - Committed patch from Dmitry that fixed some issues with the Indexes and
IndexColumns Collections
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/CHANGES 2006-08-18 20:44:19 UTC (rev 320)
@@ -7,6 +7,7 @@
Added overloaded methods in MySqlDataReader for getting a column value right from
column name
Replaced use of .NET 2.0 compression code with open source zlib library
Fixed compression
+ Fixed some problems with GetSchema and the Indexes and IndexColumns collections
Version 5.0.0.0 (Alpha)
Modified: trunk/TestSuite/GetSchemaTests.cs
===================================================================
--- trunk/TestSuite/GetSchemaTests.cs 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/TestSuite/GetSchemaTests.cs 2006-08-18 20:44:19 UTC (rev 320)
@@ -232,6 +232,69 @@
[Category("5.0")]
[Test]
+ public void Indexes()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))");
+ string[] restrictions = new string[4];
+ restrictions[2] = "test";
+ restrictions[1] = "test";
+ DataTable dt = conn.GetSchema("Indexes", restrictions);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+ Assert.AreEqual(true, dt.Rows[0]["PRIMARY"]);
+ Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]);
+
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int, name varchar(50), " +
+ "UNIQUE KEY key2 (name))");
+
+ dt = conn.GetSchema("Indexes", restrictions);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+ Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]);
+ Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
+ Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]);
+
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int, name varchar(50), " +
+ "KEY key2 (name))");
+
+ dt = conn.GetSchema("Indexes", restrictions);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+ Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]);
+ Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]);
+ Assert.AreEqual(false, dt.Rows[0]["UNIQUE"]);
+ }
+
+ [Test]
+ public void IndexColumns()
+ {
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))");
+ string[] restrictions = new string[5];
+ restrictions[2] = "test";
+ restrictions[1] = "test";
+ DataTable dt = conn.GetSchema("IndexColumns", restrictions);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+ Assert.AreEqual("id", dt.Rows[0]["COLUMN_NAME"]);
+
+ execSQL("DROP TABLE IF EXISTS test");
+ execSQL("CREATE TABLE test (id int, id1 int, id2 int, " +
+ "INDEX key1 (id1, id2))");
+ restrictions[2] = "test";
+ restrictions[1] = "test";
+ restrictions[4] = "id2";
+ dt = conn.GetSchema("IndexColumns", restrictions);
+ Assert.AreEqual(1, dt.Rows.Count);
+ Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]);
+ Assert.AreEqual("id2", dt.Rows[0]["COLUMN_NAME"]);
+ Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]);
+ }
+
+ [Test]
public void Views()
{
execSQL("DROP VIEW IF EXISTS vw");
Modified: trunk/mysqlclient/ISSchemaProvider.cs
===================================================================
--- trunk/mysqlclient/ISSchemaProvider.cs 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/mysqlclient/ISSchemaProvider.cs 2006-08-18 20:44:19 UTC (rev 320)
@@ -254,7 +254,7 @@
if (values != null)
for (int i = 0; i < keys.Length; i++)
{
- if (values.Length <= i) continue;
+ if (i >= values.Length) break;
if (values[i] == null || values[i] == String.Empty) continue;
if (where.Length > 0)
where.Append(" AND ");
Modified: trunk/mysqlclient/MySql.Data.2005.csproj
===================================================================
--- trunk/mysqlclient/MySql.Data.2005.csproj 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/mysqlclient/MySql.Data.2005.csproj 2006-08-18 20:44:19 UTC (rev 320)
@@ -69,6 +69,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="ICSharpCode.SharpZipLib, Version=0.81.0.1407, Culture=neutral,
PublicKeyToken=1b03e6acf1164f73">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\ICSharpCode.SharpZipLib.dll</HintPath>
+ </Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
@@ -82,6 +86,7 @@
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Transactions" />
+ <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
@@ -97,6 +102,7 @@
</Compile>
<Compile Include="CommandBuilder.cs">
</Compile>
+ <Compile Include="CommandMonitor.cs" />
<Compile Include="common\ContextString.cs" />
<Compile Include="common\NamedPipeStream.cs" />
<Compile Include="common\NativeMethods.cs" />
@@ -191,6 +197,7 @@
<Content Include="docs\MySqlParameter.xml" />
<Content Include="docs\MySqlParameterCollection.xml" />
<Content Include="docs\MySqlTransaction.xml" />
+ <Content Include="ReservedWords.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources.resx">
Modified: trunk/mysqlclient/MySqlStream.cs
===================================================================
--- trunk/mysqlclient/MySqlStream.cs 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/mysqlclient/MySqlStream.cs 2006-08-18 20:44:19 UTC (rev 320)
@@ -556,6 +556,8 @@
public string ReadString(long length)
{
+ if (length == 0)
+ return String.Empty;
byte[] buf = new byte[length];
Read(buf, 0, (int)length);
return encoding.GetString(buf, 0, buf.Length);
Modified: trunk/mysqlclient/SchemaProvider.cs
===================================================================
--- trunk/mysqlclient/SchemaProvider.cs 2006-08-14 19:08:10 UTC (rev 319)
+++ trunk/mysqlclient/SchemaProvider.cs 2006-08-18 20:44:19 UTC (rev 320)
@@ -270,14 +270,15 @@
DataTable tables = GetTables(restrictions);
foreach (DataRow table in tables.Rows)
{
- string sql = String.Format("SHOW INDEX FROM {0}.{1}",
table["TABLE_SCHEMA"],
- table["TABLE_NAME"]);
+ string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
+ table["TABLE_SCHEMA"], table["TABLE_NAME"]);
MySqlDataAdapter da = new MySqlDataAdapter(sql, connection);
DataTable indexes = new DataTable();
da.Fill(indexes);
foreach (DataRow index in indexes.Rows)
{
- if (!index["SEQ_IN_INDEX"].Equals(1)) continue;
+ long seq_index = (long)index["SEQ_IN_INDEX"];
+ if (seq_index != 1) continue;
if (restrictions != null && restrictions.Length == 4
&&
restrictions[3] != null &&
!index["KEY_NAME"].Equals(restrictions[3])) continue;
@@ -286,7 +287,7 @@
row["INDEX_SCHEMA"] = table["TABLE_SCHEMA"];
row["INDEX_NAME"] = index["KEY_NAME"];
row["TABLE_NAME"] = index["TABLE"];
- row["UNIQUE"] = index["NON_UNIQUE"].Equals(0);
+ row["UNIQUE"] = (long)index["NON_UNIQUE"] == 0;
row["PRIMARY"] = index["KEY_NAME"].Equals("PRIMARY");
dt.Rows.Add(row);
}
@@ -308,14 +309,13 @@
DataTable tables = GetTables(restrictions);
foreach (DataRow table in tables.Rows)
{
- string sql = String.Format("SHOW INDEX FROM {0}.{1}",
table["TABLE_SCHEMA"],
- table["TABLE_NAME"]);
+ string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
+ table["TABLE_SCHEMA"], table["TABLE_NAME"]);
MySqlDataAdapter da = new MySqlDataAdapter(sql, connection);
DataTable indexes = new DataTable();
da.Fill(indexes);
foreach (DataRow index in indexes.Rows)
{
- if (!index["SEQ_IN_INDEX"].Equals(1)) continue;
if (restrictions != null)
{
if (restrictions.Length == 4 && restrictions[3] != null
&&
| Thread |
|---|
| • Connector/NET commit: r320 - in trunk: . TestSuite mysqlclient | rburnett | 18 Aug |