Rust parser for the mdf file format used by Microsoft SQL Server.
- low level parsing of pages and records
- parsing of system tables
- parsing of existing tables
- parsing of table schema
- reading table rows
- reading LOB data storage
- larger than memory files
- data recovery from broken files
- supported datatypes
tinyint,smallint,int,bigintbinary(n),char(n),nchar(n)varbinary(n),varchar(n),nvarcharbitsqlvariantsysnamedatetime,smalldatetimeuniqueidentifierimagentextfloat
This crate provides only parsing functionality, for flexibility all pages have to be provided by implementing the PageProvider trait.
You can find a example implementation for reading directly from Microsoft SQL Server backup files in the mtf crate.
Access on the Page and Record level is available from the PageProvider::get and the RawPage::records API.
The system tables are parsed by DB::new and then used to provide a list of existing Tables with DB::tables.
The rows of a Table can be read using Table::rows and basic data recovery can be performed using Table::scan_db.
Included are additionally three examples:
lob_dumperscans the whole database for rows entries stored as LOB data and dumps them into files.p_min_len_dumperperforms a basic for of data recovery by using thep_min_lenfield ofPages to associate eachPagein the database with its correspondingTable.sharepoint_dumpdumps all files stored in a sharepoint database to disk, extracting the names / paths from theAllDocstable and their content fromAllDocStreams.
I was very delighted to find a existing implementation of a mdf file format parser at https://gitlab.com/schrieveslaach/oxidized-mdf, however in the end
I decided to implement a version myself due to multiple reasons:
oxidized-mdfcontains multiple subtle errors, finding them all might be hardoxidized-mdfis unsuitable for larger than memory files as is- implementing a async interface as
oxidized-mdfstrives do to is hard while supporting larger than memory files
The documentation of the mdf format from the following sources was used:
[1] https://github.com/improvedk/OrcaMDF
[2] https://www.sqlskills.com/blogs/paul/category/inside-the-storage-engine/