Skip to content

Commit f69abed

Browse files
LHoltenJamesGuthriesfacklerbikeshedderTroyKomodo
authored
Sync upstream (#37)
* fix code block * Update lib.rs * Add table_oid and field_id to columns of prepared statements * Simplify Debug impl of Column * Update id types * feat(types): add default derive to json wrapper Adds a Default impl for `Json<T> where T: Default` allowing for other structs to use the wrapper and implement Default. * Update env_logger requirement from 0.10 to 0.11 Updates the requirements on [env_logger](https://github.com/rust-cli/env_logger) to permit the latest version. - [Release notes](https://github.com/rust-cli/env_logger/releases) - [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md) - [Commits](rust-cli/env_logger@v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: env_logger dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Update ci.yml * Update main.rs * add #[track_caller] to the Row::get() functions This small quality-of-life improvement changes these errors: thread '<unnamed>' panicked at /../.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-postgres-0.7.10/src/row.rs:151:25: error retrieving column 0: error deserializing column 0: a Postgres value was `NULL` to: thread '<unnamed>' panicked at my-program.rs:100:25: error retrieving column 0: error deserializing column 0: a Postgres value was `NULL` * Bump CI version * Added ReadOnly session attr * Added ReadOnly session attr * Update base64 requirement from 0.21 to 0.22 Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version. - [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md) - [Commits](marshallpierce/rust-base64@v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: base64 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Shrink query_opt/query_one codegen size very slightly * use `split_once` instead of `split` to parse lsn strings [`str::split`](https://doc.rust-lang.org/std/primitive.str.html#method.split) allocates a vector and generates considerably more instructions when compiled than [`str::split_once`](https://doc.rust-lang.org/std/primitive.str.html#method.split_once). [`u64::from_str_radix(split_lo, 16)`](https://doc.rust-lang.org/std/primitive.u64.html#method.from_str_radix) will error if the `lsn_str` contains more than one `/` so this change should result in the same behavior as the current implementation despite not explicitly checking this. * Make license metadata SPDX compliant * Update heck requirement from 0.4 to 0.5 --- updated-dependencies: - dependency-name: heck dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Avoid extra clone in config if possible Using `impl Into<String>` instead of `&str` in a fn arg allows both `&str` and `String` as parameters - thus if the caller already has a String object that it doesn't need, it can pass it in without extra cloning. The same might be done with the password, but may require closer look. * add simple_query to GenericClient in tokio_postgres * feat(types): add 'js' feature for wasm Enables the "js" feature of postgres-protocol. * Add RowDescription to SimpleQueryMessage * Formatting updates * Clippy compliance * Formatting * Work with pools that don't support prepared statements Introduce a new `query_with_param_types` method that allows to specify Postgres type parameters. This obviated the need to use prepared statementsjust to obtain parameter types for a query. It then combines parse, bind, and execute in a single packet. Related: sfackler#1017, sfackler#1067 * Derive Clone for Row * impl Debug for Statement The lack of this common trait bound caused some unpleasantness. For example, the following didn't compile: let x = OnceLock::new(); let stmt = db.prepare(...)?; x.set(stmt).expect(...); // returns Result<(), T=Statement> where T: Debug * Fix a few nits pointed out by clippy - ...::max_value() -> ..::MAX - delete explicit import of signed integer types * Handle non-UTF8 error fields * PR Fix: Only use single clone for RowDescription * Replace the state machine to process messages with a direct match statements * Remove query_raw_with_param_types as per PR feedback * PR Fix: Clone first then move * Address review comment to rename query_with_param_types to query_typed * Fix a clippy warning * query_typed tweaks * Fix cancellation of TransactionBuilder::start * Release postgres-protocol v0.6.7 * Release postgres-types v0.2.7 * Release tokio-postgres v0.7.11 * Release postgres v0.19.8 * Add jiff support * For `query_typed`, deal with the no-data case. If a query returns no data, we receive `Message::NoData`, which signals the completion of the query. However, we treated it as a no-op, leading to processing other messages and eventual failure. This PR fixes the issue and updates the `query_typed` tests to cover this scenario. * Support AIX keepalive * Remove unecessary alias for Timestamp * Update impl for Timestamp The impl now directly computes `Timestamp` rather than going through `DateTime` and `Zoned`. * Remove impl for `Zoned` `Timestamp` already has impl and is semantically accurate for mapping to `timestamptz`, unlike `Zoned`. End users can do their own conversions from `Timestamp` to `Zoned` if desired. * Rename PG_EPOCH * Fix ToSql This sets the smallest unit to microseconds when calculating time deltas. Previously, the number of microseconds was expressed improperly because the rounding was not set. * Add jiff tests and overflow checks This adds tests in the same fashion as the existing ones for `chrono` and `time`. Overflow is now handled using fallible operations. For example, `Span:microseconds` is replaced with `Span::try_microseconds`. Postgres infinity values are workiing as expected. All tests are passing. * Remove `Zoned` from docs The implementation was previously removed as per jiff author comment. * Fix `chrono::DateTime<Utc>` tests `test_date_time_params` and `test_with_special_date_time_params` could fail when run with a non-UTC system time zone. In Postgres, if no time zone is stated in the input string, then it is assumed to be in system time. This means that in these tests, a correctly parsed `DateTime<Utc>` could be compared to an incorrectly offset time. The offset component is now included in the test strings of these tests. This component is already present in the test strings for `time::OffsetDateTime`. * Release postgres-derive v0.4.6 * Release postgres-types v0.2.8 * Release tokio-postgres v0.7.12 * Release postgres v0.19.9 * feat: add ssl_negotiation option * test: updte tests for direct tls * feat: provide built-in functions for setting ALPN * refactor: pub use sslnegotiation * refactor: apply review comments * chore: update postgres for ci * Add support for cidr 0.3 under separate feature * add `load_balance_hosts` to `Debug` impl for `Config` * Fix time 0.3 infinity panics Getting `PrimitiveDateTime` panics if the value is infinity. This commit fixes the panic. An infinity test is added, mirroring the existing one for chrono. * Fix clippy needless_lifetimes * Fix clippy extra_unused_lifetimes * Fix for Rust 2024 match ergonomics Fixes an error related to https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html * Fix another needless_lifetimes * Fix clippy needless_borrowed_reference The applied suggestion for 2024 match ergonomics trips another lint. This fixes the lint. * Bump CI Rust version to 1.75.0 cargo tests in CI are [failing](https://github.com/sfackler/rust-postgres/actions/runs/12862700447/job/35858038081?pr=1198) because of a dependency requirement: ``` Run cargo test --all error: package `geo-types v0.7.15` cannot be built because it requires rustc 1.75 or newer, while the currently active rustc version is 1.74.0 Either upgrade to rustc 1.75 or newer, or use cargo update geo-types@0.7.15 --precise ver where `ver` is the latest version of `geo-types` supporting rustc 1.74.0 ``` This bumps the Rust version so tests will run. * Bump actions/checkout * Empty commit (re-run CI) * Update rand requirement from 0.8 to 0.9 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@0.8.5...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * refactor: address review comments * chore: addressed rand 0.9's deprecations * fix build * fix clippy * fix wasm build * bump getrandom * Revert time 0.2 change * Propagate features * add docs * fix ci * Release postgres-native-tls v0.5.1 * Release postgres-openssl v0.5.1 * Release postgres-protocol v0.6.8 * Release postgres-types v0.2.9 * Release tokio-postgres v0.7.13 * Release postgres v0.19.10 * Fix typo in version in postgres’s changelog * Only call set_tcp_user_timeout when enabled * feat: support jiff v0.2 * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Clearly indicate tademdrive changelog * Update changelog. * Fix changelog * Fix clippy * Fix clippy --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: James Guthrie <JamesGuthrie@users.noreply.github.com> Co-authored-by: Steven Fackler <sfackler@gmail.com> Co-authored-by: Michael P. Jung <michael.jung@terreon.de> Co-authored-by: Troy Benson <troybensonsa@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Charles Samuels <ks@ks.ax> Co-authored-by: chandr-andr (Kiselev Aleksandr) <askiselev00@gmail.com> Co-authored-by: novacrazy <novacrazy@gmail.com> Co-authored-by: laxjesse <jesse@osohq.com> Co-authored-by: Paolo Barbolini <paolo.barbolini@m4ss.net> Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com> Co-authored-by: vsuryamurthy <v.sury@fizyr.com> Co-authored-by: Duarte Nunes <duarte.nunes@datadoghq.com> Co-authored-by: Dane Rigby <me@danerigby.com> Co-authored-by: Ramnivas Laddad <ramnivas@exograph.dev> Co-authored-by: Lev Kokotov <lev.kokotov@gmail.com> Co-authored-by: Sidney Cammeresi <sac@cheesecake.org> Co-authored-by: Allan Zhang <allanzhang7@gmail.com> Co-authored-by: Qiu Chaofan <qcf@ecnelises.com> Co-authored-by: Ning Sun <sunng@protonmail.com> Co-authored-by: Sidney Cammeresi <sac@readyset.io> Co-authored-by: Harris Kaufmann <harris.kaufmann@wibu.com> Co-authored-by: Allan <6740989+allan2@users.noreply.github.com> Co-authored-by: Kristof Mattei <864376+Kristof-Mattei@users.noreply.github.com> Co-authored-by: Charmander <~@charmander.me> Co-authored-by: Shawn L. <shawn@sola.sh>
1 parent 913a65f commit f69abed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1857
-353
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@ jobs:
7373
path: target
7474
key: check-wasm32-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
7575
- run: cargo check --target wasm32-unknown-unknown --manifest-path tokio-postgres/Cargo.toml --no-default-features --features js
76+
env:
77+
RUSTFLAGS: --cfg getrandom_backend="wasm_js"
7678

7779
test:
7880
name: test
7981
runs-on: ubuntu-latest
8082
steps:
81-
- uses: actions/checkout@v3
83+
- uses: actions/checkout@v4
8284
- run: docker compose up -d
8385
- uses: sfackler/actions/rustup@master
8486
with:
85-
version: 1.74.0
87+
version: 1.81.0
8688
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
8789
id: rust-version
8890
- uses: actions/cache@v3

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
postgres:
4-
image: postgres:14
4+
image: docker.io/postgres:17
55
ports:
66
- 5433:5433
77
volumes:

postgres-derive/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## v0.4.6 - 2024-09-15
4+
5+
### Changed
6+
7+
* Upgraded `heck`.
8+
39
## v0.4.5 - 2023-08-19
410

511
### Added

postgres-derive/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "postgres-derive"
3-
version = "0.4.5"
3+
version = "0.4.6"
44
authors = ["Steven Fackler <sfackler@palantir.com>"]
5-
license = "MIT/Apache-2.0"
5+
license = "MIT OR Apache-2.0"
66
edition = "2018"
77
description = "An internal crate used by postgres-types"
88
repository = "https://github.com/sfackler/rust-postgres"
@@ -15,4 +15,4 @@ test = false
1515
syn = "2.0"
1616
proc-macro2 = "1.0"
1717
quote = "1.0"
18-
heck = "0.4"
18+
heck = "0.5"

postgres-native-tls/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## v0.5.1 - 2025-02-02
4+
5+
### Added
6+
7+
* Added `set_postgresql_alpn`.
8+
39
## v0.5.0 - 2020-12-25
410

511
### Changed

postgres-native-tls/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "postgres-native-tls"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
edition = "2018"
6-
license = "MIT/Apache-2.0"
6+
license = "MIT OR Apache-2.0"
77
description = "TLS support for tokio-postgres via native-tls"
88
repository = "https://github.com/sfackler/rust-postgres"
99
readme = "../README.md"
@@ -16,12 +16,12 @@ default = ["runtime"]
1616
runtime = ["tokio-postgres/runtime"]
1717

1818
[dependencies]
19-
native-tls = "0.2"
19+
native-tls = { version = "0.2", features = ["alpn"] }
2020
tokio = "1.0"
2121
tokio-native-tls = "0.3"
22-
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
22+
tokio-postgres = { version = "0.7.11", path = "../tokio-postgres", default-features = false }
2323

2424
[dev-dependencies]
2525
futures-util = "0.3"
2626
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
27-
postgres = { version = "0.19.0", path = "../postgres" }
27+
postgres = { version = "0.19.8", path = "../postgres" }

postgres-native-tls/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
//! ```
5454
#![warn(rust_2018_idioms, clippy::all, missing_docs)]
5555

56+
use native_tls::TlsConnectorBuilder;
5657
use std::future::Future;
5758
use std::io;
5859
use std::pin::Pin;
@@ -180,3 +181,10 @@ where
180181
}
181182
}
182183
}
184+
185+
/// Set ALPN for `TlsConnectorBuilder`
186+
///
187+
/// This is required when using `sslnegotiation=direct`
188+
pub fn set_postgresql_alpn(builder: &mut TlsConnectorBuilder) {
189+
builder.request_alpns(&["postgresql"]);
190+
}

postgres-native-tls/src/test.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio_postgres::tls::TlsConnect;
55

66
#[cfg(feature = "runtime")]
77
use crate::MakeTlsConnector;
8-
use crate::TlsConnector;
8+
use crate::{set_postgresql_alpn, TlsConnector};
99

1010
async fn smoke_test<T>(s: &str, tls: T)
1111
where
@@ -42,6 +42,21 @@ async fn require() {
4242
.await;
4343
}
4444

45+
#[tokio::test]
46+
async fn direct() {
47+
let mut builder = native_tls::TlsConnector::builder();
48+
builder.add_root_certificate(
49+
Certificate::from_pem(include_bytes!("../../test/server.crt")).unwrap(),
50+
);
51+
set_postgresql_alpn(&mut builder);
52+
let connector = builder.build().unwrap();
53+
smoke_test(
54+
"user=ssl_user dbname=postgres sslmode=require sslnegotiation=direct",
55+
TlsConnector::new(connector, "localhost"),
56+
)
57+
.await;
58+
}
59+
4560
#[tokio::test]
4661
async fn prefer() {
4762
let connector = native_tls::TlsConnector::builder()

postgres-openssl/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## v0.5.1 - 2025-02-02
4+
5+
### Added
6+
7+
* Added `set_postgresql_alpn`.
8+
39
## v0.5.0 - 2020-12-25
410

511
### Changed

postgres-openssl/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "postgres-openssl"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
edition = "2018"
6-
license = "MIT/Apache-2.0"
6+
license = "MIT OR Apache-2.0"
77
description = "TLS support for tokio-postgres via openssl"
88
repository = "https://github.com/sfackler/rust-postgres"
99
readme = "../README.md"
@@ -19,9 +19,9 @@ runtime = ["tokio-postgres/runtime"]
1919
openssl = "0.10"
2020
tokio = "1.0"
2121
tokio-openssl = "0.6"
22-
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
22+
tokio-postgres = { version = "0.7.11", path = "../tokio-postgres", default-features = false }
2323

2424
[dev-dependencies]
2525
futures-util = "0.3"
2626
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
27-
postgres = { version = "0.19.0", path = "../postgres" }
27+
postgres = { version = "0.19.8", path = "../postgres" }

postgres-openssl/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use openssl::hash::MessageDigest;
5353
use openssl::nid::Nid;
5454
#[cfg(feature = "runtime")]
5555
use openssl::ssl::SslConnector;
56-
use openssl::ssl::{self, ConnectConfiguration, SslRef};
56+
use openssl::ssl::{self, ConnectConfiguration, SslConnectorBuilder, SslRef};
5757
use openssl::x509::X509VerifyResult;
5858
use std::error::Error;
5959
use std::fmt::{self, Debug};
@@ -256,3 +256,10 @@ fn tls_server_end_point(ssl: &SslRef) -> Option<Vec<u8>> {
256256
};
257257
cert.digest(md).ok().map(|b| b.to_vec())
258258
}
259+
260+
/// Set ALPN for `SslConnectorBuilder`
261+
///
262+
/// This is required when using `sslnegotiation=direct`
263+
pub fn set_postgresql_alpn(builder: &mut SslConnectorBuilder) -> Result<(), ErrorStack> {
264+
builder.set_alpn_protos(b"\x0apostgresql")
265+
}

postgres-openssl/src/test.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ async fn require() {
3737
.await;
3838
}
3939

40+
#[tokio::test]
41+
async fn direct() {
42+
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
43+
builder.set_ca_file("../test/server.crt").unwrap();
44+
set_postgresql_alpn(&mut builder).unwrap();
45+
let ctx = builder.build();
46+
smoke_test(
47+
"user=ssl_user dbname=postgres sslmode=require sslnegotiation=direct",
48+
TlsConnector::new(ctx.configure().unwrap(), "localhost"),
49+
)
50+
.await;
51+
}
52+
4053
#[tokio::test]
4154
async fn prefer() {
4255
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();

postgres-protocol/CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# Change Log
22

3-
## v0.6.6 -2023-08-19
3+
## v0.6.8 - 2025-02-02
4+
5+
### Changed
6+
7+
* Upgraded `getrandom`.
8+
9+
## v0.6.7 - 2024-07-21
10+
11+
### Deprecated
12+
13+
* Deprecated `ErrorField::value`.
14+
15+
### Added
16+
17+
* Added a `Clone` implementation for `DataRowBody`.
18+
* Added `ErrorField::value_bytes`.
19+
20+
### Changed
21+
22+
* Upgraded `base64`.
23+
24+
## v0.6.6 - 2023-08-19
425

526
### Added
627

postgres-protocol/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[package]
22
name = "postgres-protocol"
3-
version = "0.6.6"
3+
version = "0.6.8"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
edition = "2018"
66
description = "Low level Postgres protocol APIs"
7-
license = "MIT/Apache-2.0"
7+
license = "MIT OR Apache-2.0"
88
repository = "https://github.com/sfackler/rust-postgres"
99
readme = "../README.md"
1010

1111
[features]
1212
default = []
13-
js = ["getrandom/js"]
13+
js = ["getrandom/wasm_js"]
1414

1515
[dependencies]
1616
base64 = "0.22"
@@ -20,7 +20,7 @@ fallible-iterator = "0.2"
2020
hmac = "0.12"
2121
md-5 = "0.10"
2222
memchr = "2.0"
23-
rand = "0.8"
23+
rand = "0.9"
2424
sha2 = "0.10"
2525
stringprep = "0.1"
26-
getrandom = { version = "0.2", optional = true }
26+
getrandom = { version = "0.3", optional = true }

postgres-protocol/src/authentication/sasl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ impl ScramSha256 {
136136
/// Constructs a new instance which will use the provided password for authentication.
137137
pub fn new(password: &[u8], channel_binding: ChannelBinding) -> ScramSha256 {
138138
// rand 0.5's ThreadRng is cryptographically secure
139-
let mut rng = rand::thread_rng();
139+
let mut rng = rand::rng();
140140
let nonce = (0..NONCE_LENGTH)
141141
.map(|_| {
142-
let mut v = rng.gen_range(0x21u8..0x7e);
142+
let mut v = rng.random_range(0x21u8..0x7e);
143143
if v == 0x2c {
144144
v = 0x7e
145145
}

postgres-protocol/src/message/backend.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub struct ColumnFormats<'a> {
475475
remaining: u16,
476476
}
477477

478-
impl<'a> FallibleIterator for ColumnFormats<'a> {
478+
impl FallibleIterator for ColumnFormats<'_> {
479479
type Item = u16;
480480
type Error = io::Error;
481481

@@ -524,7 +524,7 @@ impl CopyOutResponseBody {
524524
}
525525
}
526526

527-
#[derive(Debug)]
527+
#[derive(Debug, Clone)]
528528
pub struct DataRowBody {
529529
storage: Bytes,
530530
len: u16,
@@ -557,7 +557,7 @@ pub struct DataRowRanges<'a> {
557557
remaining: u16,
558558
}
559559

560-
impl<'a> FallibleIterator for DataRowRanges<'a> {
560+
impl FallibleIterator for DataRowRanges<'_> {
561561
type Item = Option<Range<usize>>;
562562
type Error = io::Error;
563563

@@ -633,7 +633,7 @@ impl<'a> FallibleIterator for ErrorFields<'a> {
633633
}
634634

635635
let value_end = find_null(self.buf, 0)?;
636-
let value = get_str(&self.buf[..value_end])?;
636+
let value = &self.buf[..value_end];
637637
self.buf = &self.buf[value_end + 1..];
638638

639639
Ok(Some(ErrorField { type_, value }))
@@ -642,17 +642,23 @@ impl<'a> FallibleIterator for ErrorFields<'a> {
642642

643643
pub struct ErrorField<'a> {
644644
type_: u8,
645-
value: &'a str,
645+
value: &'a [u8],
646646
}
647647

648-
impl<'a> ErrorField<'a> {
648+
impl ErrorField<'_> {
649649
#[inline]
650650
pub fn type_(&self) -> u8 {
651651
self.type_
652652
}
653653

654654
#[inline]
655+
#[deprecated(note = "use value_bytes instead", since = "0.6.7")]
655656
pub fn value(&self) -> &str {
657+
str::from_utf8(self.value).expect("error field value contained non-UTF8 bytes")
658+
}
659+
660+
#[inline]
661+
pub fn value_bytes(&self) -> &[u8] {
656662
self.value
657663
}
658664
}
@@ -711,7 +717,7 @@ pub struct Parameters<'a> {
711717
remaining: u16,
712718
}
713719

714-
impl<'a> FallibleIterator for Parameters<'a> {
720+
impl FallibleIterator for Parameters<'_> {
715721
type Item = Oid;
716722
type Error = io::Error;
717723

postgres-protocol/src/password/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const SCRAM_DEFAULT_SALT_LEN: usize = 16;
2828
/// special characters that would require escaping in an SQL command.
2929
pub fn scram_sha_256(password: &[u8]) -> String {
3030
let mut salt: [u8; SCRAM_DEFAULT_SALT_LEN] = [0; SCRAM_DEFAULT_SALT_LEN];
31-
let mut rng = rand::thread_rng();
31+
let mut rng = rand::rng();
3232
rng.fill_bytes(&mut salt);
3333
scram_sha_256_salt(password, salt)
3434
}

postgres-protocol/src/types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'a> Array<'a> {
582582
/// An iterator over the dimensions of an array.
583583
pub struct ArrayDimensions<'a>(&'a [u8]);
584584

585-
impl<'a> FallibleIterator for ArrayDimensions<'a> {
585+
impl FallibleIterator for ArrayDimensions<'_> {
586586
type Item = ArrayDimension;
587587
type Error = StdBox<dyn Error + Sync + Send>;
588588

@@ -1048,7 +1048,7 @@ pub struct PathPoints<'a> {
10481048
buf: &'a [u8],
10491049
}
10501050

1051-
impl<'a> FallibleIterator for PathPoints<'a> {
1051+
impl FallibleIterator for PathPoints<'_> {
10521052
type Item = Point;
10531053
type Error = StdBox<dyn Error + Sync + Send>;
10541054

0 commit comments

Comments
 (0)