public void VerifyJetSpaceHintsInequality() { var spacehints = new JET_SPACEHINTS[9]; for (int i = 0; i < spacehints.Length; ++i) { spacehints[i] = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; } int j = 1; spacehints[j++].ulInitialDensity = 35; spacehints[j++].cbInitial = 2048; spacehints[j++].grbit = SpaceHintsGrbit.DeleteHintTableSequential; spacehints[j++].ulMaintDensity = 79; spacehints[j++].ulGrowth = 288; spacehints[j++].cbMinExtent = 3 * 1024 * 1024; spacehints[j++].cbMaxExtent = 2 * 1024 * 1024; spacehints[j++] = new JET_SPACEHINTS(); Debug.Assert(j == spacehints.Length, "Didn't fill in all entries of spacehints"); VerifyAll(spacehints); }
public void JetCreateIndex2SpaceHints() { Api.JetBeginTransaction(this.sesid); const string IndexName = "another_index"; const string IndexDescription = "-TestColumn\0\0"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreate = new JET_INDEXCREATE { szIndexName = IndexName, szKey = IndexDescription, cbKey = IndexDescription.Length, grbit = CreateIndexGrbit.IndexIgnoreAnyNull, pSpaceHints = spacehintsIndex, }; Api.JetCreateIndex2(this.sesid, this.tableid, new[] { indexcreate }, 1); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetSetCurrentIndex(this.sesid, this.tableid, IndexName); }
public void TestArrayObjectContentEqualsNullMembers() { var x = new JET_SPACEHINTS[] { null, null }; var y = new JET_SPACEHINTS[] { null, null }; Assert.IsTrue(Util.ArrayObjectContentEquals(x, y, x.Length)); }
public void Setup() { this.managedSource = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; this.nativeTarget = this.managedSource.GetNativeSpaceHints(); this.nativeSource = new NATIVE_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = 0x12, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; this.managedTarget = new JET_SPACEHINTS(); this.managedTarget.SetFromNativeSpaceHints(this.nativeSource); }
public void VerifyJetSpaceHintsEquality() { var x = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var y = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; TestContentEquals(x, y); }
public void Setup() { this.managedSource = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; this.nativeTarget = this.managedSource.GetNativeSpaceHints(); this.nativeSource = new NATIVE_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = 0x12, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; this.managedTarget = new JET_SPACEHINTS(); this.managedTarget.SetFromNativeSpaceHints(this.nativeSource); }
/// <summary> /// Creates the table. /// </summary> /// <param name="tableName">Name of the table.</param> /// <returns>The newly created table.</returns> private JET_TABLECREATE CreateTable(string tableName) { const string ColumnKey1Name = "columnkey1"; string clustIndexKey = string.Format("+{0}\0\0", ColumnKey1Name); string secIndexWithPrimaryKey = string.Format("+{0}\0\0", ColumnKey1Name); JET_COLUMNCREATE[] columnCreates = { new JET_COLUMNCREATE { szColumnName = ColumnKey1Name, coltyp = VistaColtyp.GUID }, }; JET_SPACEHINTS spaceHint = new JET_SPACEHINTS { cbInitial = GuidDotNetSortOrderTest.PageSize * 50 }; JET_INDEXCREATE[] indexCreates = { new JET_INDEXCREATE { szIndexName = this.clustIndexName, szKey = clustIndexKey, cbKey = clustIndexKey.Length, grbit = CreateIndexGrbit.IndexPrimary | Windows8Grbits.IndexDotNetGuid, pSpaceHints = spaceHint }, new JET_INDEXCREATE { szIndexName = this.secIndexName, szKey = clustIndexKey, cbKey = clustIndexKey.Length, grbit = Windows8Grbits.IndexDotNetGuid, pSpaceHints = spaceHint } }; JET_TABLECREATE tc = new JET_TABLECREATE { szTableName = tableName, rgcolumncreate = columnCreates, cColumns = columnCreates.Length, rgindexcreate = indexCreates, cIndexes = indexCreates.Length, grbit = CreateTableColumnIndexGrbit.None, ulPages = 110 }; Api.JetCreateTableColumnIndex3(this.sesId, this.databaseId, tc); Assert.AreEqual <int>(4, tc.cCreated); // 1 table + 1 colummns + 2 indexes. Assert.AreNotEqual <JET_TABLEID>(JET_TABLEID.Nil, tc.tableid); this.columnIdKey1 = Api.GetTableColumnid(this.sesId, tc.tableid, ColumnKey1Name); Assert.AreNotEqual <JET_COLUMNID>(JET_COLUMNID.Nil, this.columnIdKey1); return(tc); }
public void VerifySpaceHintsCanBeSerialized() { var expected = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; SerializeAndCompareContent(expected); }
public void JetCreateIndex4SpaceHintsUnicodeIndex2() { if (!EsentVersion.SupportsWindows8Features) { return; } Api.JetBeginTransaction(this.sesid); const string IndexName = "another_index"; const string IndexDescription = "-TestColumn\0\0"; const string LocaleName = "en-US"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var unicode = new JET_UNICODEINDEX() { szLocaleName = LocaleName, dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None), }; var indexcreate = new JET_INDEXCREATE { szIndexName = IndexName, szKey = IndexDescription, cbKey = IndexDescription.Length, pidxUnicode = unicode, grbit = CreateIndexGrbit.IndexIgnoreAnyNull, pSpaceHints = spacehintsIndex, }; Windows8Api.JetCreateIndex4(this.sesid, this.tableid, new[] { indexcreate }, 1); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetSetCurrentIndex(this.sesid, this.tableid, IndexName); }
public void TestArrayObjectContentEqualsDiffer() { var a = new[] { new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, } }; var b = new[] { new JET_SPACEHINTS { ulInitialDensity = 34, cbInitial = 4096, } }; var c = new[] { new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4077, } }; var d = new JET_SPACEHINTS[] { null, }; JET_SPACEHINTS[][] values = new[] { a, b, c, d, null }; for (int i = 0; i < values.Length - 1; i++) { for (int j = i + 1; j < values.Length; j++) { Assert.IsFalse(Util.ArrayObjectContentEquals(values[i], values[j], 1)); } } }
public void VerifyJetTablecreateEquality() { var columncreatesX = new[] { new JET_COLUMNCREATE { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, }, new JET_COLUMNCREATE { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, }; const string Index1NameX = "firstIndex"; const string Index1DescriptionX = "+col1_short\0-col2_longtext\0"; const string Index2NameX = "secondIndex"; const string Index2DescriptionX = "+col2_longtext\0-col1_short\0"; var spacehintsIndexX = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeqX = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLvX = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreatesX = new[] { new JET_INDEXCREATE { szIndexName = Index1NameX, szKey = Index1DescriptionX, cbKey = Index1DescriptionX.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndexX, }, new JET_INDEXCREATE { szIndexName = Index2NameX, szKey = Index2DescriptionX, cbKey = Index2DescriptionX.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, }; JET_TABLEID tableidTemp = new JET_TABLEID() { Value = (IntPtr)2, }; var tablecreateX = new JET_TABLECREATE { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreatesX.Length, rgcolumncreate = columncreatesX, rgindexcreate = indexcreatesX, cIndexes = indexcreatesX.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.NoFixedVarColumnsInDerivedTables, pSeqSpacehints = spacehintsSeqX, pLVSpacehints = spacehintsLvX, tableid = tableidTemp, cCreated = 7, }; var columncreatesY = new[] { new JET_COLUMNCREATE { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, }, new JET_COLUMNCREATE { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, new JET_COLUMNCREATE { szColumnName = "col3_ignored", }, }; const string Index1NameY = "firstIndex"; const string Index1DescriptionY = "+col1_short\0-col2_longtext\0"; const string Index2NameY = "secondIndex"; const string Index2DescriptionY = "+col2_longtext\0-col1_short\0"; var spacehintsIndexY = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeqY = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLvY = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreatesY = new[] { new JET_INDEXCREATE { szIndexName = Index1NameY, szKey = Index1DescriptionY, cbKey = Index1DescriptionY.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndexY, }, new JET_INDEXCREATE { szIndexName = Index2NameY, szKey = Index2DescriptionY, cbKey = Index2DescriptionY.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, null, }; var tablecreateY = new JET_TABLECREATE() { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreatesX.Length, rgcolumncreate = columncreatesY, rgindexcreate = indexcreatesY, cIndexes = indexcreatesX.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.NoFixedVarColumnsInDerivedTables, pSeqSpacehints = spacehintsSeqY, pLVSpacehints = spacehintsLvY, tableid = tableidTemp, cCreated = 7, }; TestContentEquals(tablecreateX, tablecreateY); }
public void JetCreateTableColumnIndexSpaceHints() { var columncreates = new[] { new JET_COLUMNCREATE() { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, pvDefault = BitConverter.GetBytes((short)37), cbDefault = 2, }, new JET_COLUMNCREATE() { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, }; const string Index1Name = "firstIndex"; const string Index1Description = "+col1_short\0-col2_longtext\0"; const string Index2Name = "secondIndex"; const string Index2Description = "+col2_longtext\0-col1_short\0"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeq = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLv = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreates = new JET_INDEXCREATE[] { new JET_INDEXCREATE { szIndexName = Index1Name, szKey = Index1Description, cbKey = Index1Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndex, }, new JET_INDEXCREATE { szIndexName = Index2Name, szKey = Index2Description, cbKey = Index2Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, }; var tablecreate = new JET_TABLECREATE() { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreates.Length, rgcolumncreate = columncreates, rgindexcreate = indexcreates, cIndexes = indexcreates.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.None, pSeqSpacehints = spacehintsSeq, pLVSpacehints = spacehintsLv, }; Api.JetBeginTransaction(this.sesid); Api.JetCreateTableColumnIndex3(this.sesid, this.dbid, tablecreate); var tableCreated = new JET_TABLEID() { Value = tablecreate.tableid.Value }; Assert.AreNotEqual<JET_TABLEID>(JET_TABLEID.Nil, tableCreated); // 1 table, 2 columns, 2 indices = 5 objects. Assert.AreEqual<int>(tablecreate.cCreated, 5); Api.JetCloseTable(this.sesid, tableCreated); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); }
public void JetCreateIndex2SpaceHints() { Api.JetBeginTransaction(this.sesid); const string IndexName = "another_index"; const string IndexDescription = "-TestColumn\0\0"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreate = new JET_INDEXCREATE { szIndexName = IndexName, szKey = IndexDescription, cbKey = IndexDescription.Length, grbit = CreateIndexGrbit.IndexIgnoreAnyNull, pSpaceHints = spacehintsIndex, }; Api.JetCreateIndex2(this.sesid, this.tableid, new[] { indexcreate }, 1); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetSetCurrentIndex(this.sesid, this.tableid, IndexName); }
public void TestArrayObjectContentEqualsDiffer() { var a = new[] { new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, } }; var b = new[] { new JET_SPACEHINTS { ulInitialDensity = 34, cbInitial = 4096, } }; var c = new[] { new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4077, } }; var d = new JET_SPACEHINTS[] { null, }; JET_SPACEHINTS[][] values = new[] { a, b, c, d, null }; for (int i = 0; i < values.Length - 1; i++) { for (int j = i + 1; j < values.Length; j++) { Assert.IsFalse(Util.ArrayObjectContentEquals(values[i], values[j], 1)); } } }
public void JetCreateTableColumnIndexSpaceHints() { var columncreates = new[] { new JET_COLUMNCREATE() { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, pvDefault = BitConverter.GetBytes((short)37), cbDefault = 2, }, new JET_COLUMNCREATE() { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, }; const string Index1Name = "firstIndex"; const string Index1Description = "+col1_short\0-col2_longtext\0"; const string Index2Name = "secondIndex"; const string Index2Description = "+col2_longtext\0-col1_short\0"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeq = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLv = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreates = new JET_INDEXCREATE[] { new JET_INDEXCREATE { szIndexName = Index1Name, szKey = Index1Description, cbKey = Index1Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndex, }, new JET_INDEXCREATE { szIndexName = Index2Name, szKey = Index2Description, cbKey = Index2Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, }; var tablecreate = new JET_TABLECREATE() { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreates.Length, rgcolumncreate = columncreates, rgindexcreate = indexcreates, cIndexes = indexcreates.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.None, pSeqSpacehints = spacehintsSeq, pLVSpacehints = spacehintsLv, }; Api.JetBeginTransaction(this.sesid); Api.JetCreateTableColumnIndex3(this.sesid, this.dbid, tablecreate); var tableCreated = new JET_TABLEID() { Value = tablecreate.tableid.Value }; Assert.AreNotEqual <JET_TABLEID>(JET_TABLEID.Nil, tableCreated); // 1 table, 2 columns, 2 indices = 5 objects. Assert.AreEqual <int>(tablecreate.cCreated, 5); Api.JetCloseTable(this.sesid, tableCreated); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); }
private static void CompareIndexCreateWithOutput( JET_INDEXCREATE orig, JET_INDEXCREATE actual) { Assert.AreEqual(orig.szIndexName, actual.szIndexName); Assert.AreEqual(orig.cConditionalColumn, actual.cConditionalColumn); Assert.AreEqual(orig.cbKey, actual.cbKey); Assert.AreEqual(orig.szKey, actual.szKey); if (orig.cbKeyMost == 0) { Assert.AreEqual(255, actual.cbKeyMost); } else { Assert.AreEqual(orig.cbKeyMost, actual.cbKeyMost); } if (orig.cbVarSegMac == 0) { Assert.AreEqual(255, actual.cbVarSegMac); } else { Assert.AreEqual(orig.cbVarSegMac, actual.cbVarSegMac); } if (orig.ulDensity == 0) { Assert.AreEqual(100, actual.ulDensity); } else { Assert.AreEqual(orig.ulDensity, actual.ulDensity); } // Clear the bits that might get set: CreateIndexGrbit originalGrbit = orig.grbit; CreateIndexGrbit actualGrbit = actual.grbit & ~(CreateIndexGrbit.IndexUnique | VistaGrbits.IndexUnicode); if (originalGrbit.HasFlag(CreateIndexGrbit.IndexIgnoreAnyNull)) { originalGrbit &= ~(CreateIndexGrbit.IndexIgnoreAnyNull | CreateIndexGrbit.IndexIgnoreFirstNull | CreateIndexGrbit.IndexIgnoreNull); actualGrbit &= ~(CreateIndexGrbit.IndexIgnoreAnyNull | CreateIndexGrbit.IndexIgnoreFirstNull | CreateIndexGrbit.IndexIgnoreNull); } Assert.AreEqual(originalGrbit, actualGrbit); if (orig.pSpaceHints == null) { JET_SPACEHINTS defaultSpaceHints = new JET_SPACEHINTS() { ulInitialDensity = 100, // Or is it actual.ulDensity ? }; Assert.IsTrue(defaultSpaceHints.ContentEquals(actual.pSpaceHints)); } else { Assert.IsTrue(orig.pSpaceHints.ContentEquals(actual.pSpaceHints)); } if (orig.pidxUnicode == null) { JET_UNICODEINDEX defaultUnicodeIndex = new JET_UNICODEINDEX() { dwMapFlags = 0x30401, szLocaleName = "en-us", }; Assert.IsTrue(defaultUnicodeIndex.ContentEquals(actual.pidxUnicode)); } }
public void VerifyTableCreateCanBeSerialized() { var columncreates = new[] { new JET_COLUMNCREATE() { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, pvDefault = BitConverter.GetBytes((short)37), cbDefault = 2, }, new JET_COLUMNCREATE() { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, }; const string Index1Name = "firstIndex"; const string Index1Description = "+col1_short\0-col2_longtext\0"; const string Index2Name = "secondIndex"; const string Index2Description = "+col2_longtext\0-col1_short\0"; var spacehintsIndex = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeq = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLv = new JET_SPACEHINTS() { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreates = new JET_INDEXCREATE[] { new JET_INDEXCREATE { szIndexName = Index1Name, szKey = Index1Description, cbKey = Index1Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndex, }, new JET_INDEXCREATE { szIndexName = Index2Name, szKey = Index2Description, cbKey = Index2Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, }; var expected = new JET_TABLECREATE() { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreates.Length, rgcolumncreate = columncreates, rgindexcreate = indexcreates, cIndexes = indexcreates.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.None, pSeqSpacehints = spacehintsSeq, pLVSpacehints = spacehintsLv, }; SerializeAndCompareContent(expected); }
private void JetCreateTableColumnIndex() { Console.WriteLine("\tJetCreateTableColumnIndex()"); var columncreates = new JET_COLUMNCREATE[13]; for (int i = 0; i < columncreates.Length; ++i) { columncreates[i] = new JET_COLUMNCREATE(); } columncreates[0] = new JET_COLUMNCREATE { szColumnName = "recordID", coltyp = JET_coltyp.Long }; columncreates[1].szColumnName = "tagged"; columncreates[1].coltyp = VistaColtyp.LongLong; columncreates[1].grbit = ColumndefGrbit.ColumnTagged; columncreates[2].szColumnName = "separated_lv"; columncreates[2].coltyp = JET_coltyp.LongBinary; columncreates[3].szColumnName = "compressed_unicode"; columncreates[3].coltyp = JET_coltyp.LongText; columncreates[3].cp = JET_CP.Unicode; columncreates[3].grbit = Windows7Grbits.ColumnCompressed; columncreates[4].szColumnName = "compressed_ascii"; columncreates[4].coltyp = JET_coltyp.LongText; columncreates[4].cp = JET_CP.ASCII; columncreates[4].grbit = Windows7Grbits.ColumnCompressed; columncreates[5].szColumnName = "compressed_binary"; columncreates[5].coltyp = JET_coltyp.LongBinary; columncreates[5].grbit = Windows7Grbits.ColumnCompressed; columncreates[6].szColumnName = "columntodelete"; columncreates[6].coltyp = JET_coltyp.Long; columncreates[7].szColumnName = "autoinc"; columncreates[7].coltyp = JET_coltyp.Long; columncreates[7].grbit = ColumndefGrbit.ColumnAutoincrement; columncreates[8].szColumnName = "version"; columncreates[8].coltyp = JET_coltyp.Long; columncreates[8].grbit = ColumndefGrbit.ColumnVersion; columncreates[9].szColumnName = "unicode"; columncreates[9].coltyp = JET_coltyp.LongText; columncreates[9].cp = JET_CP.Unicode; columncreates[9].pvDefault = Encoding.Unicode.GetBytes( "This is the default value for the unicode column"); columncreates[9].cbDefault = columncreates[9].pvDefault.Length; columncreates[10].szColumnName = "ascii"; columncreates[10].coltyp = JET_coltyp.LongText; columncreates[10].cp = JET_CP.ASCII; columncreates[10].pvDefault = Encoding.ASCII.GetBytes("This is the default value for the ASCII column"); columncreates[10].cbDefault = columncreates[10].pvDefault.Length; columncreates[11].szColumnName = "columntodelete2"; columncreates[11].coltyp = JET_coltyp.Long; columncreates[12].szColumnName = "fixed"; columncreates[12].coltyp = VistaColtyp.LongLong; columncreates[12].grbit = ColumndefGrbit.ColumnFixed; var primarySpaceHints = new JET_SPACEHINTS(); primarySpaceHints.ulInitialDensity = 100; primarySpaceHints.cbInitial = 512 * 1024; var secondarySpaceHints = new JET_SPACEHINTS(); secondarySpaceHints.ulInitialDensity = 80; secondarySpaceHints.cbInitial = 96 * 1024; secondarySpaceHints.ulGrowth = 150; secondarySpaceHints.cbMinExtent = 64 * 1024; secondarySpaceHints.cbMaxExtent = 256 * 1024; var indexcreates = new JET_INDEXCREATE[14]; for (int i = 0; i < indexcreates.Length; ++i) { indexcreates[i] = new JET_INDEXCREATE(); } indexcreates[0].szIndexName = "index_recordID"; indexcreates[0].szKey = "+recordID\0\0"; indexcreates[0].cbKey = indexcreates[0].szKey.Length; indexcreates[0].grbit = CreateIndexGrbit.IndexPrimary; indexcreates[0].pSpaceHints = primarySpaceHints; indexcreates[1] = this.MakeIndexcreate("tagged"); indexcreates[2] = this.MakeIndexcreate("separated_lv"); indexcreates[3] = this.MakeIndexcreate("compressed_unicode"); indexcreates[4] = this.MakeIndexcreate("compressed_ascii"); indexcreates[5] = this.MakeIndexcreate("compressed_binary"); indexcreates[6] = this.MakeIndexcreate("autoinc"); indexcreates[7] = this.MakeIndexcreate("version"); indexcreates[8] = this.MakeIndexcreate("unicode"); indexcreates[9] = this.MakeIndexcreate("ascii"); indexcreates[10] = this.MakeIndexcreate("fixed"); indexcreates[11].szIndexName = "secondary"; indexcreates[11].szKey = "+autoinc\0+compressed_unicode\0+recordID\0\0"; indexcreates[11].cbKey = indexcreates[11].szKey.Length; indexcreates[11].grbit = CreateIndexGrbit.IndexUnique; indexcreates[11].pSpaceHints = secondarySpaceHints; indexcreates[12].szIndexName = "indextodelete"; indexcreates[12].szKey = "+autoinc\0+recordID\0\0"; indexcreates[12].cbKey = indexcreates[12].szKey.Length; indexcreates[13] = this.MakeIndexcreate("columntodelete2"); var tablecreate = new JET_TABLECREATE(); tablecreate.szTableName = this.table; tablecreate.ulPages = 1; tablecreate.ulDensity = 100; tablecreate.rgcolumncreate = columncreates; tablecreate.cColumns = tablecreate.rgcolumncreate.Length; tablecreate.rgindexcreate = indexcreates; tablecreate.cIndexes = tablecreate.rgindexcreate.Length; Api.JetBeginTransaction(this.sesid); Api.JetCreateTableColumnIndex3(this.sesid, this.dbid, tablecreate); Api.JetCloseTable(this.sesid, tablecreate.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); }
public void VerifyJetTablecreateInequality() { var columncreates = new[] { new JET_COLUMNCREATE { szColumnName = "col1_short", coltyp = JET_coltyp.Short, cbMax = 2, }, new JET_COLUMNCREATE { szColumnName = "col2_longtext", coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, }, }; const string Index1Name = "firstIndex"; const string Index1Description = "+col1_short\0-col2_longtext\0"; const string Index2Name = "secondIndex"; const string Index2Description = "+col2_longtext\0-col1_short\0"; var spacehintsIndex = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintHotpointSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsSeq = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanForward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var spacehintsLv = new JET_SPACEHINTS { ulInitialDensity = 33, cbInitial = 4096, grbit = SpaceHintsGrbit.CreateHintAppendSequential | SpaceHintsGrbit.RetrieveHintTableScanBackward, ulMaintDensity = 44, ulGrowth = 144, cbMinExtent = 1024 * 1024, cbMaxExtent = 3 * 1024 * 1024, }; var indexcreates = new[] { new JET_INDEXCREATE { szIndexName = Index1Name, szKey = Index1Description, cbKey = Index1Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 99, pSpaceHints = spacehintsIndex, }, null, new JET_INDEXCREATE { szIndexName = Index2Name, szKey = Index2Description, cbKey = Index2Description.Length + 1, grbit = CreateIndexGrbit.None, ulDensity = 79, }, }; JET_TABLEID tableidTemp = new JET_TABLEID() { Value = (IntPtr)2, }; var tablecreates = new JET_TABLECREATE[21]; for (int i = 0; i < tablecreates.Length; ++i) { tablecreates[i] = new JET_TABLECREATE { szTableName = "tableBigBang", ulPages = 23, ulDensity = 75, cColumns = columncreates.Length, rgcolumncreate = columncreates, rgindexcreate = indexcreates, cIndexes = indexcreates.Length, cbSeparateLV = 100, cbtyp = JET_cbtyp.Null, grbit = CreateTableColumnIndexGrbit.NoFixedVarColumnsInDerivedTables, pSeqSpacehints = spacehintsSeq, pLVSpacehints = spacehintsLv, tableid = tableidTemp, cCreated = 7, }; } int j = 1; tablecreates[j++].szTableName = "different"; tablecreates[j++].ulPages = 57; tablecreates[j++].ulDensity = 98; tablecreates[j++].cColumns = 1; tablecreates[j++].rgcolumncreate = new[] { null, columncreates[0], }; tablecreates[j].rgcolumncreate = null; tablecreates[j++].cColumns = 0; tablecreates[j++].cIndexes--; tablecreates[j++].cbSeparateLV = 24; tablecreates[j++].rgindexcreate = new[] { indexcreates[1], indexcreates[0], indexcreates[0], }; tablecreates[j++].rgindexcreate = new[] { indexcreates[1], null, indexcreates[0], }; tablecreates[j].rgindexcreate = null; tablecreates[j++].cIndexes = 0; tablecreates[j++].cbtyp = JET_cbtyp.AfterInsert; tablecreates[j++].grbit = CreateTableColumnIndexGrbit.FixedDDL; tablecreates[j++].pSeqSpacehints = spacehintsLv; tablecreates[j++].pSeqSpacehints = null; tablecreates[j++].pLVSpacehints = spacehintsSeq; tablecreates[j++].pLVSpacehints = null; tableidTemp.Value = new IntPtr(63); tablecreates[j++].tableid = tableidTemp; tablecreates[j++].cCreated--; tablecreates[j++] = new JET_TABLECREATE(); Debug.Assert(j == tablecreates.Length, "Didn't fill in all entries of tablecreates"); VerifyAll(tablecreates); }
public void TestArrayObjectContentEqualsNullMembers() { var x = new JET_SPACEHINTS[] { null, null }; var y = new JET_SPACEHINTS[] { null, null }; Assert.IsTrue(Util.ArrayObjectContentEquals(x, y, x.Length)); }
private void JetCreateTableColumnIndex() { Console.WriteLine("\tJetCreateTableColumnIndex()"); var columncreates = new JET_COLUMNCREATE[13]; for (int i = 0; i < columncreates.Length; ++i) { columncreates[i] = new JET_COLUMNCREATE(); } columncreates[0] = new JET_COLUMNCREATE { szColumnName = "recordID", coltyp = JET_coltyp.Long }; columncreates[1].szColumnName = "tagged"; columncreates[1].coltyp = VistaColtyp.LongLong; columncreates[1].grbit = ColumndefGrbit.ColumnTagged; columncreates[2].szColumnName = "separated_lv"; columncreates[2].coltyp = JET_coltyp.LongBinary; columncreates[3].szColumnName = "compressed_unicode"; columncreates[3].coltyp = JET_coltyp.LongText; columncreates[3].cp = JET_CP.Unicode; columncreates[3].grbit = Windows7Grbits.ColumnCompressed; columncreates[4].szColumnName = "compressed_ascii"; columncreates[4].coltyp = JET_coltyp.LongText; columncreates[4].cp = JET_CP.ASCII; columncreates[4].grbit = Windows7Grbits.ColumnCompressed; columncreates[5].szColumnName = "compressed_binary"; columncreates[5].coltyp = JET_coltyp.LongBinary; columncreates[5].grbit = Windows7Grbits.ColumnCompressed; columncreates[6].szColumnName = "columntodelete"; columncreates[6].coltyp = JET_coltyp.Long; columncreates[7].szColumnName = "autoinc"; columncreates[7].coltyp = JET_coltyp.Long; columncreates[7].grbit = ColumndefGrbit.ColumnAutoincrement; columncreates[8].szColumnName = "version"; columncreates[8].coltyp = JET_coltyp.Long; columncreates[8].grbit = ColumndefGrbit.ColumnVersion; columncreates[9].szColumnName = "unicode"; columncreates[9].coltyp = JET_coltyp.LongText; columncreates[9].cp = JET_CP.Unicode; columncreates[9].pvDefault = Encoding.Unicode.GetBytes( "This is the default value for the unicode column"); columncreates[9].cbDefault = columncreates[9].pvDefault.Length; columncreates[10].szColumnName = "ascii"; columncreates[10].coltyp = JET_coltyp.LongText; columncreates[10].cp = JET_CP.ASCII; columncreates[10].pvDefault = Encoding.ASCII.GetBytes("This is the default value for the ASCII column"); columncreates[10].cbDefault = columncreates[10].pvDefault.Length; columncreates[11].szColumnName = "columntodelete2"; columncreates[11].coltyp = JET_coltyp.Long; columncreates[12].szColumnName = "fixed"; columncreates[12].coltyp = VistaColtyp.LongLong; columncreates[12].grbit = ColumndefGrbit.ColumnFixed; var primarySpaceHints = new JET_SPACEHINTS(); primarySpaceHints.ulInitialDensity = 100; primarySpaceHints.cbInitial = 512 * 1024; var secondarySpaceHints = new JET_SPACEHINTS(); secondarySpaceHints.ulInitialDensity = 80; secondarySpaceHints.cbInitial = 96 * 1024; secondarySpaceHints.ulGrowth = 150; secondarySpaceHints.cbMinExtent = 64 * 1024; secondarySpaceHints.cbMaxExtent = 256 * 1024; var indexcreates = new JET_INDEXCREATE[14]; for (int i = 0; i < indexcreates.Length; ++i) { indexcreates[i] = new JET_INDEXCREATE(); } indexcreates[0].szIndexName = "index_recordID"; indexcreates[0].szKey = "+recordID\0\0"; indexcreates[0].cbKey = indexcreates[0].szKey.Length; indexcreates[0].grbit = CreateIndexGrbit.IndexPrimary; indexcreates[0].pSpaceHints = primarySpaceHints; indexcreates[1] = this.MakeIndexcreate("tagged"); indexcreates[2] = this.MakeIndexcreate("separated_lv"); indexcreates[3] = this.MakeIndexcreate("compressed_unicode"); indexcreates[4] = this.MakeIndexcreate("compressed_ascii"); indexcreates[5] = this.MakeIndexcreate("compressed_binary"); indexcreates[6] = this.MakeIndexcreate("autoinc"); indexcreates[7] = this.MakeIndexcreate("version"); indexcreates[8] = this.MakeIndexcreate("unicode"); indexcreates[9] = this.MakeIndexcreate("ascii"); indexcreates[10] = this.MakeIndexcreate("fixed"); indexcreates[11].szIndexName = "secondary"; indexcreates[11].szKey = "+autoinc\0+compressed_unicode\0+recordID\0\0"; indexcreates[11].cbKey = indexcreates[11].szKey.Length; indexcreates[11].grbit = CreateIndexGrbit.IndexUnique; indexcreates[11].pSpaceHints = secondarySpaceHints; indexcreates[12].szIndexName = "indextodelete"; indexcreates[12].szKey = "+autoinc\0+recordID\0\0"; indexcreates[12].cbKey = indexcreates[12].szKey.Length; indexcreates[13] = this.MakeIndexcreate("columntodelete2"); var tablecreate = new JET_TABLECREATE(); tablecreate.szTableName = this.table; tablecreate.ulPages = 1; tablecreate.ulDensity = 100; tablecreate.rgcolumncreate = columncreates; tablecreate.cColumns = tablecreate.rgcolumncreate.Length; tablecreate.rgindexcreate = indexcreates; tablecreate.cIndexes = tablecreate.rgindexcreate.Length; Api.JetBeginTransaction(this.sesid); Api.JetCreateTableColumnIndex3(this.sesid, this.dbid, tablecreate); Api.JetCloseTable(this.sesid, tablecreate.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); }