public static CreateNewInstance ( string myDir ) : JET_INSTANCE | ||
myDir | string | The directory to use. |
Результат | JET_INSTANCE |
public void CreateDatabaseAndOpenReadOnly() { string dir = SetupHelper.CreateRandomDirectory(); JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetInit(ref instance); try { string database = Path.Combine(dir, "test.db"); JET_SESID sesid; JET_DBID dbid; Api.JetBeginSession(instance, out sesid, String.Empty, String.Empty); Api.JetCreateDatabase(sesid, database, String.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(sesid, database); Api.JetAttachDatabase(sesid, database, AttachDatabaseGrbit.ReadOnly); Api.JetOpenDatabase(sesid, database, String.Empty, out dbid, OpenDatabaseGrbit.ReadOnly); Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(sesid, database); } finally { Api.JetTerm(instance); Directory.Delete(dir, true); } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.PageTempDBMin, SystemParameters.PageTempDBSmallest, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { cp = JET_CP.Unicode, coltyp = JET_coltyp.LongText, }; Api.JetAddColumn(this.sesid, this.tableid, "TestColumn", columndef, null, 0, out this.columnidLongText); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void JetSetDatabaseSizeThrowsExceptionWhenDesiredPagesIsNegative() { string dir = SetupHelper.CreateRandomDirectory(); JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance); string database = Path.Combine(dir, "test.db"); JET_SESID sesid; JET_DBID dbid; Api.JetBeginSession(instance, out sesid, string.Empty, string.Empty); try { Api.JetCreateDatabase(sesid, database, string.Empty, out dbid, CreateDatabaseGrbit.None); int actualPages; Api.JetSetDatabaseSize(sesid, database, -1, out actualPages); } finally { Api.JetTerm(instance); Cleanup.DeleteDirectoryWithRetry(dir); } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public void Setup() { var random = new Random(); this.numRecords = random.Next(5, 20); this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); var columns = new[] { new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.TTKey } }; var columnids = new JET_COLUMNID[columns.Length]; // BUG: use TempTableGrbit.Indexed once in-memory TT bugs are fixed Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.ForceMaterialization, out this.tableid, columnids); this.columnidLong = columnids[0]; for (int i = 0; i < this.numRecords; ++i) { Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert); Api.JetSetColumn(this.sesid, this.tableid, this.columnidLong, BitConverter.GetBytes(i), 4, SetColumnGrbit.None, null); int ignored; Api.JetUpdate(this.sesid, this.tableid, null, 0, out ignored); } }
public void CreateAndGrowDatabase() { string dir = SetupHelper.CreateRandomDirectory(); JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance); try { string database = Path.Combine(dir, "test.db"); JET_SESID sesid; JET_DBID dbid; Api.JetBeginSession(instance, out sesid, String.Empty, String.Empty); Api.JetCreateDatabase(sesid, database, String.Empty, out dbid, CreateDatabaseGrbit.None); // BUG: ESENT requires that JetGrowDatabase be in a transaction (Win7 and below) Api.JetBeginTransaction(sesid); int actualPages; Api.JetGrowDatabase(sesid, dbid, 512, out actualPages); Api.JetCommitTransaction(sesid, CommitTransactionGrbit.None); Assert.IsTrue(actualPages >= 512, "Database didn't grow"); } finally { Api.JetTerm(instance); Cleanup.DeleteDirectoryWithRetry(dir); } }
public void TestSetup() { if (!EsentVersion.SupportsWindows8Features) { return; } this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.instance = SetupHelper.CreateNewInstance(this.directory); //// Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, UnpublishedParam.EnablePeriodicShrinkDatabase, 0, null); this.callback = new DurableCommitCallback(this.instance, this.TestCallback); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetCreateDatabase(this.sesid, this.database, string.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(this.sesid, this.dbid, CloseDatabaseGrbit.None); Api.JetOpenDatabase(this.sesid, this.database, null, out this.dbid, OpenDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); JET_TABLECREATE tc = this.CreateTable(this.tableName); Api.JetCloseTable(this.sesid, tc.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.None); Api.JetOpenTable(this.sesid, this.dbid, this.tableName, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnEscrowUpdate, }; Api.JetAddColumn(this.sesid, this.tableid, "EscrowColumn", columndef, BitConverter.GetBytes(0), 4, out this.columnid); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); Api.JetBeginTransaction(this.sesid); Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert); Api.JetUpdate(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetMove(this.sesid, this.tableid, JET_Move.First, MoveGrbit.None); }
public void CreateAndOpenDatabase() { string dir = SetupHelper.CreateRandomDirectory(); JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref instance); try { string database = Path.Combine(dir, "test.db"); JET_SESID sesid; JET_DBID dbid; Api.JetBeginSession(instance, out sesid, String.Empty, String.Empty); Api.JetCreateDatabase(sesid, database, String.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(sesid, database); Api.JetAttachDatabase(sesid, database, AttachDatabaseGrbit.None); Api.JetOpenDatabase(sesid, database, String.Empty, out dbid, OpenDatabaseGrbit.None); Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(sesid, database); } finally { Api.JetTerm(instance); Cleanup.DeleteDirectoryWithRetry(dir); } }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetCreateDatabase(this.sesid, this.database, string.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); JET_COLUMNID ignored; var columndef = new JET_COLUMNDEF { coltyp = JET_coltyp.Text, cp = JET_CP.Unicode }; Api.JetAddColumn(this.sesid, this.tableid, "C1", columndef, null, 0, out ignored); Api.JetAddColumn(this.sesid, this.tableid, "C2", columndef, null, 0, out ignored); Api.JetAddColumn(this.sesid, this.tableid, "C3", columndef, null, 0, out ignored); Api.JetCreateIndex(this.sesid, this.tableid, "Primary", CreateIndexGrbit.IndexPrimary, "+C1\0\0", 5, 100); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); JET_INDEXCREATE[] indexcreates = new[] { new JET_INDEXCREATE { szIndexName = "Index2", cbKey = 5, szKey = "+C2\0\0" }, new JET_INDEXCREATE { szIndexName = "Index3", cbKey = 5, szKey = "+C3\0\0", cbVarSegMac = 100 }, }; Api.JetCreateIndex2(this.sesid, this.tableid, indexcreates, indexcreates.Length); if (EsentVersion.SupportsWindows8Features) { var unicode = new JET_UNICODEINDEX() { szLocaleName = "pt-br", dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None), }; var indexcreate = new JET_INDEXCREATE { szIndexName = "win8BrazilIndex", szKey = "+C2\0\0", cbKey = 5, pidxUnicode = unicode, grbit = CreateIndexGrbit.IndexIgnoreAnyNull, ulDensity = 100, }; Windows8Api.JetCreateIndex4(this.sesid, this.tableid, new[] { indexcreate }, 1); } Api.JetCloseTable(this.sesid, this.tableid); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void CreateResizeAndTrimDatabase() { if (!EsentVersion.SupportsWindows81Features) { return; } string dir = SetupHelper.CreateRandomDirectory(); JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); InstanceParameters instanceParameters = new InstanceParameters(instance); instanceParameters.EnableShrinkDatabase = ShrinkDatabaseGrbit.On; Api.JetInit(ref instance); try { string database = Path.Combine(dir, "CreateAndResizeDatabase.db"); JET_SESID sesid; JET_DBID dbid; Api.JetBeginSession(instance, out sesid, string.Empty, string.Empty); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.DbExtensionSize, 256, null); Api.JetCreateDatabase(sesid, database, string.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.DbExtensionSize, 1, null); int databaseSpaceOwned; Api.JetGetDatabaseInfo(sesid, dbid, out databaseSpaceOwned, JET_DbInfo.SpaceOwned); // We have to take into account the reserved pages in the database as per the API to get the actual // space. databaseSpaceOwned += ReservedPages; int actualPages; Windows8Api.JetResizeDatabase(sesid, dbid, databaseSpaceOwned + 100, out actualPages, ResizeDatabaseGrbit.None); EseInteropTestHelper.ConsoleWriteLine("actualPages is {0}.", actualPages); Assert.IsTrue(actualPages >= databaseSpaceOwned + 100, "Database didn't grow enough!"); int actualPagesAfterTrim = 0; Windows8Api.JetResizeDatabase(sesid, dbid, 0, out actualPagesAfterTrim, ResizeDatabaseGrbit.None); EseInteropTestHelper.ConsoleWriteLine("actualPagesAfterTrim is {0}.", actualPagesAfterTrim); Assert.IsTrue(actualPagesAfterTrim < actualPages, "Database didn't shrink!"); int databaseSizeOnDiskInPages; Api.JetGetDatabaseInfo(sesid, dbid, out databaseSizeOnDiskInPages, Windows81DbInfo.FilesizeOnDisk); EseInteropTestHelper.ConsoleWriteLine("databaseSizeOnDiskInPages is {0}.", databaseSizeOnDiskInPages); Assert.AreEqual(actualPagesAfterTrim, databaseSizeOnDiskInPages); } finally { Api.JetTerm(instance); Cleanup.DeleteDirectoryWithRetry(dir); } }
public void Setup() { // we just need a session so don't do any logging or create a database this.instance = SetupHelper.CreateNewInstance("."); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public void InitAndTermOneInstanceAbruptly() { JET_INSTANCE instance = SetupHelper.CreateNewInstance("instance"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance); Api.JetTerm2(instance, TermGrbit.Abrupt); }
public void Setup() { this.instance = SetupHelper.CreateNewInstance("."); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); this.tableid = JET_TABLEID.Nil; }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); }
/// <summary> /// Resets the cache for the database. /// </summary> private void ResetCache() { Api.JetCloseTable(this.sesid, this.tableid); Api.JetEndSession(this.sesid, EndSessionGrbit.None); Api.JetTerm(this.instance); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetAttachDatabase(this.sesid, this.database, AttachDatabaseGrbit.None); Api.JetOpenDatabase(this.sesid, this.database, null, out this.dbid, OpenDatabaseGrbit.None); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.PageTempDBMin, SystemParameters.PageTempDBSmallest, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); this.columnidDict = SetupHelper.CreateTempTableWithAllColumns(this.sesid, TempTableGrbit.None, out this.tableid); }
public void InitAndTermOneInstanceAbruptly() { string dir = SetupHelper.CreateRandomDirectory(); try { JET_INSTANCE instance = SetupHelper.CreateNewInstance(dir); Api.JetInit(ref instance); Api.JetTerm2(instance, TermGrbit.Abrupt); } finally { Directory.Delete(dir, true); } }
public void InitAndTermTwoInstances() { JET_INSTANCE instance1 = SetupHelper.CreateNewInstance("instance1"); Api.JetSetSystemParameter(instance1, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(instance1, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); JET_INSTANCE instance2 = SetupHelper.CreateNewInstance("instance2"); Api.JetSetSystemParameter(instance2, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(instance2, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance1); Api.JetInit(ref instance2); Api.JetTerm(instance1); Api.JetTerm(instance2); }
public void CreateUsingInitializedInstance() { string directory = SetupHelper.CreateRandomDirectory(); string db = Path.Combine(directory, DatabaseObjectTests.DbName); JET_INSTANCE instance; JET_SESID sesid; JET_DBID dbid; instance = SetupHelper.CreateNewInstance(directory); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref instance); Api.JetBeginSession(instance, out sesid, string.Empty, string.Empty); Api.JetCreateDatabase(sesid, db, string.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None); Api.JetEndSession(sesid, EndSessionGrbit.None); var engineConfig = new DatabaseConfig() { DatabaseFilename = db, }; using (this.database = new Database(instance, false, engineConfig)) { Assert.AreNotEqual(this.database.InstanceHandle, JET_INSTANCE.Nil); Assert.AreEqual(this.database.Config.Recovery, "off"); } using (this.database = new Database(instance, true, engineConfig)) { Assert.AreNotEqual(this.database.InstanceHandle, JET_INSTANCE.Nil); Assert.AreEqual(this.database.Config.Recovery, "off"); } try { Api.JetTerm(instance); Assert.Fail("EsentInvalidInstanceException expected !"); } // ISSUE-2014/10/28-UmairA - Debug build returns InvalidInstance, retail returns InvalidParameter. JetTerm() should be fixed. catch (EsentInvalidInstanceException) { } catch (EsentInvalidParameterException) { } }
public void TestJetDupSession() { JET_INSTANCE instance = SetupHelper.CreateNewInstance("instance"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref instance); JET_SESID sesid; Api.JetBeginSession(instance, out sesid, null, null); JET_SESID sesidDup; Api.JetDupSession(sesid, out sesidDup); Assert.AreNotEqual(sesid, sesidDup); Assert.AreNotEqual(sesidDup, JET_SESID.Nil); Api.JetTerm(instance); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); var columns = new[] { new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.TTKey } }; var columnids = new JET_COLUMNID[columns.Length]; // BUG: use TempTableGrbit.Indexed once in-memory TT bugs are fixed Api.JetOpenTempTable(this.sesid, columns, columns.Length, TempTableGrbit.Scrollable, out this.tableid, columnids); }
public void TestSetup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesId, string.Empty, string.Empty); JET_DBID dbId; Api.JetCreateDatabase(this.sesId, this.database, string.Empty, out dbId, CreateDatabaseGrbit.None); Api.JetCloseDatabase(this.sesId, dbId, CloseDatabaseGrbit.None); Api.JetOpenDatabase(this.sesId, this.database, null, out this.dbId, OpenDatabaseGrbit.None); Api.JetBeginTransaction(this.sesId); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.PageTempDBMin, SystemParameters.PageTempDBSmallest, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetCreateDatabase(this.sesid, this.database, string.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Long, }; Api.JetAddColumn(this.sesid, this.tableid, "key", columndef, null, 0, out this.keyColumn); columndef = new JET_COLUMNDEF() { cp = JET_CP.Unicode, coltyp = JET_coltyp.LongText, }; Api.JetAddColumn(this.sesid, this.tableid, "data", columndef, null, 0, out this.dataColumn); columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Bit, }; Api.JetAddColumn(this.sesid, this.tableid, "condition1", columndef, null, 0, out this.conditionalColumn1); Api.JetAddColumn(this.sesid, this.tableid, "condition2", columndef, null, 0, out this.conditionalColumn2); const string PrimaryIndexDescription = "+key\0\0"; Api.JetCreateIndex(this.sesid, this.tableid, "primary", CreateIndexGrbit.IndexPrimary, PrimaryIndexDescription, PrimaryIndexDescription.Length, 0); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.DenyRead, out this.tableid); }
public void Setup() { JET_TABLEID tableid; this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out tableid); var columndef = new JET_COLUMNDEF { coltyp = JET_coltyp.Long }; Api.JetAddColumn(this.sesid, tableid, "Column1", columndef, null, 0, out this.columnid1); Api.JetAddColumn(this.sesid, tableid, "Column2", columndef, null, 0, out this.columnid2); var indexDef = "+Column1\0\0"; Api.JetCreateIndex(this.sesid, tableid, "index1", CreateIndexGrbit.None, indexDef, indexDef.Length, 100); indexDef = "+Column2\0\0"; Api.JetCreateIndex(this.sesid, tableid, "index2", CreateIndexGrbit.None, indexDef, indexDef.Length, 100); // Create a cross-product of records. Index intersection can be used to select a subset. for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { this.InsertRecord(tableid, i, j); } } Api.JetCloseTable(this.sesid, tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); }
public void Setup() { var random = new Random(); this.numRecords = random.Next(5, 20); this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, string.Empty, string.Empty); Api.JetCreateDatabase(this.sesid, this.database, string.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Long }; Api.JetAddColumn(this.sesid, this.tableid, "Long", columndef, null, 0, out this.columnidLong); string indexDef = "+long\0\0"; Api.JetCreateIndex(this.sesid, this.tableid, "primary", CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 100); for (int i = 0; i < this.numRecords; ++i) { Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert); Api.JetSetColumn(this.sesid, this.tableid, this.columnidLong, BitConverter.GetBytes(i), 4, SetColumnGrbit.None, null); int ignored; Api.JetUpdate(this.sesid, this.tableid, null, 0, out ignored); } Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.table = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); Api.JetCreateTable(this.sesid, this.dbid, this.table, 0, 100, out this.tableid); var columndef = new JET_COLUMNDEF() { coltyp = JET_coltyp.Long, }; Api.JetAddColumn(this.sesid, this.tableid, "keycolumn", columndef, null, 0, out this.keyColumn); columndef = new JET_COLUMNDEF() { cp = JET_CP.Unicode, coltyp = JET_coltyp.LongText, grbit = ColumndefGrbit.ColumnMultiValued, }; Api.JetAddColumn(this.sesid, this.tableid, "mvcolumn", columndef, null, 0, out this.multiValueColumn); const string PrimaryIndexDescription = "+keycolumn\0\0"; Api.JetCreateIndex(this.sesid, this.tableid, "primary", CreateIndexGrbit.IndexPrimary, PrimaryIndexDescription, PrimaryIndexDescription.Length, 0); const string MultiValueIndexDescription = "+mvcolumn\0\0"; Api.JetCreateIndex(this.sesid, this.tableid, "index", CreateIndexGrbit.None, MultiValueIndexDescription, MultiValueIndexDescription.Length, 0); Api.JetCloseTable(this.sesid, this.tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush); Api.JetOpenTable(this.sesid, this.dbid, this.table, null, 0, OpenTableGrbit.None, out this.tableid); }
public void Setup() { this.directory = SetupHelper.CreateRandomDirectory(); this.database = Path.Combine(this.directory, "database.edb"); this.tableName = "table"; this.instance = SetupHelper.CreateNewInstance(this.directory); // turn off logging so initialization is faster Api.JetSetSystemParameter(this.instance, JET_SESID.Nil, JET_param.Recovery, 0, "off"); Api.JetInit(ref this.instance); Api.JetBeginSession(this.instance, out this.sesid, String.Empty, String.Empty); Api.JetCreateDatabase(this.sesid, this.database, String.Empty, out this.dbid, CreateDatabaseGrbit.None); Api.JetBeginTransaction(this.sesid); JET_TABLEID tableid; Api.JetCreateTable(this.sesid, this.dbid, this.tableName, 0, 100, out tableid); Api.JetCloseTable(this.sesid, tableid); Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.None); }