Skip to content

Commit 52a9f9c

Browse files
authored
Merge pull request #175 from blackbeam/v0.36.0-release
v0.36.0 release
2 parents 1f45cf2 + 6427e7f commit 52a9f9c

21 files changed

Lines changed: 242 additions & 270 deletions

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords = ["mysql", "database"]
1313
categories = ["database"]
1414

1515
# * Invoke `cargo readme > README.md` if relevant!
16-
version = "0.35.5"
16+
version = "0.36.0"
1717

1818
edition = "2024"
1919
exclude = [
@@ -61,7 +61,7 @@ serde = { version = "1", features = ["derive"] }
6161
serde_json = "1"
6262

6363
mysql-common-derive = { path = "derive", version = "0.32.0", optional = true }
64-
btoi = "0.4.3"
64+
btoi = "0.5"
6565
zstd = { version = "0.13", optional = true }
6666

6767
[dev-dependencies]
@@ -70,7 +70,7 @@ proptest = "1.0"
7070
unic-langid = { version = "0.9.4" }
7171

7272
[build-dependencies]
73-
bindgen = { version = "0.71", default-features = false, features = [
73+
bindgen = { version = "0.72", default-features = false, features = [
7474
"runtime",
7575
], optional = true }
7676
cc = { version = "1.0", optional = true }

src/binlog/events/format_description_event.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ define_const!(
3838

3939
/// A format description event is the first event of a binlog for binlog-version 4.
4040
///
41-
/// It describes how the other events are layed out.
41+
/// It describes how other events are laid out.
4242
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
4343
pub struct FormatDescriptionEvent<'a> {
4444
/// Version of this binlog format.
4545
binlog_version: Const<BinlogVersion, LeU16>,
4646
/// Version of the MySQL Server that created the binlog (len=50).
4747
///
48-
/// The string is evaluted to apply work-arounds in the slave.
48+
/// The string is evaluated to apply workarounds in the slave.
4949
server_version: RawBytes<'a, FixedLengthText<{ SERVER_VER_LEN }>>,
5050
/// Seconds since Unix epoch when the binlog was created.
5151
create_timestamp: RawInt<LeU32>,
52-
/// Event header length. Aloway `19`.
52+
/// Event header length. Always `19`.
5353
event_header_length: EventHeaderLength,
5454
/// An array indexed by Binlog Event Type - 1 to extract the length of the event specific
5555
/// header.
5656
///
5757
/// Use [`Self::get_event_type_header_length`] to get header length for particular event type.
5858
event_type_header_lengths: RawBytes<'a, EofBytes>,
59-
/// This event structure also stores a footer containig checksum algorithm description.
59+
/// This event structure also stores a footer containing checksum algorithm description.
6060
///
6161
/// # Note
6262
///
63-
/// Footer must be assigned manualy after `Self::read`
63+
/// Footer must be assigned manually after `Self::read`
6464
footer: BinlogEventFooter,
6565
}
6666

@@ -236,7 +236,7 @@ impl<'a> FormatDescriptionEvent<'a> {
236236
.as_bytes()
237237
.get(usize::from(event_type as u8).saturating_sub(1))
238238
.copied()
239-
.unwrap_or_else(|| match event_type {
239+
.unwrap_or(match event_type {
240240
EventType::UNKNOWN_EVENT => 0,
241241
EventType::START_EVENT_V3 => Self::START_V3_HEADER_LEN,
242242
EventType::QUERY_EVENT => Self::QUERY_HEADER_LEN,

src/binlog/events/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use std::{
4848
borrow::Cow,
4949
cmp::min,
5050
io::{self, Read, Write},
51-
u16,
5251
};
5352

5453
use super::{
@@ -245,13 +244,10 @@ impl Event {
245244

246245
// it is an error if the `event_data` isn't fully consumed
247246
if !event_data.is_empty() {
248-
return Err(io::Error::new(
249-
io::ErrorKind::Other,
250-
format!(
251-
"bytes remaining on stream while reading {}",
252-
type_name::<T>()
253-
),
254-
));
247+
return Err(io::Error::other(format!(
248+
"bytes remaining on stream while reading {}",
249+
type_name::<T>()
250+
)));
255251
}
256252

257253
Ok(event)

src/binlog/events/rows_event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'a> RowsEvent<'a> {
145145
len += S(2); // extra-data len
146146
len += S(min(self.extra_data.len(), u16::MAX as usize - 2)); // extra data
147147
len += S(crate::misc::lenenc_int_len(self.num_columns()) as usize); // number of columns
148-
let bitmap_len = (self.num_columns() as usize + 7) / 8;
148+
let bitmap_len = self.num_columns().div_ceil(8) as usize;
149149
if self.columns_before_image.is_some() {
150150
len += S(bitmap_len); // columns present bitmap 1
151151
}
@@ -229,7 +229,7 @@ impl<'de> MyDeserialize<'de> for RowsEvent<'de> {
229229
};
230230

231231
let num_columns: RawInt<LenEnc> = buf.parse(())?;
232-
let bitmap_len = (num_columns.0 as usize + 7) / 8;
232+
let bitmap_len = num_columns.0.div_ceil(8) as usize;
233233

234234
let mut columns_before_image = None;
235235
let mut columns_after_image = None;

src/binlog/events/table_map_event.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'a> TableMapEvent<'a> {
9393
self.columns_count.0
9494
}
9595

96-
/// Ruturns a number of JSON columns.
96+
/// Returns a number of JSON columns.
9797
pub fn json_column_count(&self) -> usize {
9898
self.columns_type
9999
.0
@@ -265,7 +265,7 @@ impl<'de> MyDeserialize<'de> for TableMapEvent<'de> {
265265
let columns_count: RawInt<LenEnc> = buf.parse(())?;
266266
let columns_type = buf.parse(columns_count.0 as usize)?;
267267
let columns_metadata = buf.parse(())?;
268-
let null_bitmask = buf.parse(((columns_count.0 + 7) / 8) as usize)?;
268+
let null_bitmask = buf.parse(columns_count.0.div_ceil(8) as usize)?;
269269
let optional_metadata = buf.parse(())?;
270270

271271
Ok(TableMapEvent {
@@ -328,8 +328,8 @@ impl<'a> BinlogStruct<'a> for TableMapEvent<'a> {
328328

329329
/// Optional metadata field that contains charsets for columns.
330330
///
331-
/// - contains charsets for caracter columns if it's a [`OptionalMetadataField::DefaultCharset`];
332-
/// contains charsets for ENUM and SET columns if it's a
331+
/// * contains charsets for character columns if it's a [`OptionalMetadataField::DefaultCharset`];
332+
/// * contains charsets for ENUM and SET columns if it's a
333333
/// [`OptionalMetadataField::EnumAndSetDefaultCharset`].
334334
#[derive(Debug, Clone, Eq, PartialEq)]
335335
pub struct DefaultCharset<'a> {
@@ -449,8 +449,8 @@ impl MySerialize for NonDefaultCharset {
449449

450450
/// Contains charset+collation for column.
451451
///
452-
/// - contains charsets for caracter columns if it's a [`OptionalMetadataField::ColumnCharset`];
453-
/// contains charsets for ENUM and SET columns if it's a
452+
/// * contains charsets for character columns if it's a [`OptionalMetadataField::ColumnCharset`];
453+
/// * contains charsets for ENUM and SET columns if it's a
454454
/// [`OptionalMetadataField::EnumAndSetColumnCharset`].
455455
#[derive(Debug, Clone, Eq, PartialEq)]
456456
pub struct ColumnCharsets<'a> {
@@ -1215,7 +1215,7 @@ pub struct OptionalMetadataIter<'a> {
12151215

12161216
impl<'a> OptionalMetadataIter<'a> {
12171217
/// Reads type-length-value value.
1218-
fn read_tlv(&mut self) -> io::Result<(RawConst<u8, OptionalMetadataFieldType>, &'a [u8])> {
1218+
fn read_tlv(&mut self) -> io::Result<(u8, &'a [u8])> {
12191219
let t = self.data.read_u8()?;
12201220
// The length is encoded in 1, 3 or 8 bytes (https://github.com/mysql/mysql-server/blob/824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/libs/mysql/binlog/event/binlog_event.h#L812)
12211221
let l = self.data.read_lenenc_int()? as usize;
@@ -1230,13 +1230,11 @@ impl<'a> OptionalMetadataIter<'a> {
12301230
}
12311231
};
12321232
self.data = &self.data[l..];
1233-
Ok((RawConst::new(t), v))
1233+
Ok((t, v))
12341234
}
12351235

12361236
/// Returns next tlv, if any.
1237-
fn next_tlv(
1238-
&mut self,
1239-
) -> Option<io::Result<(RawConst<u8, OptionalMetadataFieldType>, &'a [u8])>> {
1237+
fn next_tlv(&mut self) -> Option<io::Result<(u8, &'a [u8])>> {
12401238
if self.data.is_empty() {
12411239
return None;
12421240
}
@@ -1266,19 +1264,17 @@ impl<'a> Iterator for OptionalMetadataIter<'a> {
12661264

12671265
self.next_tlv()?
12681266
.and_then(|(t, v)| {
1267+
let t = RawConst::<u8, OptionalMetadataFieldType>::new(t);
12691268
let mut v = ParseBuf(v);
12701269
match t.get() {
12711270
Ok(t) => match t {
12721271
SIGNEDNESS => {
12731272
let num_numeric = self.count_columns(ColumnType::is_numeric_type);
1274-
let num_flags_bytes = (num_numeric + 7) / 8;
1273+
let num_flags_bytes = num_numeric.div_ceil(8);
12751274
let flags: &[u8] = v.parse(num_flags_bytes)?;
12761275

12771276
if !v.is_empty() {
1278-
return Err(io::Error::new(
1279-
io::ErrorKind::Other,
1280-
"bytes remaining on stream",
1281-
));
1277+
return Err(io::Error::other("bytes remaining on stream"));
12821278
}
12831279

12841280
let flags = BitSlice::from_slice(flags);
@@ -1304,14 +1300,11 @@ impl<'a> Iterator for OptionalMetadataIter<'a> {
13041300
}
13051301
COLUMN_VISIBILITY => {
13061302
let num_columns = self.num_columns();
1307-
let num_flags_bytes = (num_columns + 7) / 8;
1303+
let num_flags_bytes = num_columns.div_ceil(8);
13081304
let flags: &[u8] = v.parse(num_flags_bytes)?;
13091305

13101306
if !v.is_empty() {
1311-
return Err(io::Error::new(
1312-
io::ErrorKind::Other,
1313-
"bytes remaining on stream",
1314-
));
1307+
return Err(io::Error::other("bytes remaining on stream"));
13151308
}
13161309

13171310
let flags = BitSlice::from_slice(flags);
@@ -1453,7 +1446,7 @@ impl<'a> OptionalMetaExtractor<'a> {
14531446
///
14541447
/// Returns peekable iterator so that it is possible to observe next PK index.
14551448
///
1456-
/// Emits nothing if there are no PK data in the optinal metadata.
1449+
/// Emits nothing if there are no PK data in the optional metadata.
14571450
pub fn iter_primary_key(&'a self) -> Peekable<impl Iterator<Item = io::Result<u64>> + 'a> {
14581451
let simple = self
14591452
.simple_primary_key

src/binlog/events/transaction_payload_event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl io::BufRead for TransactionPayloadReader<'_> {
8080
}
8181
}
8282

83-
/// Wraps the data providing [`io::BufRead`] implementaion.
83+
/// Wraps the data providing [`io::BufRead`] implementation.
8484
enum TransactionPayloadInner<'a> {
8585
Uncompressed(&'a [u8]),
8686
ZstdCompressed(BufReader<zstd::Decoder<'a, &'a [u8]>>),
@@ -209,7 +209,7 @@ impl<'a> TransactionPayloadEvent<'a> {
209209
));
210210
}
211211

212-
return TransactionPayloadReader::new_zstd(self.payload_raw());
212+
TransactionPayloadReader::new_zstd(self.payload_raw())
213213
}
214214

215215
/// Decompress the whole payload.

src/binlog/jsonb.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,15 +792,14 @@ impl<'a> Value<'a> {
792792
)))
793793
}
794794
ColumnType::MYSQL_TYPE_TIME => {
795-
let packed_value = dbg!(opaque_value.data_raw())
796-
.first_chunk::<8>()
797-
.ok_or_else(|| {
795+
let packed_value =
796+
opaque_value.data_raw().first_chunk::<8>().ok_or_else(|| {
798797
io::Error::new(
799798
io::ErrorKind::InvalidData,
800799
"not enough data to decode MYSQL_TYPE_TIME",
801800
)
802801
})?;
803-
let packed_value = dbg!(i64::from_le_bytes(*packed_value));
802+
let packed_value = i64::from_le_bytes(*packed_value);
804803
Ok(JsonDom::Scalar(JsonScalar::DateTime(
805804
MysqlTime::from_int64_time_packed(packed_value),
806805
)))

0 commit comments

Comments
 (0)