1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//! CLI subcommand implementations for the `inno` binary.
//!
//! The `inno` binary provides twenty subcommands for analyzing InnoDB data files,
//! redo logs, and system tablespaces. CLI argument parsing uses clap derive macros,
//! with the top-level [`app::Cli`] struct and [`app::Commands`] enum defined in
//! [`app`] and shared between `main.rs` and `build.rs` (for man page generation)
//! via `include!()`.
//!
//! Each subcommand module follows the same pattern: an `Options` struct holding
//! the parsed arguments and a `pub fn execute(opts, writer) -> Result<(), IdbError>`
//! entry point. The `writer: &mut dyn Write` parameter allows output to be
//! captured in tests or redirected to a file via the global `--output` flag.
//!
//! # Subcommands
//!
//! | Command | Module | Purpose |
//! |---------|--------|---------|
//! | `inno parse` | [`parse`] | Parse FIL headers for every page and show a page-type summary table |
//! | `inno pages` | [`pages`] | Deep structure analysis of INDEX, UNDO, BLOB/LOB, and SDI pages |
//! | `inno dump` | [`dump`] | Hex dump of raw bytes by page number or absolute file offset |
//! | `inno checksum` | [`checksum`] | Validate CRC-32C and legacy InnoDB checksums for every page |
//! | `inno diff` | [`diff`] | Compare two tablespace files page-by-page and report differences |
//! | `inno watch` | [`watch`] | Monitor a tablespace file for page-level changes in real time |
//! | `inno corrupt` | [`corrupt`] | Inject random bytes into a page for testing recovery workflows |
//! | `inno recover` | [`recover`] | Assess page-level recoverability and count salvageable records |
//! | `inno repair` | [`repair`] | Recalculate and fix corrupt page checksums |
//! | `inno find` | [`find`] | Search a MySQL data directory for pages matching a page number |
//! | `inno tsid` | [`tsid`] | List or look up tablespace (space) IDs across `.ibd`/`.ibu` files |
//! | `inno sdi` | [`sdi`] | Extract SDI metadata (MySQL 8.0+ serialized data dictionary) |
//! | `inno schema` | [`schema`] | Extract schema and reconstruct DDL from tablespace metadata |
//! | `inno export` | [`export`] | Export record-level data from INDEX pages as CSV, JSON, or hex |
//! | `inno health` | [`health`] | Per-index B+Tree health metrics (fill factor, fragmentation, garbage) |
//! | `inno log` | [`log`] | Analyze redo log file headers, checkpoints, and data blocks |
//! | `inno info` | [`info`] | Inspect `ibdata1`, compare LSNs, or query a live MySQL instance |
//! | `inno defrag` | [`defrag`] | Defragment a tablespace by reclaiming free space and reordering pages |
//! | `inno transplant` | [`transplant`] | Copy specific pages from a donor tablespace into a target |
//! | `inno audit` | [`audit`] | Audit a data directory for integrity, health, or corrupt pages |
//! | `inno completions` | — | Generate shell completion scripts for bash, zsh, fish, or powershell |
//!
//! # Common patterns
//!
//! - **`--json`** — Every subcommand supports structured JSON output via
//! `#[derive(Serialize)]` structs and `serde_json`.
//! - **`--page-size`** — Override auto-detected page size (useful for non-standard
//! 4K, 8K, 32K, or 64K tablespaces).
//! - **`--verbose` / `-v`** — Show additional detail such as per-page checksum
//! status, FSEG internals, or MLOG record types.
//! - **`--color`** (global) — Control colored terminal output (`auto`, `always`,
//! `never`).
//! - **`--output` / `-o`** (global) — Redirect output to a file instead of stdout.
//!
//! Progress bars (via [`indicatif`]) are displayed for long-running operations
//! in `parse`, `checksum`, `find`, and `audit`. The `wprintln!` and `wprint!` macros
//! wrap `writeln!`/`write!` to convert `io::Error` into `IdbError`.
/// Write a line to the given writer, converting io::Error to IdbError.
pub use wprint;
pub use wprintln;
/// Escape a string value for CSV output.
///
/// If the value contains a comma, double-quote, or newline, it is enclosed
/// in double-quotes with internal double-quotes doubled. Otherwise the value
/// is returned as-is.
pub
use crateDecryptionContext;
use crateKeyring;
use crateTablespace;
use crateIdbError;
use ;
/// Open a tablespace file, selecting mmap or buffered I/O based on the flag.
///
/// When `use_mmap` is true, the file is memory-mapped via `mmap(2)` for
/// potentially better performance on large files (especially with parallel
/// processing). When `page_size` is `Some`, auto-detection is bypassed.
pub
/// Set up decryption on a tablespace if a keyring path is provided.
///
/// Loads the keyring file, reads the encryption info from page 0,
/// decrypts the tablespace key, and installs the decryption context
/// on the tablespace for transparent page decryption.
pub
/// Create a styled progress bar for iterating over pages or files.
pub