Skip to content

Commit 580b8df

Browse files
Merge branch 'launchbadge:main' into main
2 parents 5627ca8 + e283bf9 commit 580b8df

File tree

20 files changed

+303
-9
lines changed

20 files changed

+303
-9
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ _unstable-all-types = [
6868
"json",
6969
"time",
7070
"chrono",
71+
"ipnet",
7172
"ipnetwork",
7273
"mac_address",
7374
"uuid",
@@ -117,11 +118,12 @@ sqlite-unbundled = ["_sqlite", "sqlx-sqlite/unbundled", "sqlx-macros?/sqlite-unb
117118
sqlite-preupdate-hook = ["sqlx-sqlite/preupdate-hook"]
118119

119120
# types
120-
json = ["sqlx-macros?/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sqlite?/json"]
121+
json = ["sqlx-core/json", "sqlx-macros?/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sqlite?/json"]
121122

122123
bigdecimal = ["sqlx-core/bigdecimal", "sqlx-macros?/bigdecimal", "sqlx-mysql?/bigdecimal", "sqlx-postgres?/bigdecimal"]
123124
bit-vec = ["sqlx-core/bit-vec", "sqlx-macros?/bit-vec", "sqlx-postgres?/bit-vec"]
124125
chrono = ["sqlx-core/chrono", "sqlx-macros?/chrono", "sqlx-mysql?/chrono", "sqlx-postgres?/chrono", "sqlx-sqlite?/chrono"]
126+
ipnet = ["sqlx-core/ipnet", "sqlx-macros?/ipnet", "sqlx-postgres?/ipnet"]
125127
ipnetwork = ["sqlx-core/ipnetwork", "sqlx-macros?/ipnetwork", "sqlx-postgres?/ipnetwork"]
126128
mac_address = ["sqlx-core/mac_address", "sqlx-macros?/mac_address", "sqlx-postgres?/mac_address"]
127129
rust_decimal = ["sqlx-core/rust_decimal", "sqlx-macros?/rust_decimal", "sqlx-mysql?/rust_decimal", "sqlx-postgres?/rust_decimal"]
@@ -149,6 +151,7 @@ sqlx = { version = "=0.8.3", path = ".", default-features = false }
149151
bigdecimal = "0.4.0"
150152
bit-vec = "0.6.3"
151153
chrono = { version = "0.4.34", default-features = false, features = ["std", "clock"] }
154+
ipnet = "2.3.0"
152155
ipnetwork = "0.20.0"
153156
mac_address = "1.1.5"
154157
rust_decimal = { version = "1.26.1", default-features = false, features = ["std"] }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ be removed in the future.
220220

221221
- `rust_decimal`: Add support for `NUMERIC` using the `rust_decimal` crate.
222222

223+
- `ipnet`: Add support for `INET` and `CIDR` (in postgres) using the `ipnet` crate.
224+
223225
- `ipnetwork`: Add support for `INET` and `CIDR` (in postgres) using the `ipnetwork` crate.
224226

225227
- `json`: Add support for `JSON` and `JSONB` (in postgres) using the `serde_json` crate.

sqlx-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ bit-vec = { workspace = true, optional = true }
5050
bigdecimal = { workspace = true, optional = true }
5151
rust_decimal = { workspace = true, optional = true }
5252
time = { workspace = true, optional = true }
53+
ipnet = { workspace = true, optional = true }
5354
ipnetwork = { workspace = true, optional = true }
5455
mac_address = { workspace = true, optional = true }
5556
uuid = { workspace = true, optional = true }

sqlx-core/src/types/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ pub use bigdecimal::BigDecimal;
6767
#[doc(no_inline)]
6868
pub use rust_decimal::Decimal;
6969

70+
#[cfg(feature = "ipnet")]
71+
#[cfg_attr(docsrs, doc(cfg(feature = "ipnet")))]
72+
pub mod ipnet {
73+
#[doc(no_inline)]
74+
pub use ipnet::{IpNet, Ipv4Net, Ipv6Net};
75+
}
76+
7077
#[cfg(feature = "ipnetwork")]
7178
#[cfg_attr(docsrs, doc(cfg(feature = "ipnetwork")))]
7279
pub mod ipnetwork {

sqlx-macros-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ json = ["sqlx-core/json", "sqlx-mysql?/json", "sqlx-postgres?/json", "sqlx-sqlit
3939
bigdecimal = ["sqlx-core/bigdecimal", "sqlx-mysql?/bigdecimal", "sqlx-postgres?/bigdecimal"]
4040
bit-vec = ["sqlx-core/bit-vec", "sqlx-postgres?/bit-vec"]
4141
chrono = ["sqlx-core/chrono", "sqlx-mysql?/chrono", "sqlx-postgres?/chrono", "sqlx-sqlite?/chrono"]
42+
ipnet = ["sqlx-core/ipnet", "sqlx-postgres?/ipnet"]
4243
ipnetwork = ["sqlx-core/ipnetwork", "sqlx-postgres?/ipnetwork"]
4344
mac_address = ["sqlx-core/mac_address", "sqlx-postgres?/mac_address"]
4445
rust_decimal = ["sqlx-core/rust_decimal", "sqlx-mysql?/rust_decimal", "sqlx-postgres?/rust_decimal"]

sqlx-macros/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ sqlite-unbundled = ["sqlx-macros-core/sqlite-unbundled"]
3838
bigdecimal = ["sqlx-macros-core/bigdecimal"]
3939
bit-vec = ["sqlx-macros-core/bit-vec"]
4040
chrono = ["sqlx-macros-core/chrono"]
41+
ipnet = ["sqlx-macros-core/ipnet"]
4142
ipnetwork = ["sqlx-macros-core/ipnetwork"]
4243
mac_address = ["sqlx-macros-core/mac_address"]
4344
rust_decimal = ["sqlx-macros-core/rust_decimal"]

sqlx-mysql/src/protocol/text/row.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ impl<'de> ProtocolDecode<'de, &'de [MySqlColumn]> for TextRow {
1616

1717
let mut values = Vec::with_capacity(columns.len());
1818

19-
for _ in columns {
19+
for c in columns {
2020
if buf[0] == 0xfb {
2121
// NULL is sent as 0xfb
2222
values.push(None);
2323
buf.advance(1);
2424
} else {
2525
let size = buf.get_uint_lenenc();
26+
if (buf.remaining() as u64) < size {
27+
return Err(err_protocol!(
28+
"buffer exhausted when reading data for column {:?}; decoded length is {}, but only {} bytes remain in buffer. Malformed packet or protocol error?",
29+
c,
30+
size,
31+
buf.remaining()));
32+
}
2633
let size = usize::try_from(size)
2734
.map_err(|_| err_protocol!("TextRow length out of range: {size}"))?;
2835

sqlx-postgres/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ offline = ["sqlx-core/offline"]
1919
bigdecimal = ["dep:bigdecimal", "dep:num-bigint", "sqlx-core/bigdecimal"]
2020
bit-vec = ["dep:bit-vec", "sqlx-core/bit-vec"]
2121
chrono = ["dep:chrono", "sqlx-core/chrono"]
22+
ipnet = ["dep:ipnet", "sqlx-core/ipnet"]
2223
ipnetwork = ["dep:ipnetwork", "sqlx-core/ipnetwork"]
2324
mac_address = ["dep:mac_address", "sqlx-core/mac_address"]
2425
rust_decimal = ["dep:rust_decimal", "rust_decimal/maths", "sqlx-core/rust_decimal"]
@@ -43,6 +44,7 @@ sha2 = { version = "0.10.0", default-features = false }
4344
bigdecimal = { workspace = true, optional = true }
4445
bit-vec = { workspace = true, optional = true }
4546
chrono = { workspace = true, optional = true }
47+
ipnet = { workspace = true, optional = true }
4648
ipnetwork = { workspace = true, optional = true }
4749
mac_address = { workspace = true, optional = true }
4850
rust_decimal = { workspace = true, optional = true }

sqlx-postgres/src/type_checking.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ impl_type_checking!(
8888
#[cfg(feature = "ipnetwork")]
8989
sqlx::types::ipnetwork::IpNetwork,
9090

91+
#[cfg(feature = "ipnet")]
92+
sqlx::types::ipnet::IpNet,
93+
9194
#[cfg(feature = "mac_address")]
9295
sqlx::types::mac_address::MacAddress,
9396

@@ -149,6 +152,9 @@ impl_type_checking!(
149152
#[cfg(feature = "ipnetwork")]
150153
Vec<sqlx::types::ipnetwork::IpNetwork> | &[sqlx::types::ipnetwork::IpNetwork],
151154

155+
#[cfg(feature = "ipnet")]
156+
Vec<sqlx::types::ipnet::IpNet> | &[sqlx::types::ipnet::IpNet],
157+
152158
#[cfg(feature = "mac_address")]
153159
Vec<sqlx::types::mac_address::MacAddress> | &[sqlx::types::mac_address::MacAddress],
154160

0 commit comments

Comments
 (0)