|
1 | 1 | # FirebirdRepairBase |
2 | | -Program for analize and repare broken firebird database, it is working on the low level |
3 | | -This is dirty version of program, now program is in develop process. |
4 | | - |
5 | | -Now it features: |
6 | | -* check database pages by type |
7 | | -* replace some header page params |
8 | | -* set READ ONLY and FORCE WRITE flags |
9 | | -* replace check sum on pages |
10 | | -* generate new page |
11 | | - |
12 | | -# In developing |
13 | | -* Analisys pages, pump data. |
14 | | -* Analisys TIP sequence, generate lost TIP pages |
15 | | - |
16 | | -# Firebird Database Pages |
17 | | -* Database Header Page |
18 | | -* Page Inventory Page (PIP) |
19 | | -* Transaction Inventory Page (TIP) |
20 | | -* Pointer Page |
21 | | -* Data Page |
22 | | -* Index Root Page |
23 | | -* Index B-Tree Page |
24 | | -* Blob Data Page |
25 | | -* Generator Page |
26 | | -* Write Ahead Log Page |
| 2 | + |
| 3 | +A low-level tool for analyzing and potentially recovering data from **broken** Firebird database files (`.fdb`, `.gdb`). It bypasses the standard Firebird engine to read raw page structures and data. |
| 4 | + |
| 5 | +**Warning:** This is a **development version**. It directly manipulates database files. Always create a **backup** of your database before using this tool. Use at your own risk. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +* **Database Structure Analysis:** |
| 10 | + * Opens and reads Firebird database files. |
| 11 | + * Identifies and counts pages by type (Header, PIP, TIP, Pointer, Data, Index Root/BTree, Blob, Generator, WAL). |
| 12 | + * Displays basic page information (number, type, checksum, relation ID). |
| 13 | +* **Header Manipulation:** |
| 14 | + * Reads and interprets database header flags. |
| 15 | + * Allows setting/clearing specific flags (e.g., Read Only, Force Write). |
| 16 | +* **Page Content Inspection:** |
| 17 | + * Reads specific pages by number. |
| 18 | + * Extracts and displays raw record fragments from Data Pages. |
| 19 | + * Allows changing page type and checksum (Dangerous!). |
| 20 | +* **Transaction Analysis:** |
| 21 | + * Reads Transaction Inventory Pages (TIP). |
| 22 | + * Counts transactions by state (Active, Limbo, Dead, Committed). |
| 23 | +* **Basic Data Recovery:** |
| 24 | + * Extracts raw data fragments from Data Pages. |
| 25 | + * *(WIP)* Basic MVCC (Multi-Version Concurrency Control) awareness for data visibility (see TODO). |
| 26 | + * *(New)* Parses basic record headers to identify deleted records and data length. |
| 27 | +* **Record Fragment Parsing:** |
| 28 | + * Introduces `uRecordParser` module for analyzing individual record fragments. |
| 29 | + * Extracts key information like transaction ID, back pointer, flags, and data length from the record header. |
| 30 | + |
| 31 | +## In Development (TODO) |
| 32 | + |
| 33 | +* **Advanced Data Recovery:** |
| 34 | + * Implement full MVCC logic to reconstruct the correct, visible version of records based on transaction states and TIP page data. |
| 35 | + * Export recovered data to a new, valid Firebird database or other formats (e.g., CSV). |
| 36 | + * Analyze and potentially repair B-Tree index structures. |
| 37 | + * Analyze and potentially repair Blob page chains. |
| 38 | +* **Deeper Integrity Checks:** |
| 39 | + * Verify logical links between pages (e.g., Pointer Pages -> Data Pages, Record Back Pointers). |
| 40 | + * Identify orphaned pages. |
| 41 | +* **Page Generation/Repair:** |
| 42 | + * Implement logic to generate missing TIP or PIP pages if necessary. |
| 43 | + * Attempt to rebuild damaged page structures. |
| 44 | +* **User Interface Improvements:** |
| 45 | + * Add search functionality within page data. |
| 46 | + * Provide more detailed views for different page types (B-Tree keys, Blob data). |
| 47 | + * Add a 'Restore from Backup' feature. |
| 48 | + * Improve error handling and user feedback. |
| 49 | + |
| 50 | +## Supported Firebird Pages |
| 51 | + |
| 52 | +* Database Header Page |
| 53 | +* Page Inventory Page (PIP) |
| 54 | +* Transaction Inventory Page (TIP) |
| 55 | +* Pointer Page |
| 56 | +* Data Page |
| 57 | +* Index Root Page |
| 58 | +* Index B-Tree Page |
| 59 | +* Blob Data Page |
| 60 | +* Generator Page |
| 61 | +* Write Ahead Log Page (WAL) (Note: WAL functionality might be limited) |
| 62 | + |
| 63 | +## Technical Details |
| 64 | + |
| 65 | +* **Language:** Pascal (Delphi). |
| 66 | +* **Target:** Windows. |
| 67 | +* **Approach:** Direct file I/O, parsing raw page structures according to Firebird Internal Format documentation (`fbint-page-1.html`) and Firebird source code conventions. |
| 68 | +* **Modules:** |
| 69 | + * `uStructs`: Core data structures (TPag, THdr, etc.). |
| 70 | + * `uPageAnalyzer`: General page reading and type identification. |
| 71 | + * `uDataPage`: Data Page header parsing and record fragment extraction. |
| 72 | + * `uTipPage`: TIP page header parsing and transaction state analysis. |
| 73 | + * `uBtreePage`: B-Tree page header parsing and key extraction. |
| 74 | + * `uRecordParser`: *(New)* Parses headers of individual record fragments. |
| 75 | + * `uDatabaseStats`: Aggregates statistics using `uPageAnalyzer`. |
| 76 | + * `uFlagManager`: Manages database header flags. |
27 | 77 |
|
28 | 78 | ## License |
29 | | -MIT: |
| 79 | + |
| 80 | +MIT |
30 | 81 |
|
31 | 82 | ## Author |
| 83 | + |
32 | 84 | Gordienko Roman |
0 commit comments