Skip to content

Commit

Permalink
Expose a flags() method on RowsEventDate to read corresponding event …
Browse files Browse the repository at this point in the history
…flags
  • Loading branch information
rjobanp committed Mar 8, 2024
1 parent 48ed958 commit b2b2763
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/binlog/events/delete_rows_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -50,6 +50,11 @@ impl<'a> DeleteRowsEvent<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/delete_rows_event_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -49,6 +49,11 @@ impl<'a> DeleteRowsEventV1<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
17 changes: 15 additions & 2 deletions src/binlog/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ use std::{

use super::{
consts::{
BinlogChecksumAlg, BinlogVersion, EventFlags, EventType, UnknownChecksumAlg,
UnknownEventType,
BinlogChecksumAlg, BinlogVersion, EventFlags, EventType, RowsEventFlags,
UnknownChecksumAlg, UnknownEventType,
},
misc::LimitWrite,
BinlogCtx, BinlogEvent,
Expand Down Expand Up @@ -794,6 +794,19 @@ impl<'a> RowsEventData<'a> {
}
}

/// Returns event flags.
pub fn flags(&self) -> RowsEventFlags {
match self {
RowsEventData::WriteRowsEventV1(ev) => ev.flags(),
RowsEventData::UpdateRowsEventV1(ev) => ev.flags(),
RowsEventData::DeleteRowsEventV1(ev) => ev.flags(),
RowsEventData::WriteRowsEvent(ev) => ev.flags(),
RowsEventData::UpdateRowsEvent(ev) => ev.flags(),
RowsEventData::DeleteRowsEvent(ev) => ev.flags(),
RowsEventData::PartialUpdateRowsEvent(ev) => ev.flags(),
}
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
match self {
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/partial_update_rows_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -58,6 +58,11 @@ impl<'a> PartialUpdateRowsEvent<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
5 changes: 5 additions & 0 deletions src/binlog/events/rows_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ impl<'a> RowsEvent<'a> {
self.rows_data.as_bytes()
}

/// Returns the flags (unknown bits are truncated).
pub fn flags(&self) -> RowsEventFlags {
self.flags.get()
}

/// Returns length of this event in bytes.
///
/// This function will be used in `BinlogStruct` implementations for derived events.
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/update_rows_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -59,6 +59,11 @@ impl<'a> UpdateRowsEvent<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/update_rows_event_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -56,6 +56,11 @@ impl<'a> UpdateRowsEventV1<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/write_rows_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -51,6 +51,11 @@ impl<'a> WriteRowsEvent<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down
7 changes: 6 additions & 1 deletion src/binlog/events/write_rows_event_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{self};

use crate::{
binlog::{
consts::{BinlogVersion, EventType},
consts::{BinlogVersion, EventType, RowsEventFlags},
BinlogCtx, BinlogEvent, BinlogStruct,
},
io::ParseBuf,
Expand Down Expand Up @@ -49,6 +49,11 @@ impl<'a> WriteRowsEventV1<'a> {
self.0.rows_data()
}

/// Returns row flags.
pub fn flags(&'a self) -> RowsEventFlags {
self.0.flags()
}

/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))
Expand Down

0 comments on commit b2b2763

Please sign in to comment.