public void JetCreateIndex4UnicodeIndex2()
        {
            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 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,
                ulDensity   = 100,
            };

            Windows8Api.JetCreateIndex4(this.sesid, this.tableid, new[] { indexcreate }, 1);
            Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);

            Api.JetSetCurrentIndex(this.sesid, this.tableid, IndexName);
        }
Example #2
0
        public void SortDataCaseSensitiveWithJetOpenTempTable3()
        {
            JET_TABLEID tableid;
            var         columns = new[]
            {
                new JET_COLUMNDEF {
                    coltyp = JET_coltyp.Text, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey
                },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                lcid       = 1033,
            };

            Api.JetOpenTempTable3(this.session, columns, columns.Length, idxunicode, TempTableGrbit.None, out tableid, columnids);

            var data = new[] { "g", "a", "A", "aa", "x", "b", "X" };

            foreach (string s in data)
            {
                using (var update = new Update(this.session, tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.session, tableid, columnids[0], s, Encoding.Unicode);
                    update.Save();
                }
            }

            Array.Sort(data);
            CollectionAssert.AreEqual(data, this.RetrieveAllRecordsAsString(tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, tableid);
        }
Example #3
0
        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);
        }
Example #4
0
        public void JetUnicodeIndexToString()
        {
            var unicodeindex = new JET_UNICODEINDEX {
                lcid = 1033, szLocaleName = "en-US", dwMapFlags = 0x12f
            };

            Assert.AreEqual("JET_UNICODEINDEX(1033:en-US:0x12F)", unicodeindex.ToString());
        }
Example #5
0
        public void VerifyUnicodeIndexCanBeSerialized()
        {
            var expected = new JET_UNICODEINDEX {
                lcid = 1234
            };

            SerializeAndCompareContent(expected);
        }
 public void Setup()
 {
     this.managed = new JET_UNICODEINDEX()
     {
         szLocaleName = LocaleName,
         dwMapFlags   = 0x400,
     };
     this.native = this.managed.GetNativeUnicodeIndex2();
 }
Example #7
0
 public void Setup()
 {
     this.managed = new JET_UNICODEINDEX()
     {
         lcid       = 1033,
         dwMapFlags = 0x400,
     };
     this.native = this.managed.GetNativeUnicodeIndex();
 }
        public void VerifyGetEffectiveLocaleNameWorksWithLcid1033()
        {
            var unicodeIndex = new JET_UNICODEINDEX()
            {
                lcid       = 1033,
                dwMapFlags = 0x400,
            };

            Assert.AreEqual("en-us", unicodeIndex.GetEffectiveLocaleName());
        }
        public void VerifyGetEffectiveLocaleNameWorksWithLcidNotInCache()
        {
            var unicodeIndex = new JET_UNICODEINDEX()
            {
                lcid       = 0x0477, // "la-Latn"
                dwMapFlags = 0x400,
            };

            Assert.AreEqual(null, unicodeIndex.GetEffectiveLocaleName());
        }
        public void VerifyGetEffectiveLocaleNameWorksWithNull()
        {
            var unicodeIndex = new JET_UNICODEINDEX()
            {
                szLocaleName = null,
                dwMapFlags   = 0x400,
            };

            Assert.AreEqual(null, unicodeIndex.GetEffectiveLocaleName());
        }
        public void VerifyGetEffectiveLocaleNameWorksWithLcid127()
        {
            var unicodeIndex = new JET_UNICODEINDEX()
            {
                lcid       = 127,
                dwMapFlags = 0x400,
            };

            Assert.AreEqual(string.Empty, unicodeIndex.GetEffectiveLocaleName());
        }
Example #12
0
        public void VerifyJetUnicodeIndexEquality()
        {
            var x = new JET_UNICODEINDEX {
                lcid = 1033, dwMapFlags = 1
            };
            var y = new JET_UNICODEINDEX {
                lcid = 1033, dwMapFlags = 1
            };

            TestContentEquals(x, y);
        }
        public void SortDataDifferentLocalesWithJetOpenTemporaryTable2()
        {
            if (!EsentVersion.SupportsWindows8Features)
            {
                return;
            }

            CultureInfo cultureInfo = new CultureInfo("es-ES_tradnl");
            string      localeName  = cultureInfo.CompareInfo.Name;

            Assert.AreEqual("es-ES_tradnl", localeName);

            var columns = new[]
            {
                new JET_COLUMNDEF {
                    coltyp = JET_coltyp.Text, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey
                },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                szLocaleName = localeName,
            };

            var opentemporarytable = new JET_OPENTEMPORARYTABLE
            {
                cbKeyMost    = SystemParameters.KeyMost,
                ccolumn      = columns.Length,
                grbit        = TempTableGrbit.Scrollable,
                pidxunicode  = idxunicode,
                prgcolumndef = columns,
                prgcolumnid  = columnids,
            };

            Windows8Api.JetOpenTemporaryTable2(this.sesid, opentemporarytable);

            // Note that es-ES_tradnl sorts differently than English.
            var data = new[] { "canary", "cocoa", "chicken", "bad!" };

            foreach (string s in data)
            {
                using (var update = new Update(this.sesid, opentemporarytable.tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.sesid, opentemporarytable.tableid, columnids[0], s, Encoding.Unicode);
                    update.Save();
                }
            }

            Array.Sort(data, new CultureInfo(localeName).CompareInfo.Compare);

            CollectionAssert.AreEqual(data, this.RetrieveAllRecordsAsString(opentemporarytable.tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.sesid, opentemporarytable.tableid);
        }
Example #14
0
        public void SortDataCaseSensitiveWithJetOpenTemporaryTable3()
        {
            if (!EsentVersion.SupportsWindows8Features)
            {
                return;
            }

            const string LocaleName = "pt-BR";

            var columns = new[]
            {
                new JET_COLUMNDEF {
                    coltyp = JET_coltyp.Text, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey
                },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags   = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                szLocaleName = LocaleName,
            };

            var opentemporarytable = new JET_OPENTEMPORARYTABLE
            {
                cbKeyMost    = SystemParameters.KeyMost,
                ccolumn      = columns.Length,
                grbit        = TempTableGrbit.Scrollable,
                pidxunicode  = idxunicode,
                prgcolumndef = columns,
                prgcolumnid  = columnids,
            };

            Windows8Api.JetOpenTemporaryTable2(this.session, opentemporarytable);

            var data = new[] { "g", "a", "A", "aa", "x", "b", "X" };

            foreach (string s in data)
            {
                using (var update = new Update(this.session, opentemporarytable.tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.session, opentemporarytable.tableid, columnids[0], s, Encoding.Unicode);
                    update.Save();
                }
            }

            Array.Sort(data, new CultureInfo(LocaleName).CompareInfo.Compare);
            CollectionAssert.AreEqual(
                data, this.RetrieveAllRecordsAsString(opentemporarytable.tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, opentemporarytable.tableid);
        }
        public void SortLongValueDataWithJetOpenTempTable3()
        {
            JET_TABLEID tableid;
            var         columns = new[]
            {
                new JET_COLUMNDEF {
                    coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey
                },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                lcid       = 1041, // ja-JP
            };

            Api.JetOpenTempTable3(this.session, columns, columns.Length, idxunicode, TempTableGrbit.Scrollable, out tableid, columnids);

            var data = new[]
            {
                Any.StringOfLength(1999),
                Any.StringOfLength(2000),
                Any.StringOfLength(1999),
                Any.StringOfLength(2000),
                Any.StringOfLength(2001),
                Any.StringOfLength(2000),
                Any.StringOfLength(1999)
            };

            using (var transaction = new Transaction(this.session))
            {
                foreach (string s in data)
                {
                    using (var update = new Update(this.session, tableid, JET_prep.Insert))
                    {
                        Api.SetColumn(this.session, tableid, columnids[0], s, Encoding.Unicode);
                        update.Save();
                    }
                }

                transaction.Commit(CommitTransactionGrbit.None);
            }

            Array.Sort(data, new CultureInfo("ja-JP").CompareInfo.Compare);

            CollectionAssert.AreEqual(data, this.RetrieveAllRecordsAsString(tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, tableid);
        }
        public void VerifyUnicodeIndexConversionToNativeThrowsWithLcid()
        {
            var unicodeIndexWithLcid = new JET_UNICODEINDEX()
            {
                szLocaleName = "de-de",
                dwMapFlags   = 0x30403,
            };

            try
            {
                NATIVE_UNICODEINDEX unicodeindex = unicodeIndexWithLcid.GetNativeUnicodeIndex();
                Assert.Fail("The conversion should have thrown an ArgumentException!");
            }
            catch (ArgumentException)
            {
            }
        }
        public void VerifyJetIndexInfoLocaleName()
        {
            if (!EsentVersion.SupportsWindows8Features)
            {
                return;
            }

            Api.JetBeginTransaction(this.sesid);

            const string IndexName        = "localizedIndex";
            const string IndexDescription = "-TestColumn\0\0";
            const string LocaleName       = "pt-bR";

            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,
                ulDensity   = 100,
            };

            Windows8Api.JetCreateIndex4(this.sesid, this.tableid, new[] { indexcreate }, 1);
            Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);

            string localeNameOut;

            Api.JetGetIndexInfo(this.sesid, this.dbid, this.table, IndexName, out localeNameOut, Windows8IdxInfo.LocaleName);
            Assert.IsNotNull(localeNameOut);
            Assert.AreEqual(LocaleName, localeNameOut, true);

            localeNameOut = null;
            Api.JetGetTableIndexInfo(this.sesid, this.tableid, IndexName, out localeNameOut, Windows8IdxInfo.LocaleName);
            Assert.IsNotNull(localeNameOut);
            Assert.AreEqual(LocaleName, localeNameOut, true);

            Api.JetSetCurrentIndex(this.sesid, this.tableid, IndexName);
        }
        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);
        }
Example #19
0
        public void GetIndexInformationOneIndexWithCompareOptions()
        {
            const string Indexname = "myindex";
            const string Indexdef  = "-unicode\0\0";

            CultureInfo currentCulture = CultureInfo.CurrentCulture;
            var         pidxUnicode    = new JET_UNICODEINDEX
            {
                lcid       = EseInteropTestHelper.CultureInfoGetLcid(currentCulture),
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase),
            };

            var indexcreate = new JET_INDEXCREATE
            {
                szIndexName = Indexname,
                szKey       = Indexdef,
                cbKey       = Indexdef.Length,
                grbit       = CreateIndexGrbit.IndexDisallowNull,
                pidxUnicode = pidxUnicode,
            };

            Api.JetBeginTransaction(this.sesid);
            Api.JetCreateIndex2(this.sesid, this.tableid, new[] { indexcreate }, 1);
            IEnumerable <IndexInfo> indexes = Api.GetTableIndexes(this.sesid, this.tableid);

            // There should be only one index
            IndexInfo info = indexes.Single();

            Assert.AreEqual(Indexname, info.Name);
            Assert.AreEqual(CreateIndexGrbit.IndexDisallowNull, info.Grbit);

            Assert.AreEqual(1, info.IndexSegments.Count);
            Assert.AreEqual("unicode", info.IndexSegments[0].ColumnName, true);
            Assert.IsFalse(info.IndexSegments[0].IsAscending);
            Assert.AreEqual(JET_coltyp.LongText, info.IndexSegments[0].Coltyp);
            Assert.IsFalse(info.IndexSegments[0].IsASCII);
            Assert.AreEqual(CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase, info.CompareOptions);

            Api.JetRollback(this.sesid, RollbackTransactionGrbit.None);
        }
        /// <summary>
        /// Creates a temp table with GUID column and tests .Net sort order.
        /// </summary>
        private void TestTempTableWithGuidDotNetSortOrder()
        {
            // check temp table logic
            EseInteropTestHelper.ConsoleWriteLine("Create temp table on GUID column.");

            var columns = new[]
            {
                new JET_COLUMNDEF {
                    coltyp = VistaColtyp.GUID, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey
                },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags   = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                szLocaleName = "pt-br",
            };

            var opentemporarytable = new JET_OPENTEMPORARYTABLE
            {
                cbKeyMost    = SystemParameters.KeyMost,
                ccolumn      = columns.Length,
                grbit        = TempTableGrbit.Scrollable | Windows8Grbits.TTDotNetGuid,
                pidxunicode  = idxunicode,
                prgcolumndef = columns,
                prgcolumnid  = columnids,
            };

            Windows8Api.JetOpenTemporaryTable2(this.sesId, opentemporarytable);
            Guid g = System.Guid.NewGuid();

            EseInteropTestHelper.ConsoleWriteLine("Insert values in temp table.");
            for (int i = 0; i < 10000; i++)
            {
                if ((i % 2000) == 0)
                {
                    EseInteropTestHelper.ConsoleWriteLine("Added another 2000 Guids.");
                }

                using (var update = new Update(this.sesId, opentemporarytable.tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.sesId, opentemporarytable.tableid, columnids[0], g);
                    update.Save();
                }

                g = System.Guid.NewGuid();
            }

            EseInteropTestHelper.ConsoleWriteLine("Finished inserting values in temp table.");

            // validate order after having closed the database and restarted
            Api.JetMove(this.sesId, opentemporarytable.tableid, JET_Move.First, MoveGrbit.None);
            int bytesRead;

            byte[] data = new byte[16];
            Api.JetRetrieveColumn(this.sesId, opentemporarytable.tableid, columnids[0], data, data.Length, out bytesRead, 0, null);
            Guid guidPrev = new System.Guid(data);

            EseInteropTestHelper.ConsoleWriteLine("Retrieved first value from temp table.");
            Guid guidCur;

            for (int i = 1; i < 10000; i++)
            {
                Api.JetMove(this.sesId, opentemporarytable.tableid, JET_Move.Next, MoveGrbit.None);
                Api.JetRetrieveColumn(this.sesId, opentemporarytable.tableid, columnids[0], data, data.Length, out bytesRead, 0, null);

                guidCur = new System.Guid(data);
                Assert.IsTrue(guidCur.CompareTo(guidPrev) > 0);
                guidPrev = guidCur;
            }

            EseInteropTestHelper.ConsoleWriteLine("Validated temp table order.");
        }
        public void JetCreateTableColumnIndex4UnicodeIndex2()
        {
            if (!EsentVersion.SupportsWindows8Features)
            {
                return;
            }

            const string LocaleName = "en-US";

            var unicode = new JET_UNICODEINDEX()
            {
                szLocaleName = LocaleName,
                dwMapFlags   = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
            };

            var columncreates = new JET_COLUMNCREATE[]
            {
                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 indexcreates = new JET_INDEXCREATE[]
            {
                new JET_INDEXCREATE
                {
                    szIndexName = Index1Name,
                    szKey       = Index1Description,
                    cbKey       = Index1Description.Length + 1,
                    pidxUnicode = unicode,
                    grbit       = CreateIndexGrbit.None,
                    ulDensity   = 99,
                },
                new JET_INDEXCREATE
                {
                    szIndexName = Index2Name,
                    szKey       = Index2Description,
                    cbKey       = Index2Description.Length + 1,
                    pidxUnicode = unicode,
                    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,
            };

            Api.JetBeginTransaction(this.sesid);
            Windows8Api.JetCreateTableColumnIndex4(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);

            Assert.AreNotEqual(tablecreate.rgcolumncreate[0].columnid, JET_COLUMNID.Nil);
            Assert.AreNotEqual(tablecreate.rgcolumncreate[1].columnid, JET_COLUMNID.Nil);

            Api.JetCloseTable(this.sesid, tableCreated);
            Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);
        }
Example #22
0
        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));
            }
        }