Permalink
Browse files

Added support for databases with multiple data files. Major refactori…

…ng around MdfFile -> Database/DataFile.
  • Loading branch information...
1 parent 88f53e0 commit 08cd6e7d7cd395b0de1611eca50027315e5e8e23 @improvedk committed Oct 23, 2011
Showing with 748 additions and 455 deletions.
  1. +10 −1 Todo.txt
  2. +1 −1 src/OrcaMDF.Adhoc/EntityPrinter.cs
  3. +6 −3 src/OrcaMDF.Adhoc/Program.cs
  4. +4 −4 src/OrcaMDF.Core.Tests/Engine/DataScannerTests.cs
  5. +11 −11 src/OrcaMDF.Core.Tests/Engine/IndexScannerTests.cs
  6. +2 −2 src/OrcaMDF.Core.Tests/Engine/Records/RecordTests.cs
  7. +2 −2 src/OrcaMDF.Core.Tests/Features/DataTypes/Decimal/DecimalTests.cs
  8. +2 −2 src/OrcaMDF.Core.Tests/Features/ForwardedRecords/ForwardedRecordTests.cs
  9. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/ImageTests.cs
  10. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/NTextTests.cs
  11. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/NVarcharMaxTests.cs
  12. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/TextTests.cs
  13. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/VarBinaryTests.cs
  14. +18 −18 src/OrcaMDF.Core.Tests/Features/LobTypes/VarcharMaxTests.cs
  15. +96 −0 src/OrcaMDF.Core.Tests/Features/MultiDataFile/MultiFileTests.cs
  16. +4 −5 src/OrcaMDF.Core.Tests/Features/NullBitmap/NullBitmapTests.cs
  17. +12 −12 src/OrcaMDF.Core.Tests/Features/SparseColumns/SparseColumnTests.cs
  18. +4 −4 src/OrcaMDF.Core.Tests/MetaData/DatabaseMetaDataTests/MetaDataTests.cs
  19. +2 −1 src/OrcaMDF.Core.Tests/OrcaMDF.Core.Tests.csproj
  20. +49 −24 src/OrcaMDF.Core.Tests/SqlServerSystemTest.cs
  21. +72 −0 src/OrcaMDF.Core/Engine/BufferManager.cs
  22. +14 −0 src/OrcaMDF.Core/Engine/DataFile.cs
  23. +20 −9 src/OrcaMDF.Core/Engine/DataScanner.cs
  24. +168 −0 src/OrcaMDF.Core/Engine/Database.cs
  25. +4 −4 src/OrcaMDF.Core/Engine/IndexScanner.cs
  26. +0 −179 src/OrcaMDF.Core/Engine/MdfFile.cs
  27. +2 −2 src/OrcaMDF.Core/Engine/Pages/BootPage.cs
  28. +2 −2 src/OrcaMDF.Core/Engine/Pages/ClusteredIndexPage.cs
  29. +2 −2 src/OrcaMDF.Core/Engine/Pages/DataPage.cs
  30. +4 −4 src/OrcaMDF.Core/Engine/Pages/ExtentAllocationMap.cs
  31. +46 −0 src/OrcaMDF.Core/Engine/Pages/FileHeaderPage.cs
  32. +2 −2 src/OrcaMDF.Core/Engine/Pages/GamPage.cs
  33. +15 −2 src/OrcaMDF.Core/Engine/Pages/IamPage.cs
  34. +2 −2 src/OrcaMDF.Core/Engine/Pages/IndexRecordPage.cs
  35. +2 −2 src/OrcaMDF.Core/Engine/Pages/NonclusteredIndexPage.cs
  36. +2 −2 src/OrcaMDF.Core/Engine/Pages/PFS/PfsPage.cs
  37. +3 −19 src/OrcaMDF.Core/Engine/Pages/Page.cs
  38. +2 −2 src/OrcaMDF.Core/Engine/Pages/PrimaryRecordPage.cs
  39. +2 −2 src/OrcaMDF.Core/Engine/Pages/RecordPage.cs
  40. +2 −2 src/OrcaMDF.Core/Engine/Pages/SgamPage.cs
  41. +2 −2 src/OrcaMDF.Core/Engine/Pages/TextMixPage.cs
  42. +3 −3 src/OrcaMDF.Core/Engine/Records/LobStructures/BaseLobStructure.cs
  43. +2 −2 src/OrcaMDF.Core/Engine/Records/LobStructures/DataLobStructure.cs
  44. +4 −4 src/OrcaMDF.Core/Engine/Records/LobStructures/InternalLobStructure.cs
  45. +4 −4 src/OrcaMDF.Core/Engine/Records/LobStructures/LargeRootYukonLobStructure.cs
  46. +5 −5 src/OrcaMDF.Core/Engine/Records/LobStructures/LobStructureFactory.cs
  47. +2 −2 src/OrcaMDF.Core/Engine/Records/LobStructures/SmallRootLobStructure.cs
  48. +2 −2 src/OrcaMDF.Core/Engine/Records/PrimaryRecord.cs
  49. +2 −2 src/OrcaMDF.Core/Engine/Records/VariableLengthDataProxies/BlobInlineRootProxy.cs
  50. +2 −2 src/OrcaMDF.Core/Engine/Records/VariableLengthDataProxies/TextPointerProxy.cs
  51. +4 −4 src/OrcaMDF.Core/Engine/Scanner.cs
  52. +5 −5 src/OrcaMDF.Core/MetaData/DatabaseMetaData.cs
  53. +7 −0 src/OrcaMDF.Core/MetaData/ObjectDefinitions/ColumnDefinition.cs
  54. +7 −0 src/OrcaMDF.Core/MetaData/ObjectDefinitions/IndexDefinition.cs
  55. +11 −0 src/OrcaMDF.Core/MetaData/ObjectDefinitions/TableDefinition.cs
  56. +7 −1 src/OrcaMDF.Core/OrcaMDF.Core.csproj
View
@@ -3,4 +3,13 @@
- Support parsing of included columns
- Support sparse columns in indexes
-- Large (MAX) value support - hybrid overflow & LOB parsing
+- Large (MAX) value support - hybrid overflow & LOB parsing
+
+
+I nogle tilf�lde bliver dbi_dbname forkert idet man tilsyneladende ikke kan regne med at det termineres med 0x2000 � der m� v�re en l�ngde et eller andet sted idet SQL-server godt kan finde ud af det.
+Jeg kan godt genkende de ekstra tegn idet databasen sandsynligvis er rename�t fra lessor5 til hhv. kursus (og ikke kursus5) og demo (og ikke demoor5).
+
+Du har st�ende at FlagBits i PageHeader er en smallint og anvender ToInt16(), men i forhold til DBCC-output ser det ud til at det kun er en enkelt byte.
+
+Tilsvarende har jeg et problem med dbi_status i BootPage.
+Her ser det ud til at den ikke er en 4-byte int32 men kun 2 eller 3 bytes.
@@ -24,7 +24,7 @@ public static void Print(IEnumerable<Row> input)
foreach (var col in input.First().Columns)
{
- int maxPropValueLength = entities.Max(x => Math.Max(x[col].ToString().Length, 6));
+ int maxPropValueLength = entities.Max(x => Math.Max((x[col] ?? "").ToString().Length, 6));
maxPropValueLength = Math.Min(maxPropValueLength, 40);
@@ -8,12 +8,15 @@ class Program
static void Main()
{
Console.WriteLine("VSS Copying...");
- VssHelper.CopyFile(@"C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Test.mdf", @"C:\Test.mdf");
+ //VssHelper.CopyFile(@"C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Data1.mdf", @"C:\Data1.mdf");
Console.WriteLine();
- using (var file = new MdfFile(@"C:\Test.mdf"))
+ using (var db = new Database(new[] { @"C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MF1.mdf", @"C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MF2.ndf" }))
{
- file.GetGamPage(new PagePointer(1, 2));
+ var scanner = new DataScanner(db);
+
+ var result = scanner.ScanTable("X");
+ EntityPrinter.Print(result);
}
Console.WriteLine("Done");
@@ -11,9 +11,9 @@ public class DataScannerTests : SqlServerSystemTest
[Test]
public void ScanUniqueClusteredTable()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("UniqueClusteredTable").ToList();
Assert.AreEqual(112, rows[0].Field<int>("Num1"));
@@ -27,9 +27,9 @@ public void ScanUniqueClusteredTable()
[Test]
public void ScanNonUniqueClusteredTable()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NonUniqueClusteredTable").ToList();
Assert.AreEqual(112, rows[0].Field<int>("Num1"));
@@ -11,9 +11,9 @@ public class IndexScannerTests : SqlServerSystemTest
[Test]
public void ScanClusteredIndexOnUniqueClusteredTable()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new IndexScanner(mdf);
+ var scanner = new IndexScanner(db);
var result = scanner.ScanIndex("UniqueClusteredTable", "CX_Num1_Name").ToList();
Assert.AreEqual(112, result[0]["Num1"]);
@@ -26,9 +26,9 @@ public void ScanClusteredIndexOnUniqueClusteredTable()
[Test]
public void ScanNonclusteredIndexOnUniqueClusteredTable()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new IndexScanner(mdf);
+ var scanner = new IndexScanner(db);
var result = scanner.ScanIndex("UniqueClusteredTable", "IDX_Num1").ToList();
Assert.AreEqual(112, result[0]["Num1"]);
@@ -39,9 +39,9 @@ public void ScanNonclusteredIndexOnUniqueClusteredTable()
[Test]
public void ScanHeapAsIndex()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new IndexScanner(mdf);
+ var scanner = new IndexScanner(db);
var result = scanner.ScanIndex("Heap", null).ToList();
Assert.AreEqual(382, result[0]["Num1"]);
@@ -54,9 +54,9 @@ public void ScanHeapAsIndex()
[Test]
public void ScanNonclusteredIndexOnNonUniqueClusteredTable()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new IndexScanner(mdf);
+ var scanner = new IndexScanner(db);
var result = scanner.ScanIndex("NonUniqueClusteredTable", "IDX_Num1").ToList();
Assert.AreEqual(112, result[0]["Num1"]);
@@ -71,10 +71,10 @@ public void ScanNonclusteredIndexOnNonUniqueClusteredTable()
[Test]
public void ScanNonclusteredIndexOnHeap()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
// Index stored in sorted order
- var scanner = new IndexScanner(mdf);
+ var scanner = new IndexScanner(db);
var result = scanner.ScanIndex("Heap", "IDX_Num1").ToList();
Assert.AreEqual(112, result[0]["Num1"]);
@@ -85,7 +85,7 @@ public void ScanNonclusteredIndexOnHeap()
Assert.AreEqual(0, ((SlotPointer)result[1][DataColumn.RID]).SlotID);
// Data stored in insertion order
- var dataScanner = new DataScanner(mdf);
+ var dataScanner = new DataScanner(db);
var dataResult = dataScanner.ScanTable("Heap").ToList();
Assert.AreEqual(382, dataResult[0]["Num1"]);
@@ -10,9 +10,9 @@ public class RecordTests : SqlServerSystemTest
[Test]
public void RowOverflowPointer()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("RowOverflowPointer").ToList();
Assert.AreEqual(1, rows.Count);
@@ -11,9 +11,9 @@ public class DecimalTests : SqlServerSystemTest
[Test]
public void DecimalTest()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("DecimalTest").ToList();
Assert.AreEqual(12345m, rows[0].Field<decimal>("A"));
@@ -10,9 +10,9 @@ public class ForwardedRecordTests : SqlServerSystemTest
[Test]
public void HeapForwardedRecord()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("HeapForwardedRecord").ToList();
Assert.AreEqual(25, rows[0].Field<int>("A"));
@@ -11,9 +11,9 @@ public class ImageTests : SqlServerSystemTest
[Test]
public void ImageNull()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTestNull").ToList();
Assert.AreEqual(null, rows[0].Field<string>("A"));
@@ -23,9 +23,9 @@ public void ImageNull()
[Test]
public void ImageEmpty()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTestEmpty").ToList();
Assert.AreEqual("", rows[0].Field<byte[]>("A"));
@@ -35,9 +35,9 @@ public void ImageEmpty()
[Test]
public void Image64()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest64").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(64, 'A')), rows[0].Field<byte[]>("A"));
@@ -47,9 +47,9 @@ public void Image64()
[Test]
public void Image65()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest65").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(65, 'A')), rows[0].Field<byte[]>("A"));
@@ -59,9 +59,9 @@ public void Image65()
[Test]
public void Image8040()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest8040").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(8040, 'A')), rows[0].Field<byte[]>("A"));
@@ -71,9 +71,9 @@ public void Image8040()
[Test]
public void Image8041()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest8041").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(8041, 'A')), rows[0].Field<byte[]>("A"));
@@ -83,9 +83,9 @@ public void Image8041()
[Test]
public void Image40200()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest40200").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(40200, 'A')), rows[0].Field<byte[]>("A"));
@@ -95,9 +95,9 @@ public void Image40200()
[Test]
public void Image40201()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest40201").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(40201, 'A')), rows[0].Field<byte[]>("A"));
@@ -107,9 +107,9 @@ public void Image40201()
[Test]
public void Image20000000()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("ImageTest20000000").ToList();
Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(20000000, 'A')), rows[0].Field<byte[]>("A"));
@@ -10,9 +10,9 @@ public class NTextTests : SqlServerSystemTest
[Test]
public void NTextNull()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTestNull").ToList();
Assert.AreEqual(null, rows[0].Field<string>("A"));
@@ -22,9 +22,9 @@ public void NTextNull()
[Test]
public void NTextEmpty()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTestEmpty").ToList();
Assert.AreEqual("", rows[0].Field<string>("A"));
@@ -34,9 +34,9 @@ public void NTextEmpty()
[Test]
public void NText32()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest32").ToList();
Assert.AreEqual("".PadLeft(32, '\u040A'), rows[0].Field<string>("A"));
@@ -46,9 +46,9 @@ public void NText32()
[Test]
public void NText33()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest33").ToList();
Assert.AreEqual("".PadLeft(33, '\u040A'), rows[0].Field<string>("A"));
@@ -58,9 +58,9 @@ public void NText33()
[Test]
public void NText4020()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest4020").ToList();
Assert.AreEqual("".PadLeft(4020, '\u040A'), rows[0].Field<string>("A"));
@@ -70,9 +70,9 @@ public void NText4020()
[Test]
public void NText4021()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest4021").ToList();
Assert.AreEqual("".PadLeft(4021, '\u040A'), rows[0].Field<string>("A"));
@@ -82,9 +82,9 @@ public void NText4021()
[Test]
public void NText20100()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest20100").ToList();
Assert.AreEqual("".PadLeft(20100, '\u040A'), rows[0].Field<string>("A"));
@@ -94,9 +94,9 @@ public void NText20100()
[Test]
public void NText20101()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest20101").ToList();
Assert.AreEqual("".PadLeft(20101, '\u040A'), rows[0].Field<string>("A"));
@@ -106,9 +106,9 @@ public void NText20101()
[Test]
public void NText10000000()
{
- using (var mdf = new MdfFile(MdfPath))
+ using (var db = new Database(DataFilePaths))
{
- var scanner = new DataScanner(mdf);
+ var scanner = new DataScanner(db);
var rows = scanner.ScanTable("NTextTest10000000").ToList();
Assert.AreEqual("".PadLeft(10000000, '\u040A'), rows[0].Field<string>("A"));
Oops, something went wrong.

0 comments on commit 08cd6e7

Please sign in to comment.