This commit is contained in:
MichaelGrafnetter 2016-02-20 18:55:56 +01:00
parent 47b5d4754d
commit 79fce88903
2 changed files with 26 additions and 5 deletions

View File

@ -8,6 +8,7 @@
using Microsoft.Database.Isam;
using DSInternals.Common;
using DSInternals.Common.Exceptions;
using Microsoft.Isam.Esent.Interop;
/// <summary>
/// The ActiveDirectorySchema class represents the schema partition for a particular domain.
@ -30,7 +31,7 @@
{
TableDefinition dataTable = database.Tables[ADConstants.DataTableName];
this.LoadColumnList(dataTable.Columns);
this.LoadAttributeIndices(dataTable.Indices);
this.LoadAttributeIndices(dataTable.Indices2);
using (var cursor = database.OpenCursor(ADConstants.DataTableName))
{
this.LoadClassList(cursor);
@ -128,15 +129,19 @@
}
}
private void LoadAttributeIndices(IndexCollection indices)
private void LoadAttributeIndices(IEnumerable<IndexInfo> indices)
{
foreach (IndexDefinition index in indices)
//HACK: We are using low-level IndexInfo instead of high-level IndexCollection.
/* There is a bug in Isam IndexCollection enumerator, which causes it to loop indefinitely
* through the first few indices under some very rare circumstances. */
foreach (var index in indices)
{
if (index.KeyColumns.Count == 1)
var segments = index.IndexSegments;
if (segments.Count == 1)
{
// We support only simple indexes
SchemaAttribute attr = FindAttributeByIndexName(index.Name);
if(attr != null)
if (attr != null)
{
// We found a single attribute to which this index corresponds
attr.Index = index.Name;

View File

@ -12,6 +12,7 @@
namespace Microsoft.Database.Isam
{
using Microsoft.Isam.Esent.Interop;
using System.Collections.Generic;
/// <summary>
/// A Table Definition contains the schema for a single table. It can be
@ -126,6 +127,21 @@ namespace Microsoft.Database.Isam
}
}
/// <summary>
/// Gets a collection containing the tables indices.
/// </summary>
public IEnumerable<IndexInfo> Indices2
{
//HACK: We added support to retrieve the low-level IndexInfo instead of high-level IndexCollection.
/* There is a bug in Isam IndexCollection enumerator, which causes it to loop indefinitely
* through the first few indices under some very rare circumstances. */
get
{
// TODO: Possibly add a lock for thread safety.
return Api.GetTableIndexes(this.IsamSession.Sesid, this.Database.Dbid, this.Name);
}
}
/// <summary>
/// Gets the session.
/// </summary>