Пример #1
0
        public void Setup()
        {
            var s1 = new JET_RECSIZE
            {
                cbData                    = 0x10,
                cbDataCompressed          = 0x20,
                cbLongValueData           = 0x30,
                cbLongValueDataCompressed = 0x40,
                cbLongValueOverhead       = 0x50,
                cbOverhead                = 0x60,
                cCompressedColumns        = 0x70,
                cLongValues               = 0x80,
                cMultiValues              = 0x90,
                cNonTaggedColumns         = 0xa0,
                cTaggedColumns            = 0xb0,
            };

            var s2 = new JET_RECSIZE
            {
                cbData                    = 0x1,
                cbDataCompressed          = 0x2,
                cbLongValueData           = 0x3,
                cbLongValueDataCompressed = 0x4,
                cbLongValueOverhead       = 0x5,
                cbOverhead                = 0x6,
                cCompressedColumns        = 0x7,
                cLongValues               = 0x8,
                cMultiValues              = 0x9,
                cNonTaggedColumns         = 0xa,
                cTaggedColumns            = 0xb,
            };

            this.result      = s1 + s2;
            this.namedResult = JET_RECSIZE.Add(s1, s2);
        }
Пример #2
0
        public void Setup()
        {
            var s1 = new JET_RECSIZE
            {
                cbData                    = 0x11,
                cbDataCompressed          = 0x22,
                cbLongValueData           = 0x33,
                cbLongValueDataCompressed = 0x44,
                cbLongValueOverhead       = 0x55,
                cbOverhead                = 0x66,
                cCompressedColumns        = 0x77,
                cLongValues               = 0x88,
                cMultiValues              = 0x99,
                cNonTaggedColumns         = 0xaa,
                cTaggedColumns            = 0xbb,
            };

            var s2 = new JET_RECSIZE
            {
                cbData                    = 0x1,
                cbDataCompressed          = 0x2,
                cbLongValueData           = 0x3,
                cbLongValueDataCompressed = 0x4,
                cbLongValueOverhead       = 0x5,
                cbOverhead                = 0x6,
                cCompressedColumns        = 0x7,
                cLongValues               = 0x8,
                cMultiValues              = 0x9,
                cNonTaggedColumns         = 0xa,
                cTaggedColumns            = 0xb,
            };

            this.result      = s1 - s2;
            this.namedResult = JET_RECSIZE.Subtract(s1, s2);
        }
Пример #3
0
        public void JetGetRecordSizeSeparated()
        {
            if (!EsentVersion.SupportsVistaFeatures)
            {
                return;
            }

            var size = new JET_RECSIZE();

            byte[] data = Any.BytesOfLength(64);
            Api.JetBeginTransaction(this.sesid);
            Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
            Api.JetSetColumn(this.sesid, this.tableid, this.columnidLongText, data, data.Length, SetColumnGrbit.SeparateLV, null);
            VistaApi.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.InCopyBuffer);
            this.UpdateAndGotoBookmark();
            VistaApi.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.RunningTotal);

            Assert.AreEqual(0, size.cbData, "cbData");
            Assert.AreEqual(0, size.cbDataCompressed, "cbDataCompressed");
            Assert.AreEqual(data.Length * 2, size.cbLongValueData, "cbLongValueData");
            Assert.AreEqual(data.Length * 2, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
            Assert.AreNotEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
            Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
            Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
            Assert.AreEqual(2, size.cLongValues, "cLongValues");
            Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
            Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
            Assert.AreEqual(2, size.cTaggedColumns, "cTaggedColumns");
        }
Пример #4
0
        public void Setup()
        {
            var s1 = new JET_RECSIZE
            {
                cbData = 0x10,
                cbDataCompressed = 0x20,
                cbLongValueData = 0x30,
                cbLongValueDataCompressed = 0x40,
                cbLongValueOverhead = 0x50,
                cbOverhead = 0x60,
                cCompressedColumns = 0x70,
                cLongValues = 0x80,
                cMultiValues = 0x90,
                cNonTaggedColumns = 0xa0,
                cTaggedColumns = 0xb0,
            };

            var s2 = new JET_RECSIZE
            {
                cbData = 0x1,
                cbDataCompressed = 0x2,
                cbLongValueData = 0x3,
                cbLongValueDataCompressed = 0x4,
                cbLongValueOverhead = 0x5,
                cbOverhead = 0x6,
                cCompressedColumns = 0x7,
                cLongValues = 0x8,
                cMultiValues = 0x9,
                cNonTaggedColumns = 0xa,
                cTaggedColumns = 0xb,
            };

            this.result = s1 + s2;
            this.namedResult = JET_RECSIZE.Add(s1, s2);
        }
Пример #5
0
        // verifies that the data in the record matches the expected values
        private void CheckColumns(JET_SESID sesid, JET_TABLEID tableid, byte[][] expectedData)
        {
            byte[][] actualData;

            actualData = this.GetColumnsWithJetRetrieveColumn(sesid, tableid);
            this.CompareColumns(actualData, expectedData);
            actualData = this.GetColumnsWithJetRetrieveColumns(sesid, tableid);
            this.CompareColumns(actualData, expectedData);

            int totalsize = 0;

            foreach (var columndata in actualData)
            {
                if (columndata != null)
                {
                    totalsize += columndata.Length;
                }
            }

            // BUGBUG: need to investigate why this gives a value which is larger than the sum of the column sizes
            var recsize = new JET_RECSIZE();

            VistaApi.JetGetRecordSize(sesid, tableid, ref recsize, GetRecordSizeGrbit.None);
            BasicClass.Assert(
                recsize.cbData + recsize.cbLongValueData >= totalsize,
                string.Format("JetGetRecordSize returned {0} bytes, expected {1}", recsize.cbData + recsize.cbLongValueData, totalsize));
        }
Пример #6
0
        public void Setup()
        {
            var s1 = new JET_RECSIZE
            {
                cbData = 0x11,
                cbDataCompressed = 0x22,
                cbLongValueData = 0x33,
                cbLongValueDataCompressed = 0x44,
                cbLongValueOverhead = 0x55,
                cbOverhead = 0x66,
                cCompressedColumns = 0x77,
                cLongValues = 0x88,
                cMultiValues = 0x99,
                cNonTaggedColumns = 0xaa,
                cTaggedColumns = 0xbb,
            };

            var s2 = new JET_RECSIZE
            {
                cbData = 0x1,
                cbDataCompressed = 0x2,
                cbLongValueData = 0x3,
                cbLongValueDataCompressed = 0x4,
                cbLongValueOverhead = 0x5,
                cbOverhead = 0x6,
                cCompressedColumns = 0x7,
                cLongValues = 0x8,
                cMultiValues = 0x9,
                cNonTaggedColumns = 0xa,
                cTaggedColumns = 0xb,
            };

            this.result = s1 - s2;
        }
Пример #7
0
        public void VerifyRecsizeCanBeSerialized()
        {
            var expected = new JET_RECSIZE {
                cbData = 101
            };

            SerializeAndCompare(expected);
        }
Пример #8
0
 public void Setup()
 {
     this.managed = new JET_RECSIZE
     {
         cbData              = 1,
         cbLongValueData     = 2,
         cbLongValueOverhead = 3,
         cbOverhead          = 4,
         cLongValues         = 5,
         cMultiValues        = 6,
         cNonTaggedColumns   = 7,
         cTaggedColumns      = 8,
     };
     this.native = this.managed.GetNativeRecsize();
 }
 public void Setup()
 {
     this.managed = new JET_RECSIZE
     {
         cbData = 1,
         cbLongValueData = 2,
         cbLongValueOverhead = 3,
         cbOverhead = 4,
         cLongValues = 5,
         cMultiValues = 6,
         cNonTaggedColumns = 7,
         cTaggedColumns = 8,
     };
     this.native = this.managed.GetNativeRecsize();
 }
Пример #10
0
 public void Setup()
 {
     this.native = new NATIVE_RECSIZE2
     {
         cbData                    = 1,
         cbDataCompressed          = 2,
         cbLongValueData           = 3,
         cbLongValueDataCompressed = 4,
         cbLongValueOverhead       = 5,
         cbOverhead                = 6,
         cCompressedColumns        = 7,
         cLongValues               = 8,
         cMultiValues              = 9,
         cNonTaggedColumns         = 10,
         cTaggedColumns            = 11,
     };
     this.managed = new JET_RECSIZE();
     this.managed.SetFromNativeRecsize(this.native);
 }
Пример #11
0
 public void Setup()
 {
     this.native = new NATIVE_RECSIZE2
     {
         cbData = 1,
         cbDataCompressed = 2,
         cbLongValueData = 3,
         cbLongValueDataCompressed = 4,
         cbLongValueOverhead = 5,
         cbOverhead = 6,
         cCompressedColumns = 7,
         cLongValues = 8,
         cMultiValues = 9,
         cNonTaggedColumns = 10,
         cTaggedColumns = 11,
     };
     this.managed = new JET_RECSIZE();
     this.managed.SetFromNativeRecsize(this.native);
 }
Пример #12
0
        public void JetGetRecordSizeIntrinsic()
        {
            var size = new JET_RECSIZE();

            byte[] data = Any.Bytes;
            Api.JetBeginTransaction(this.sesid);
            Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
            Api.JetSetColumn(this.sesid, this.tableid, this.columnidLongText, data, data.Length, SetColumnGrbit.None, null);
            this.UpdateAndGotoBookmark();
            Api.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.None);

            Assert.AreEqual(data.Length, size.cbData, "cbData");
            Assert.AreEqual(data.Length, size.cbDataCompressed, "cbDataCompressed");
            Assert.AreEqual(0, size.cbLongValueData, "cbLongValueData");
            Assert.AreEqual(0, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
            Assert.AreEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
            Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
            Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
            Assert.AreEqual(0, size.cLongValues, "cLongValues");
            Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
            Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
            Assert.AreEqual(1, size.cTaggedColumns, "cTaggedColumns");
        }
        public void GetRecordSizeOnVista()
        {
            if (!EsentVersion.SupportsVistaFeatures)
            {
                return;
            }

            string directory = SetupHelper.CreateRandomDirectory();
            string database  = Path.Combine(directory, "test.db");

            using (var instance = new Instance("VistaGetRecordSize"))
            {
                instance.Parameters.Recovery           = false;
                instance.Parameters.NoInformationEvent = true;
                instance.Parameters.MaxTemporaryTables = 0;
                instance.Init();
                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetCreateDatabase(session, database, string.Empty, out dbid, CreateDatabaseGrbit.None);
                    using (var transaction = new Transaction(session))
                    {
                        JET_TABLEID tableid;
                        Api.JetCreateTable(session, dbid, "table", 0, 100, out tableid);
                        JET_COLUMNID columnid;
                        Api.JetAddColumn(
                            session,
                            tableid,
                            "column1",
                            new JET_COLUMNDEF {
                            coltyp = JET_coltyp.LongBinary
                        },
                            null,
                            0,
                            out columnid);

                        var    size = new JET_RECSIZE();
                        byte[] data = Any.Bytes;

                        using (var update = new Update(session, tableid, JET_prep.Insert))
                        {
                            Api.SetColumn(session, tableid, columnid, data);
                            VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.Local | GetRecordSizeGrbit.InCopyBuffer);
                            update.SaveAndGotoBookmark();
                        }

                        VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.RunningTotal);

                        Assert.AreEqual(data.Length * 2, size.cbData, "cbData");
                        Assert.AreEqual(data.Length * 2, size.cbDataCompressed, "cbDataCompressed");
                        Assert.AreEqual(0, size.cbLongValueData, "cbLongValueData");
                        Assert.AreEqual(0, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
                        Assert.AreEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
                        Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
                        Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
                        Assert.AreEqual(0, size.cLongValues, "cLongValues");
                        Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
                        Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
                        Assert.AreEqual(2, size.cTaggedColumns, "cTaggedColumns");

                        transaction.Commit(CommitTransactionGrbit.LazyFlush);
                    }
                }
            }

            Cleanup.DeleteDirectoryWithRetry(directory);
        }
Пример #14
0
 public void VerifyXpThrowsExceptionOnJetGetRecordSize()
 {
     JET_RECSIZE recsize = new JET_RECSIZE();
     VistaApi.JetGetRecordSize(JET_SESID.Nil, JET_TABLEID.Nil, ref recsize, GetRecordSizeGrbit.None);
 }
Пример #15
0
 /// <summary>
 /// Retrieves record size information from the desired location.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="tableid">
 /// The cursor that will be used for the API call. The cursor must be
 /// positioned on a record, or have an update prepared.
 /// </param>
 /// <param name="recsize">Returns the size of the record.</param>
 /// <param name="grbit">Call options.</param>
 public static void JetGetRecordSize(JET_SESID sesid, JET_TABLEID tableid, ref JET_RECSIZE recsize, GetRecordSizeGrbit grbit)
 {
     Api.Check(Api.Impl.JetGetRecordSize(sesid, tableid, ref recsize, grbit));
 }
Пример #16
0
        // verifies that the data in the record matches the expected values
        private void CheckColumns(JET_SESID sesid, JET_TABLEID tableid, byte[][] expectedData)
        {
            byte[][] actualData;

            actualData = this.GetColumnsWithJetRetrieveColumn(sesid, tableid);
            this.CompareColumns(actualData, expectedData);
            actualData = this.GetColumnsWithJetRetrieveColumns(sesid, tableid);
            this.CompareColumns(actualData, expectedData);

            int totalsize = 0;
            foreach (var columndata in actualData)
            {
                if (columndata != null)
                {
                    totalsize += columndata.Length;
                }
            }

            // BUGBUG: need to investigate why this gives a value which is larger than the sum of the column sizes
            var recsize = new JET_RECSIZE();
            VistaApi.JetGetRecordSize(sesid, tableid, ref recsize, GetRecordSizeGrbit.None);
            BasicClass.Assert(
                recsize.cbData + recsize.cbLongValueData >= totalsize,
                String.Format("JetGetRecordSize returned {0} bytes, expected {1}", recsize.cbData + recsize.cbLongValueData, totalsize));
        }
Пример #17
0
 /// <summary>
 /// Retrieves record size information from the desired location.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="tableid">
 /// The cursor that will be used for the API call. The cursor must be
 /// positioned on a record, or have an update prepared.
 /// </param>
 /// <param name="recsize">Returns the size of the record.</param>
 /// <param name="grbit">Call options.</param>
 public static void JetGetRecordSize(JET_SESID sesid, JET_TABLEID tableid, ref JET_RECSIZE recsize, GetRecordSizeGrbit grbit)
 {
     Api.Check(Api.Impl.JetGetRecordSize(sesid, tableid, ref recsize, grbit));
 }
Пример #18
0
        public void JetGetRecordSizeSeparated()
        {
            var size = new JET_RECSIZE();

            byte[] data = Any.BytesOfLength(64);
            Api.JetBeginTransaction(this.sesid);
            Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
            Api.JetSetColumn(this.sesid, this.tableid, this.columnidLongText, data, data.Length, SetColumnGrbit.SeparateLV, null);
            Api.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.InCopyBuffer);
            this.UpdateAndGotoBookmark();
            Api.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.RunningTotal);

            Assert.AreEqual(0, size.cbData, "cbData");
            Assert.AreEqual(0, size.cbDataCompressed, "cbDataCompressed");
            Assert.AreEqual(data.Length * 2, size.cbLongValueData, "cbLongValueData");
            Assert.AreEqual(data.Length * 2, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
            Assert.AreNotEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
            Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
            Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
            Assert.AreEqual(2, size.cLongValues, "cLongValues");
            Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
            Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
            Assert.AreEqual(2, size.cTaggedColumns, "cTaggedColumns");
        }
Пример #19
0
        public void VerifyXpThrowsExceptionOnJetGetRecordSize()
        {
            JET_RECSIZE recsize = new JET_RECSIZE();

            VistaApi.JetGetRecordSize(JET_SESID.Nil, JET_TABLEID.Nil, ref recsize, GetRecordSizeGrbit.None);
        }
Пример #20
0
        public void GetRecordSizeOnVista()
        {
            if (!EsentVersion.SupportsVistaFeatures)
            {
                return;
            }

            string directory = SetupHelper.CreateRandomDirectory();
            string database = Path.Combine(directory, "test.db");

            using (var instance = new Instance("VistaGetRecordSize"))
            {
                instance.Parameters.Recovery = false;
                instance.Parameters.NoInformationEvent = true;
                instance.Parameters.MaxTemporaryTables = 0;
                instance.Init();
                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetCreateDatabase(session, database, String.Empty, out dbid, CreateDatabaseGrbit.None);
                    using (var transaction = new Transaction(session))
                    {
                        JET_TABLEID tableid;
                        Api.JetCreateTable(session, dbid, "table", 0, 100, out tableid);
                        JET_COLUMNID columnid;
                        Api.JetAddColumn(
                            session,
                            tableid,
                            "column1",
                            new JET_COLUMNDEF { coltyp = JET_coltyp.LongBinary },
                            null,
                            0,
                            out columnid);

                        var size = new JET_RECSIZE();
                        byte[] data = Any.Bytes;

                        using (var update = new Update(session, tableid, JET_prep.Insert))
                        {
                            Api.SetColumn(session, tableid, columnid, data);
                            VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.Local | GetRecordSizeGrbit.InCopyBuffer);
                            update.SaveAndGotoBookmark();
                        }

                        VistaApi.JetGetRecordSize(session, tableid, ref size, GetRecordSizeGrbit.RunningTotal);

                        Assert.AreEqual(data.Length * 2, size.cbData, "cbData");
                        Assert.AreEqual(data.Length * 2, size.cbDataCompressed, "cbDataCompressed");
                        Assert.AreEqual(0, size.cbLongValueData, "cbLongValueData");
                        Assert.AreEqual(0, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
                        Assert.AreEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
                        Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
                        Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
                        Assert.AreEqual(0, size.cLongValues, "cLongValues");
                        Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
                        Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
                        Assert.AreEqual(2, size.cTaggedColumns, "cTaggedColumns");

                        transaction.Commit(CommitTransactionGrbit.LazyFlush);
                    }
                }
            }

            Cleanup.DeleteDirectoryWithRetry(directory);
        }
Пример #21
0
        public void JetGetRecordSizeIntrinsic()
        {
            if (!EsentVersion.SupportsVistaFeatures)
            {
                return;
            }

            var size = new JET_RECSIZE();

            byte[] data = Any.Bytes;
            Api.JetBeginTransaction(this.sesid);
            Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
            Api.JetSetColumn(this.sesid, this.tableid, this.columnidLongText, data, data.Length, SetColumnGrbit.None, null);
            this.UpdateAndGotoBookmark();
            VistaApi.JetGetRecordSize(this.sesid, this.tableid, ref size, GetRecordSizeGrbit.None);

            Assert.AreEqual(data.Length, size.cbData, "cbData");
            Assert.AreEqual(data.Length, size.cbDataCompressed, "cbDataCompressed");
            Assert.AreEqual(0, size.cbLongValueData, "cbLongValueData");
            Assert.AreEqual(0, size.cbLongValueDataCompressed, "cbLongValueDataCompressed");
            Assert.AreEqual(0, size.cbLongValueOverhead, "cbLongValueOverhead");
            Assert.AreNotEqual(0, size.cbOverhead, "cbOverhead");
            Assert.AreEqual(0, size.cCompressedColumns, "cCompressedColumns");
            Assert.AreEqual(0, size.cLongValues, "cLongValues");
            Assert.AreEqual(0, size.cMultiValues, "cMultiValues");
            Assert.AreEqual(0, size.cNonTaggedColumns, "cTaggedColumns");
            Assert.AreEqual(1, size.cTaggedColumns, "cTaggedColumns");
        }