Skip to content

Commit b2b2763

Browse files
committed
Expose a flags() method on RowsEventDate to read corresponding event flags
1 parent 48ed958 commit b2b2763

9 files changed

+62
-9
lines changed

src/binlog/events/delete_rows_event.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -50,6 +50,11 @@ impl<'a> DeleteRowsEvent<'a> {
5050
self.0.rows_data()
5151
}
5252

53+
/// Returns row flags.
54+
pub fn flags(&'a self) -> RowsEventFlags {
55+
self.0.flags()
56+
}
57+
5358
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
5459
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
5560
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/delete_rows_event_v1.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -49,6 +49,11 @@ impl<'a> DeleteRowsEventV1<'a> {
4949
self.0.rows_data()
5050
}
5151

52+
/// Returns row flags.
53+
pub fn flags(&'a self) -> RowsEventFlags {
54+
self.0.flags()
55+
}
56+
5257
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
5358
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
5459
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/mod.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use std::{
5353

5454
use super::{
5555
consts::{
56-
BinlogChecksumAlg, BinlogVersion, EventFlags, EventType, UnknownChecksumAlg,
57-
UnknownEventType,
56+
BinlogChecksumAlg, BinlogVersion, EventFlags, EventType, RowsEventFlags,
57+
UnknownChecksumAlg, UnknownEventType,
5858
},
5959
misc::LimitWrite,
6060
BinlogCtx, BinlogEvent,
@@ -794,6 +794,19 @@ impl<'a> RowsEventData<'a> {
794794
}
795795
}
796796

797+
/// Returns event flags.
798+
pub fn flags(&self) -> RowsEventFlags {
799+
match self {
800+
RowsEventData::WriteRowsEventV1(ev) => ev.flags(),
801+
RowsEventData::UpdateRowsEventV1(ev) => ev.flags(),
802+
RowsEventData::DeleteRowsEventV1(ev) => ev.flags(),
803+
RowsEventData::WriteRowsEvent(ev) => ev.flags(),
804+
RowsEventData::UpdateRowsEvent(ev) => ev.flags(),
805+
RowsEventData::DeleteRowsEvent(ev) => ev.flags(),
806+
RowsEventData::PartialUpdateRowsEvent(ev) => ev.flags(),
807+
}
808+
}
809+
797810
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
798811
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
799812
match self {

src/binlog/events/partial_update_rows_event.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -58,6 +58,11 @@ impl<'a> PartialUpdateRowsEvent<'a> {
5858
self.0.rows_data()
5959
}
6060

61+
/// Returns row flags.
62+
pub fn flags(&'a self) -> RowsEventFlags {
63+
self.0.flags()
64+
}
65+
6166
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
6267
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
6368
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/rows_event.rs

+5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ impl<'a> RowsEvent<'a> {
124124
self.rows_data.as_bytes()
125125
}
126126

127+
/// Returns the flags (unknown bits are truncated).
128+
pub fn flags(&self) -> RowsEventFlags {
129+
self.flags.get()
130+
}
131+
127132
/// Returns length of this event in bytes.
128133
///
129134
/// This function will be used in `BinlogStruct` implementations for derived events.

src/binlog/events/update_rows_event.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -59,6 +59,11 @@ impl<'a> UpdateRowsEvent<'a> {
5959
self.0.rows_data()
6060
}
6161

62+
/// Returns row flags.
63+
pub fn flags(&'a self) -> RowsEventFlags {
64+
self.0.flags()
65+
}
66+
6267
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
6368
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
6469
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/update_rows_event_v1.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -56,6 +56,11 @@ impl<'a> UpdateRowsEventV1<'a> {
5656
self.0.rows_data()
5757
}
5858

59+
/// Returns row flags.
60+
pub fn flags(&'a self) -> RowsEventFlags {
61+
self.0.flags()
62+
}
63+
5964
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
6065
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
6166
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/write_rows_event.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -51,6 +51,11 @@ impl<'a> WriteRowsEvent<'a> {
5151
self.0.rows_data()
5252
}
5353

54+
/// Returns row flags.
55+
pub fn flags(&'a self) -> RowsEventFlags {
56+
self.0.flags()
57+
}
58+
5459
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
5560
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
5661
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

src/binlog/events/write_rows_event_v1.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::{self};
1212

1313
use crate::{
1414
binlog::{
15-
consts::{BinlogVersion, EventType},
15+
consts::{BinlogVersion, EventType, RowsEventFlags},
1616
BinlogCtx, BinlogEvent, BinlogStruct,
1717
},
1818
io::ParseBuf,
@@ -49,6 +49,11 @@ impl<'a> WriteRowsEventV1<'a> {
4949
self.0.rows_data()
5050
}
5151

52+
/// Returns row flags.
53+
pub fn flags(&'a self) -> RowsEventFlags {
54+
self.0.flags()
55+
}
56+
5257
/// Returns an iterator over event's rows given the corresponding `TableMapEvent`.
5358
pub fn rows(&'a self, table_map_event: &'a TableMapEvent<'a>) -> RowsEventRows<'a> {
5459
RowsEventRows::new(&self.0, table_map_event, ParseBuf(self.rows_data()))

0 commit comments

Comments
 (0)