Skip to main content

LogFileHeader

Struct LogFileHeader 

Source
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):

OffsetPre-8.0.308.0.30+ (incl. 9.x)
0group_id (u32)format_version (u32)
4start_lsn (u64)log_uuid (u32)
8(start_lsn cont.)start_lsn (u64)
12file_no (u32)(start_lsn cont.)
16created_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: u32

Log 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: u64

Start LSN of this log file.

§log_uuid: u32

Log UUID (MySQL 8.0.30+) or 0 for older formats.

A 4-byte identifier for the data directory, stored at offset 4.

§created_by: String

MySQL version string that created this log file (e.g. “MySQL 9.0.1”).

Implementations§

Source§

impl LogFileHeader

Source

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.

Source

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

Source§

fn clone(&self) -> LogFileHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogFileHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for LogFileHeader

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V