Esempio n. 1
0
        internal static bool areEqual(CreateIndexGrbit grDatabase, CreateIndexGrbit grDeclaration)
        {
            // For some reason, indices sometimes have IndexUnique bit even when it was not requested while creation.
            // So we ignore that bit when validating.
            grDatabase    &= ~CreateIndexGrbit.IndexUnique;
            grDeclaration &= ~CreateIndexGrbit.IndexUnique;

            // The DB engine normalizes JET_bitIndexIgnore*Null bits
            if (grDeclaration.HasFlag(CreateIndexGrbit.IndexIgnoreAnyNull))
            {
                grDeclaration |= CreateIndexGrbit.IndexIgnoreFirstNull;
                grDeclaration |= CreateIndexGrbit.IndexIgnoreNull;
            }

            return(grDatabase == grDeclaration);
        }
Esempio n. 2
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));
            }
        }