Skip to content

Sync upstream #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 148 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
863c1d6
fix code block
JamesGuthrie Nov 7, 2023
c5aef21
Merge pull request #1080 from JamesGuthrie/patch-1
sfackler Nov 7, 2023
10edbcb
Update lib.rs
sfackler Nov 7, 2023
02bab67
Add table_oid and field_id to columns of prepared statements
bikeshedder Dec 5, 2023
8787615
Simplify Debug impl of Column
bikeshedder Dec 5, 2023
eb3f595
Merge pull request #1084 from bikeshedder/table_oid_column_id
sfackler Dec 11, 2023
bbc0414
Update id types
sfackler Dec 12, 2023
90c92c2
feat(types): add default derive to json wrapper
TroyKomodo Jan 15, 2024
e8f44ec
Merge pull request #1093 from ScuffleTV/troy/add-default-json
sfackler Jan 15, 2024
2f150a7
Update env_logger requirement from 0.10 to 0.11
dependabot[bot] Jan 22, 2024
7bc3deb
Update ci.yml
sfackler Jan 23, 2024
a92c6eb
Update main.rs
sfackler Jan 23, 2024
8989fc9
Merge pull request #1097 from sfackler/dependabot/cargo/env_logger-0.11
sfackler Jan 23, 2024
289cf88
add #[track_caller] to the Row::get() functions
Feb 16, 2024
25314a9
Bump CI version
sfackler Feb 17, 2024
ba1b4cf
Merge pull request #1104 from njaard/master
sfackler Feb 17, 2024
a9ca481
Added ReadOnly session attr
chandr-andr Mar 3, 2024
6a01730
Added ReadOnly session attr
chandr-andr Mar 3, 2024
d6c2835
Merge pull request #1110 from chandr-andr/feature/add_read_only_sessi…
sfackler Mar 3, 2024
4217553
Update base64 requirement from 0.21 to 0.22
dependabot[bot] Mar 4, 2024
270a29b
Merge pull request #1112 from sfackler/dependabot/cargo/base64-0.22
sfackler Mar 4, 2024
9d7c43c
Shrink query_opt/query_one codegen size very slightly
novacrazy Feb 11, 2024
9743630
use `split_once` instead of `split` to parse lsn strings
laxjesse Mar 13, 2024
e528e01
Merge pull request #1118 from laxjesse/split_once_in_lsn_from_str
sfackler Mar 13, 2024
64caf4c
Merge pull request #1101 from Lantern-chat/async_size
sfackler Mar 17, 2024
3836a30
Make license metadata SPDX compliant
paolobarbolini Apr 10, 2024
8cf7f3a
Merge pull request #1130 from paolobarbolini/spdx
sfackler Apr 10, 2024
670cd7d
Update heck requirement from 0.4 to 0.5
dependabot[bot] Apr 10, 2024
98f5a11
Merge pull request #1117 from sfackler/dependabot/cargo/heck-0.5
sfackler Apr 10, 2024
3c6dbe9
Avoid extra clone in config if possible
nyurik May 2, 2024
d5d75d3
add simple_query to GenericClient in tokio_postgres
vsuryamurthy May 23, 2024
fbecae1
feat(types): add 'js' feature for wasm
duarten Mar 11, 2024
6cd4652
Add RowDescription to SimpleQueryMessage
rigby-dane May 29, 2024
7afead9
Formatting updates
rigby-dane May 29, 2024
eec0602
Clippy compliance
rigby-dane May 29, 2024
bd6350c
Formatting
rigby-dane May 30, 2024
f397668
Work with pools that don't support prepared statements
ramnivas May 26, 2024
84994da
Derive Clone for Row
levkk Jul 6, 2024
2b1949d
impl Debug for Statement
cammeresi Jul 6, 2024
0bd8b2b
Merge pull request #1153 from cammeresi/master
sfackler Jul 6, 2024
f9c2d5c
Merge pull request #1152 from levkk/levkk-add-clone-to-row
sfackler Jul 6, 2024
1f31219
Fix a few nits pointed out by clippy
cammeresi Jul 6, 2024
c2b5c8a
Merge pull request #1154 from cammeresi/master
sfackler Jul 6, 2024
263b006
Handle non-UTF8 error fields
sfackler Jul 6, 2024
7cbb462
Merge pull request #1155 from sfackler/non-utf8-error
sfackler Jul 6, 2024
20749d8
Merge pull request #1116 from duarten/postgres-types-js
sfackler Jul 6, 2024
34a68c0
Merge pull request #1142 from vsuryamurthy/add_simple_query_generic_c…
sfackler Jul 6, 2024
ded5e7d
Merge pull request #1137 from nyurik/use-string
sfackler Jul 6, 2024
cfd9163
PR Fix: Only use single clone for RowDescription
rigby-dane Jul 7, 2024
3f8f5de
Replace the state machine to process messages with a direct match sta…
ramnivas Jul 7, 2024
74eb4db
Remove query_raw_with_param_types as per PR feedback
ramnivas Jul 7, 2024
f00ed42
Merge remote-tracking branch 'origin/master' into exograph
ramnivas Jul 7, 2024
2647024
PR Fix: Clone first then move
rigby-dane Jul 8, 2024
647a925
Merge pull request #1144 from rigby-dane/add_row_description
sfackler Jul 9, 2024
dbd4d02
Address review comment to rename query_with_param_types to query_typed
ramnivas Jul 9, 2024
0fa3247
Fix a clippy warning
ramnivas Jul 10, 2024
257bcfd
Merge pull request #1147 from exograph/exograph
sfackler Jul 13, 2024
71c836b
query_typed tweaks
sfackler Jul 14, 2024
a1bdd0b
Merge pull request #1160 from sfackler/query-typed-cleanup
sfackler Jul 14, 2024
a0b2d70
Fix cancellation of TransactionBuilder::start
sfackler Jul 22, 2024
4b9cdca
Merge pull request #1162 from sfackler/transaction-builder-cancellation
sfackler Jul 22, 2024
c358077
Release postgres-protocol v0.6.7
sfackler Jul 22, 2024
6b4566b
Release postgres-types v0.2.7
sfackler Jul 22, 2024
9226618
Release tokio-postgres v0.7.11
sfackler Jul 22, 2024
9f196e7
Release postgres v0.19.8
sfackler Jul 22, 2024
6de0fce
Add jiff support
allan2 Jul 22, 2024
0fc4005
For `query_typed`, deal with the no-data case.
ramnivas Jul 22, 2024
3afcc3d
Merge pull request #1165 from exograph/query-typed-no-data
sfackler Jul 23, 2024
aa10f0d
Support AIX keepalive
ecnelises Jul 23, 2024
df2f37d
Remove unecessary alias for Timestamp
allan2 Jul 23, 2024
f00d208
Update impl for Timestamp
allan2 Jul 23, 2024
815a5d3
Remove impl for `Zoned`
allan2 Jul 23, 2024
d2634a4
Merge pull request #1166 from ecnelises/aix
sfackler Jul 24, 2024
e19b3dc
Rename PG_EPOCH
allan2 Aug 14, 2024
c96342d
Fix ToSql
allan2 Aug 14, 2024
afef88e
Add jiff tests and overflow checks
allan2 Aug 15, 2024
bc9102c
Remove `Zoned` from docs
allan2 Aug 15, 2024
5b26b5d
Fix `chrono::DateTime<Utc>` tests
allan2 Aug 15, 2024
2e6b7df
Merge pull request #1170 from allan2/chrono-test
sfackler Aug 16, 2024
6fd0444
Merge pull request #1164 from allan2/jiff
sfackler Aug 18, 2024
b1ace91
Release postgres-derive v0.4.6
sfackler Sep 16, 2024
776ea30
Release postgres-types v0.2.8
sfackler Sep 16, 2024
8d08adb
Release tokio-postgres v0.7.12
sfackler Sep 16, 2024
6ae17e0
Release postgres v0.19.9
sfackler Sep 16, 2024
60c1182
feat: add ssl_negotiation option
sunng87 Jul 5, 2024
6a6fdb9
test: updte tests for direct tls
sunng87 Jul 6, 2024
9441ce1
feat: provide built-in functions for setting ALPN
sunng87 Jul 6, 2024
cfdc66f
refactor: pub use sslnegotiation
sunng87 Jul 6, 2024
db308ef
refactor: apply review comments
sunng87 Jul 7, 2024
331e968
chore: update postgres for ci
sunng87 Sep 27, 2024
eea7f13
Add support for cidr 0.3 under separate feature
rs-sac Oct 25, 2024
7eb6f8e
add `load_balance_hosts` to `Debug` impl for `Config`
Dec 18, 2024
d7ccc7e
Merge pull request #1195 from kamulos/master
sfackler Dec 18, 2024
76a1637
Fix time 0.3 infinity panics
allan2 Jan 20, 2025
24d3234
Fix clippy needless_lifetimes
allan2 Jan 20, 2025
7046518
Fix clippy extra_unused_lifetimes
allan2 Jan 20, 2025
b13052a
Fix for Rust 2024 match ergonomics
allan2 Jan 20, 2025
4d03ed8
Fix another needless_lifetimes
allan2 Jan 20, 2025
7490e51
Fix clippy needless_borrowed_reference
allan2 Jan 20, 2025
852ae49
Bump CI Rust version to 1.75.0
allan2 Jan 20, 2025
66622f3
Bump actions/checkout
allan2 Jan 20, 2025
07b6878
Merge pull request #1199 from allan2/ci-update-rust-version
sfackler Jan 20, 2025
0a25fd1
Empty commit (re-run CI)
allan2 Jan 20, 2025
e00ceb1
Update rand requirement from 0.8 to 0.9
dependabot[bot] Jan 28, 2025
96f2347
refactor: address review comments
sunng87 Jan 30, 2025
02463b1
chore: addressed rand 0.9's deprecations
kristof-mattei Feb 1, 2025
14a1216
fix build
sfackler Feb 2, 2025
720ffe8
fix clippy
sfackler Feb 2, 2025
c104b23
Merge pull request #1151 from sunng87/feature/ssl-negotiation
sfackler Feb 2, 2025
778611c
Merge remote-tracking branch 'origin/master' into fix-rand-0.9-deprec…
sfackler Feb 2, 2025
acd17ed
fix wasm build
sfackler Feb 2, 2025
0d18b95
bump getrandom
sfackler Feb 2, 2025
f1c5c4f
Merge pull request #1205 from kristof-mattei/fix-rand-0.9-deprecations
sfackler Feb 2, 2025
1a9abac
Merge remote-tracking branch 'origin/master' into time-overflow
sfackler Feb 2, 2025
9754f13
Revert time 0.2 change
sfackler Feb 2, 2025
924d0e5
Merge pull request #1197 from allan2/time-overflow
sfackler Feb 2, 2025
263fb90
Merge pull request #1198 from allan2/clippy
sfackler Feb 2, 2025
0785381
Merge pull request #1183 from rs-sac/upstream
sfackler Feb 2, 2025
89b91b4
Propagate features
sfackler Feb 2, 2025
bfb35b2
add docs
sfackler Feb 2, 2025
a5eaea1
fix ci
sfackler Feb 2, 2025
7ee61f3
Merge pull request #1207 from sfackler/cidr-fixes
sfackler Feb 2, 2025
14f3b9e
Release postgres-native-tls v0.5.1
sfackler Feb 2, 2025
1ed6365
Release postgres-openssl v0.5.1
sfackler Feb 2, 2025
966724c
Release postgres-protocol v0.6.8
sfackler Feb 2, 2025
43c7049
Release postgres-types v0.2.9
sfackler Feb 2, 2025
ad68abf
Release tokio-postgres v0.7.13
sfackler Feb 2, 2025
bfe5b9d
Release postgres v0.19.10
sfackler Feb 2, 2025
5c56e5e
Fix typo in version in postgres’s changelog
charmander Feb 3, 2025
1e1f6bf
Merge pull request #1208 from charmander/patch-2
sfackler Feb 3, 2025
c867352
Only call set_tcp_user_timeout when enabled
sfackler Feb 12, 2025
cd8a341
feat: support jiff v0.2
Feb 12, 2025
3469ab0
WIP
Feb 12, 2025
4c2ded1
Merge pull request #1215 from sfackler/wsl1
sfackler Feb 14, 2025
ddea059
WIP
Feb 15, 2025
7fe6797
WIP
Feb 15, 2025
0e1d04c
WIP
Feb 15, 2025
e26ebf5
WIP
Feb 15, 2025
3d3705c
WIP
Feb 16, 2025
7b8d796
WIP
Feb 16, 2025
490c485
Merge pull request #1217 from NOBLES5E/master
sfackler Feb 17, 2025
d7b2b08
Clearly indicate tademdrive changelog
LHolten Nov 14, 2024
f1c600d
Update changelog.
LHolten Feb 27, 2025
be49151
Merge remote-tracking branch 'upstream/master' into prepare-upstream
LHolten Feb 27, 2025
9bdfda2
Fix changelog
LHolten Feb 27, 2025
8e5fb5f
Merge remote-tracking branch 'upstream/master' into prepare-upstream
LHolten Feb 27, 2025
cbe70ac
Fix clippy
LHolten Feb 27, 2025
5448b0d
Fix clippy
LHolten Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,18 @@ jobs:
path: target
key: check-wasm32-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- run: cargo check --target wasm32-unknown-unknown --manifest-path tokio-postgres/Cargo.toml --no-default-features --features js
env:
RUSTFLAGS: --cfg getrandom_backend="wasm_js"

test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: docker compose up -d
- uses: sfackler/actions/rustup@master
with:
version: 1.74.0
version: 1.81.0
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
id: rust-version
- uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
postgres:
image: postgres:14
image: docker.io/postgres:17
ports:
- 5433:5433
volumes:
Expand Down
6 changes: 6 additions & 0 deletions postgres-derive/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## v0.4.6 - 2024-09-15

### Changed

* Upgraded `heck`.

## v0.4.5 - 2023-08-19

### Added
Expand Down
6 changes: 3 additions & 3 deletions postgres-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "postgres-derive"
version = "0.4.5"
version = "0.4.6"
authors = ["Steven Fackler <sfackler@palantir.com>"]
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
edition = "2018"
description = "An internal crate used by postgres-types"
repository = "https://github.com/sfackler/rust-postgres"
Expand All @@ -15,4 +15,4 @@ test = false
syn = "2.0"
proc-macro2 = "1.0"
quote = "1.0"
heck = "0.4"
heck = "0.5"
6 changes: 6 additions & 0 deletions postgres-native-tls/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## v0.5.1 - 2025-02-02

### Added

* Added `set_postgresql_alpn`.

## v0.5.0 - 2020-12-25

### Changed
Expand Down
10 changes: 5 additions & 5 deletions postgres-native-tls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "postgres-native-tls"
version = "0.5.0"
version = "0.5.1"
authors = ["Steven Fackler <sfackler@gmail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
description = "TLS support for tokio-postgres via native-tls"
repository = "https://github.com/sfackler/rust-postgres"
readme = "../README.md"
Expand All @@ -16,12 +16,12 @@ default = ["runtime"]
runtime = ["tokio-postgres/runtime"]

[dependencies]
native-tls = "0.2"
native-tls = { version = "0.2", features = ["alpn"] }
tokio = "1.0"
tokio-native-tls = "0.3"
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
tokio-postgres = { version = "0.7.11", path = "../tokio-postgres", default-features = false }

[dev-dependencies]
futures-util = "0.3"
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
postgres = { version = "0.19.0", path = "../postgres" }
postgres = { version = "0.19.8", path = "../postgres" }
8 changes: 8 additions & 0 deletions postgres-native-tls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
//! ```
#![warn(rust_2018_idioms, clippy::all, missing_docs)]

use native_tls::TlsConnectorBuilder;
use std::future::Future;
use std::io;
use std::pin::Pin;
Expand Down Expand Up @@ -180,3 +181,10 @@ where
}
}
}

/// Set ALPN for `TlsConnectorBuilder`
///
/// This is required when using `sslnegotiation=direct`
pub fn set_postgresql_alpn(builder: &mut TlsConnectorBuilder) {
builder.request_alpns(&["postgresql"]);
}
17 changes: 16 additions & 1 deletion postgres-native-tls/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tokio_postgres::tls::TlsConnect;

#[cfg(feature = "runtime")]
use crate::MakeTlsConnector;
use crate::TlsConnector;
use crate::{set_postgresql_alpn, TlsConnector};

async fn smoke_test<T>(s: &str, tls: T)
where
Expand Down Expand Up @@ -42,6 +42,21 @@ async fn require() {
.await;
}

#[tokio::test]
async fn direct() {
let mut builder = native_tls::TlsConnector::builder();
builder.add_root_certificate(
Certificate::from_pem(include_bytes!("../../test/server.crt")).unwrap(),
);
set_postgresql_alpn(&mut builder);
let connector = builder.build().unwrap();
smoke_test(
"user=ssl_user dbname=postgres sslmode=require sslnegotiation=direct",
TlsConnector::new(connector, "localhost"),
)
.await;
}

#[tokio::test]
async fn prefer() {
let connector = native_tls::TlsConnector::builder()
Expand Down
6 changes: 6 additions & 0 deletions postgres-openssl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## v0.5.1 - 2025-02-02

### Added

* Added `set_postgresql_alpn`.

## v0.5.0 - 2020-12-25

### Changed
Expand Down
8 changes: 4 additions & 4 deletions postgres-openssl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "postgres-openssl"
version = "0.5.0"
version = "0.5.1"
authors = ["Steven Fackler <sfackler@gmail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
description = "TLS support for tokio-postgres via openssl"
repository = "https://github.com/sfackler/rust-postgres"
readme = "../README.md"
Expand All @@ -19,9 +19,9 @@ runtime = ["tokio-postgres/runtime"]
openssl = "0.10"
tokio = "1.0"
tokio-openssl = "0.6"
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
tokio-postgres = { version = "0.7.11", path = "../tokio-postgres", default-features = false }

[dev-dependencies]
futures-util = "0.3"
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
postgres = { version = "0.19.0", path = "../postgres" }
postgres = { version = "0.19.8", path = "../postgres" }
9 changes: 8 additions & 1 deletion postgres-openssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use openssl::hash::MessageDigest;
use openssl::nid::Nid;
#[cfg(feature = "runtime")]
use openssl::ssl::SslConnector;
use openssl::ssl::{self, ConnectConfiguration, SslRef};
use openssl::ssl::{self, ConnectConfiguration, SslConnectorBuilder, SslRef};
use openssl::x509::X509VerifyResult;
use std::error::Error;
use std::fmt::{self, Debug};
Expand Down Expand Up @@ -256,3 +256,10 @@ fn tls_server_end_point(ssl: &SslRef) -> Option<Vec<u8>> {
};
cert.digest(md).ok().map(|b| b.to_vec())
}

/// Set ALPN for `SslConnectorBuilder`
///
/// This is required when using `sslnegotiation=direct`
pub fn set_postgresql_alpn(builder: &mut SslConnectorBuilder) -> Result<(), ErrorStack> {
builder.set_alpn_protos(b"\x0apostgresql")
}
13 changes: 13 additions & 0 deletions postgres-openssl/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ async fn require() {
.await;
}

#[tokio::test]
async fn direct() {
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_ca_file("../test/server.crt").unwrap();
set_postgresql_alpn(&mut builder).unwrap();
let ctx = builder.build();
smoke_test(
"user=ssl_user dbname=postgres sslmode=require sslnegotiation=direct",
TlsConnector::new(ctx.configure().unwrap(), "localhost"),
)
.await;
}

#[tokio::test]
async fn prefer() {
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
Expand Down
23 changes: 22 additions & 1 deletion postgres-protocol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# Change Log

## v0.6.6 -2023-08-19
## v0.6.8 - 2025-02-02

### Changed

* Upgraded `getrandom`.

## v0.6.7 - 2024-07-21

### Deprecated

* Deprecated `ErrorField::value`.

### Added

* Added a `Clone` implementation for `DataRowBody`.
* Added `ErrorField::value_bytes`.

### Changed

* Upgraded `base64`.

## v0.6.6 - 2023-08-19

### Added

Expand Down
10 changes: 5 additions & 5 deletions postgres-protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "postgres-protocol"
version = "0.6.6"
version = "0.6.8"
authors = ["Steven Fackler <sfackler@gmail.com>"]
edition = "2018"
description = "Low level Postgres protocol APIs"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/sfackler/rust-postgres"
readme = "../README.md"

[features]
default = []
js = ["getrandom/js"]
js = ["getrandom/wasm_js"]

[dependencies]
base64 = "0.22"
Expand All @@ -20,7 +20,7 @@ fallible-iterator = "0.2"
hmac = "0.12"
md-5 = "0.10"
memchr = "2.0"
rand = "0.8"
rand = "0.9"
sha2 = "0.10"
stringprep = "0.1"
getrandom = { version = "0.2", optional = true }
getrandom = { version = "0.3", optional = true }
4 changes: 2 additions & 2 deletions postgres-protocol/src/authentication/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ impl ScramSha256 {
/// Constructs a new instance which will use the provided password for authentication.
pub fn new(password: &[u8], channel_binding: ChannelBinding) -> ScramSha256 {
// rand 0.5's ThreadRng is cryptographically secure
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let nonce = (0..NONCE_LENGTH)
.map(|_| {
let mut v = rng.gen_range(0x21u8..0x7e);
let mut v = rng.random_range(0x21u8..0x7e);
if v == 0x2c {
v = 0x7e
}
Expand Down
20 changes: 13 additions & 7 deletions postgres-protocol/src/message/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub struct ColumnFormats<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for ColumnFormats<'a> {
impl FallibleIterator for ColumnFormats<'_> {
type Item = u16;
type Error = io::Error;

Expand Down Expand Up @@ -524,7 +524,7 @@ impl CopyOutResponseBody {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct DataRowBody {
storage: Bytes,
len: u16,
Expand Down Expand Up @@ -557,7 +557,7 @@ pub struct DataRowRanges<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for DataRowRanges<'a> {
impl FallibleIterator for DataRowRanges<'_> {
type Item = Option<Range<usize>>;
type Error = io::Error;

Expand Down Expand Up @@ -633,7 +633,7 @@ impl<'a> FallibleIterator for ErrorFields<'a> {
}

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

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

pub struct ErrorField<'a> {
type_: u8,
value: &'a str,
value: &'a [u8],
}

impl<'a> ErrorField<'a> {
impl ErrorField<'_> {
#[inline]
pub fn type_(&self) -> u8 {
self.type_
}

#[inline]
#[deprecated(note = "use value_bytes instead", since = "0.6.7")]
pub fn value(&self) -> &str {
str::from_utf8(self.value).expect("error field value contained non-UTF8 bytes")
}

#[inline]
pub fn value_bytes(&self) -> &[u8] {
self.value
}
}
Expand Down Expand Up @@ -711,7 +717,7 @@ pub struct Parameters<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for Parameters<'a> {
impl FallibleIterator for Parameters<'_> {
type Item = Oid;
type Error = io::Error;

Expand Down
2 changes: 1 addition & 1 deletion postgres-protocol/src/password/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SCRAM_DEFAULT_SALT_LEN: usize = 16;
/// special characters that would require escaping in an SQL command.
pub fn scram_sha_256(password: &[u8]) -> String {
let mut salt: [u8; SCRAM_DEFAULT_SALT_LEN] = [0; SCRAM_DEFAULT_SALT_LEN];
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
rng.fill_bytes(&mut salt);
scram_sha_256_salt(password, salt)
}
Expand Down
4 changes: 2 additions & 2 deletions postgres-protocol/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'a> Array<'a> {
/// An iterator over the dimensions of an array.
pub struct ArrayDimensions<'a>(&'a [u8]);

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

Expand Down Expand Up @@ -1048,7 +1048,7 @@ pub struct PathPoints<'a> {
buf: &'a [u8],
}

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

Expand Down
Loading