pub struct LogBlockHeader {
pub block_no: u32,
pub flush_flag: bool,
pub data_len: u16,
pub first_rec_group: u16,
pub epoch_no: u32,
}Expand description
Log block header (first 12 bytes of each 512-byte block).
The block header layout is consistent across MySQL versions:
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | Block number (bit 31 = flush flag) |
| 4 | 2 | Data length (including header bytes) |
| 6 | 2 | First record group offset |
| 8 | 4 | Epoch number (called checkpoint_no in older versions) |
In MySQL < 8.0.30, the header was 14 bytes with 2 extra bytes at offset 12-13 that were part of the checkpoint number. In 8.0.30+ the header is 12 bytes and offset 8 stores the epoch number.
Fields§
§block_no: u32Block number (with flush bit masked out).
flush_flag: boolWhether this block was the first in a flush batch (bit 31).
data_len: u16Number of bytes of log data in this block (including header).
first_rec_group: u16Offset of the first log record group starting in this block.
epoch_no: u32Epoch number (MySQL 8.0.30+) or checkpoint number (older versions).
In MySQL 8.0.30+ and 9.x, this field stores the epoch number used for log block validation. In older versions, it was the checkpoint sequence number.
Implementations§
Source§impl LogBlockHeader
impl LogBlockHeader
Sourcepub fn parse(block: &[u8]) -> Option<Self>
pub fn parse(block: &[u8]) -> Option<Self>
Parse a log block header from a 512-byte block.
§Examples
use idb::innodb::log::{LogBlockHeader, LOG_BLOCK_HDR_SIZE};
use byteorder::{BigEndian, ByteOrder};
let mut block = vec![0u8; LOG_BLOCK_HDR_SIZE];
BigEndian::write_u32(&mut block[0..], 0x80000005); // flush bit + block_no=5
BigEndian::write_u16(&mut block[4..], 200); // data_len
BigEndian::write_u16(&mut block[6..], 14); // first_rec_group
BigEndian::write_u32(&mut block[8..], 3); // epoch_no
let hdr = LogBlockHeader::parse(&block).unwrap();
assert_eq!(hdr.block_no, 5);
assert!(hdr.flush_flag);
assert_eq!(hdr.data_len, 200);
assert_eq!(hdr.first_rec_group, 14);
assert_eq!(hdr.epoch_no, 3);
assert!(hdr.has_data());Sourcepub fn checkpoint_no(&self) -> u32
pub fn checkpoint_no(&self) -> u32
Backward-compatible accessor: returns epoch_no as the checkpoint number.
In MySQL < 8.0.30, offset 8 stored the checkpoint number. In 8.0.30+ it stores the epoch number. This accessor preserves API compatibility.
Trait Implementations§
Source§impl Clone for LogBlockHeader
impl Clone for LogBlockHeader
Source§fn clone(&self) -> LogBlockHeader
fn clone(&self) -> LogBlockHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogBlockHeader
impl Debug for LogBlockHeader
Auto Trait Implementations§
impl Freeze for LogBlockHeader
impl RefUnwindSafe for LogBlockHeader
impl Send for LogBlockHeader
impl Sync for LogBlockHeader
impl Unpin for LogBlockHeader
impl UnsafeUnpin for LogBlockHeader
impl UnwindSafe for LogBlockHeader
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