pub struct LogFileHeader {
pub format_version: u32,
pub start_lsn: u64,
pub log_uuid: u32,
pub created_by: String,
}Expand description
Log file header (block 0 of the redo log file).
The header layout changed in MySQL 8.0.30 (format version 6):
| Offset | Pre-8.0.30 | 8.0.30+ (incl. 9.x) |
|---|---|---|
| 0 | group_id (u32) | format_version (u32) |
| 4 | start_lsn (u64) | log_uuid (u32) |
| 8 | (start_lsn cont.) | start_lsn (u64) |
| 12 | file_no (u32) | (start_lsn cont.) |
| 16 | created_by (32 bytes) | created_by (32 bytes) |
The format_version and group_id fields share offset 0; in practice,
format version values 1-6 are distinguishable from typical group IDs.
Fields§
§format_version: u32Log format version (offset 0).
In MySQL < 8.0.30 this was the log group ID. In 8.0.30+ this is the
format version number (e.g. 6 for MySQL 8.0.30+, 9.0, 9.1).
Aliased as group_id for backward compatibility.
start_lsn: u64Start LSN of this log file.
log_uuid: u32Log UUID (MySQL 8.0.30+) or 0 for older formats.
A 4-byte identifier for the data directory, stored at offset 4.
created_by: StringMySQL version string that created this log file (e.g. “MySQL 9.0.1”).
Implementations§
Source§impl LogFileHeader
impl LogFileHeader
Sourcepub fn group_id(&self) -> u32
pub fn group_id(&self) -> u32
Backward-compatible accessor: returns format_version as the group ID.
In MySQL < 8.0.30, offset 0 stored the log group ID. In 8.0.30+ it stores the format version. This accessor preserves API compatibility.
Sourcepub fn parse(block: &[u8]) -> Option<Self>
pub fn parse(block: &[u8]) -> Option<Self>
Parse a log file header from the first 512-byte block.
Handles both pre-8.0.30 and 8.0.30+ header layouts. The format is auto-detected: format version >= 6 indicates the 8.0.30+ layout where offset 4 is the log UUID and offset 8 is the start LSN. Versions 1-5 use the pre-8.0.30 layout where offset 4 is the start LSN (u64) and offset 12 is the file number.
§Examples
use idb::innodb::log::{LogFileHeader, LOG_BLOCK_SIZE,
LOG_HEADER_FORMAT, LOG_HEADER_START_LSN,
LOG_HEADER_LOG_UUID, LOG_HEADER_CREATED_BY};
use byteorder::{BigEndian, ByteOrder};
// MySQL 8.0.30+ / 9.x format (format_version = 6)
let mut block = vec![0u8; LOG_BLOCK_SIZE];
BigEndian::write_u32(&mut block[LOG_HEADER_FORMAT..], 6);
BigEndian::write_u32(&mut block[LOG_HEADER_LOG_UUID..], 0x12345678);
BigEndian::write_u64(&mut block[LOG_HEADER_START_LSN..], 0x1000);
block[LOG_HEADER_CREATED_BY..LOG_HEADER_CREATED_BY + 12]
.copy_from_slice(b"MySQL 9.0.1\0");
let hdr = LogFileHeader::parse(&block).unwrap();
assert_eq!(hdr.format_version, 6);
assert_eq!(hdr.start_lsn, 0x1000);
assert_eq!(hdr.log_uuid, 0x12345678);
assert_eq!(hdr.created_by, "MySQL 9.0.1");Trait Implementations§
Source§impl Clone for LogFileHeader
impl Clone for LogFileHeader
Source§fn clone(&self) -> LogFileHeader
fn clone(&self) -> LogFileHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogFileHeader
impl Debug for LogFileHeader
Auto Trait Implementations§
impl Freeze for LogFileHeader
impl RefUnwindSafe for LogFileHeader
impl Send for LogFileHeader
impl Sync for LogFileHeader
impl Unpin for LogFileHeader
impl UnsafeUnpin for LogFileHeader
impl UnwindSafe for LogFileHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more