Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sfackler/rust-postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: postgres-v0.19.10
Choose a base ref
...
head repository: sfackler/rust-postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 19 commits
  • 15 files changed
  • 6 contributors

Commits on Feb 3, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5c56e5e View commit details
  2. Merge pull request #1208 from charmander/patch-2

    Fix typo in version in postgres’s changelog
    sfackler authored Feb 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1e1f6bf View commit details

Commits on Feb 12, 2025

  1. Only call set_tcp_user_timeout when enabled

    sfackler committed Feb 12, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    sfackler Steven Fackler
    Copy the full SHA
    c867352 View commit details
  2. feat: support jiff v0.2

    Shawn L. committed Feb 12, 2025
    Copy the full SHA
    cd8a341 View commit details
  3. WIP

    Shawn L. committed Feb 12, 2025
    Copy the full SHA
    3469ab0 View commit details

Commits on Feb 14, 2025

  1. Merge pull request #1215 from sfackler/wsl1

    Only call set_tcp_user_timeout when enabled
    sfackler authored Feb 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4c2ded1 View commit details

Commits on Feb 15, 2025

  1. WIP

    Shawn L. committed Feb 15, 2025
    Copy the full SHA
    ddea059 View commit details
  2. WIP

    Shawn L. committed Feb 15, 2025
    Copy the full SHA
    7fe6797 View commit details
  3. WIP

    Shawn L. committed Feb 15, 2025
    Copy the full SHA
    0e1d04c View commit details
  4. WIP

    Shawn L. committed Feb 15, 2025
    Copy the full SHA
    e26ebf5 View commit details

Commits on Feb 16, 2025

  1. WIP

    Shawn L. committed Feb 16, 2025
    Copy the full SHA
    3d3705c View commit details
  2. WIP

    Shawn L. committed Feb 16, 2025
    Copy the full SHA
    7b8d796 View commit details

Commits on Feb 17, 2025

  1. Merge pull request #1217 from NOBLES5E/master

    feat: support jiff v0.2
    sfackler authored Feb 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    490c485 View commit details

Commits on Apr 11, 2025

  1. Copy the full SHA
    20f6bc5 View commit details
  2. Merge pull request #1234 from paolobarbolini/clippy

    Fix latest clippy warnings
    sfackler authored Apr 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2098ac2 View commit details

Commits on May 19, 2025

  1. Remove random dbg!s

    Seemingly left in by accident
    SabrinaJewson committed May 19, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    SabrinaJewson Sabrina Jewson
    Copy the full SHA
    ecd7a9f View commit details
  2. Merge pull request #1241 from SabrinaJewson/remove-dbg

    Remove random `dbg!`s
    sfackler authored May 19, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9dad65e View commit details
  3. Update criterion requirement from 0.5 to 0.6

    Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
    - [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
    - [Commits](bheisler/criterion.rs@0.5.0...0.6.0)
    
    ---
    updated-dependencies:
    - dependency-name: criterion
      dependency-version: 0.6.0
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    dependabot[bot] authored May 19, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9ca90fe View commit details
  4. Merge pull request #1242 from sfackler/dependabot/cargo/criterion-0.6

    Update criterion requirement from 0.5 to 0.6
    sfackler authored May 19, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e1cd6be View commit details
9 changes: 3 additions & 6 deletions postgres-protocol/src/authentication/sasl.rs
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@ impl ScramSha256 {
password,
channel_binding,
} => (nonce, password, channel_binding),
_ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")),
_ => return Err(io::Error::other("invalid SCRAM state")),
};

let message =
@@ -252,7 +252,7 @@ impl ScramSha256 {
salted_password,
auth_message,
} => (salted_password, auth_message),
_ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")),
_ => return Err(io::Error::other("invalid SCRAM state")),
};

let message =
@@ -262,10 +262,7 @@ impl ScramSha256 {

let verifier = match parsed {
ServerFinalMessage::Error(e) => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!("SCRAM error: {}", e),
));
return Err(io::Error::other(format!("SCRAM error: {}", e)));
}
ServerFinalMessage::Verifier(verifier) => verifier,
};
2 changes: 1 addition & 1 deletion postgres-protocol/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -324,7 +324,7 @@ pub fn varbit_from_sql(mut buf: &[u8]) -> Result<Varbit<'_>, StdBox<dyn Error +
if len < 0 {
return Err("invalid varbit length: varbit < 0".into());
}
let bytes = (len as usize + 7) / 8;
let bytes = (len as usize).div_ceil(8);
if buf.len() != bytes {
return Err("invalid message length: varbit mismatch".into());
}
2 changes: 2 additions & 0 deletions postgres-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ with-eui48-1 = ["eui48-1"]
with-geo-types-0_6 = ["geo-types-06"]
with-geo-types-0_7 = ["geo-types-0_7"]
with-jiff-0_1 = ["jiff-01"]
with-jiff-0_2 = ["jiff-02"]
with-serde_json-1 = ["serde-1", "serde_json-1"]
with-smol_str-01 = ["smol_str-01"]
with-uuid-0_8 = ["uuid-08"]
@@ -50,6 +51,7 @@ eui48-1 = { version = "1.0", package = "eui48", optional = true, default-feature
geo-types-06 = { version = "0.6", package = "geo-types", optional = true }
geo-types-0_7 = { version = "0.7", package = "geo-types", optional = true }
jiff-01 = { version = "0.1", package = "jiff", optional = true }
jiff-02 = { version = "0.2", package = "jiff", optional = true }
serde-1 = { version = "1.0", package = "serde", optional = true }
serde_json-1 = { version = "1.0", package = "serde_json", optional = true }
uuid-08 = { version = "0.8", package = "uuid", optional = true }
141 changes: 141 additions & 0 deletions postgres-types/src/jiff_02.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
use bytes::BytesMut;
use jiff_02::{
civil::{Date, DateTime, Time},
Span, SpanRound, Timestamp, Unit,
};
use postgres_protocol::types;
use std::error::Error;

use crate::{FromSql, IsNull, ToSql, Type};

const fn base() -> DateTime {
DateTime::constant(2000, 1, 1, 0, 0, 0, 0)
}

/// The number of seconds from the Unix epoch to 2000-01-01 00:00:00 UTC.
const PG_EPOCH: i64 = 946684800;

fn base_ts() -> Timestamp {
Timestamp::new(PG_EPOCH, 0).unwrap()
}

fn round_us<'a>() -> SpanRound<'a> {
SpanRound::new().largest(Unit::Microsecond)
}

fn decode_err<E>(_e: E) -> Box<dyn Error + Sync + Send>
where
E: Error,
{
"value too large to decode".into()
}

fn transmit_err<E>(_e: E) -> Box<dyn Error + Sync + Send>
where
E: Error,
{
"value too large to transmit".into()
}

impl<'a> FromSql<'a> for DateTime {
fn from_sql(_: &Type, raw: &[u8]) -> Result<DateTime, Box<dyn Error + Sync + Send>> {
let v = types::timestamp_from_sql(raw)?;
Span::new()
.try_microseconds(v)
.and_then(|s| base().checked_add(s))
.map_err(decode_err)
}

accepts!(TIMESTAMP);
}

impl ToSql for DateTime {
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let v = self
.since(base())
.and_then(|s| s.round(round_us().relative(base())))
.map_err(transmit_err)?
.get_microseconds();
types::timestamp_to_sql(v, w);
Ok(IsNull::No)
}

accepts!(TIMESTAMP);
to_sql_checked!();
}

impl<'a> FromSql<'a> for Timestamp {
fn from_sql(_: &Type, raw: &[u8]) -> Result<Timestamp, Box<dyn Error + Sync + Send>> {
let v = types::timestamp_from_sql(raw)?;
Span::new()
.try_microseconds(v)
.and_then(|s| base_ts().checked_add(s))
.map_err(decode_err)
}

accepts!(TIMESTAMPTZ);
}

impl ToSql for Timestamp {
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let v = self
.since(base_ts())
.and_then(|s| s.round(round_us()))
.map_err(transmit_err)?
.get_microseconds();
types::timestamp_to_sql(v, w);
Ok(IsNull::No)
}

accepts!(TIMESTAMPTZ);
to_sql_checked!();
}

impl<'a> FromSql<'a> for Date {
fn from_sql(_: &Type, raw: &[u8]) -> Result<Date, Box<dyn Error + Sync + Send>> {
let v = types::date_from_sql(raw)?;
Span::new()
.try_days(v)
.and_then(|s| base().date().checked_add(s))
.map_err(decode_err)
}
accepts!(DATE);
}

impl ToSql for Date {
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let v = self.since(base().date()).map_err(transmit_err)?.get_days();
types::date_to_sql(v, w);
Ok(IsNull::No)
}

accepts!(DATE);
to_sql_checked!();
}

impl<'a> FromSql<'a> for Time {
fn from_sql(_: &Type, raw: &[u8]) -> Result<Time, Box<dyn Error + Sync + Send>> {
let v = types::time_from_sql(raw)?;
Span::new()
.try_microseconds(v)
.and_then(|s| Time::midnight().checked_add(s))
.map_err(decode_err)
}

accepts!(TIME);
}

impl ToSql for Time {
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let v = self
.since(Time::midnight())
.and_then(|s| s.round(round_us()))
.map_err(transmit_err)?
.get_microseconds();
types::time_to_sql(v, w);
Ok(IsNull::No)
}

accepts!(TIME);
to_sql_checked!();
}
2 changes: 2 additions & 0 deletions postgres-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -280,6 +280,8 @@ mod geo_types_06;
mod geo_types_07;
#[cfg(feature = "with-jiff-0_1")]
mod jiff_01;
#[cfg(feature = "with-jiff-0_2")]
mod jiff_02;
#[cfg(feature = "with-serde_json-1")]
mod serde_json_1;
#[cfg(feature = "with-smol_str-01")]
2 changes: 1 addition & 1 deletion postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

## Unreleased

## v0.19.01 - 2025-02-02
## v0.19.10 - 2025-02-02

### Added

3 changes: 2 additions & 1 deletion postgres/Cargo.toml
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ with-eui48-1 = ["tokio-postgres/with-eui48-1"]
with-geo-types-0_6 = ["tokio-postgres/with-geo-types-0_6"]
with-geo-types-0_7 = ["tokio-postgres/with-geo-types-0_7"]
with-jiff-0_1 = ["tokio-postgres/with-jiff-0_1"]
with-jiff-0_2 = ["tokio-postgres/with-jiff-0_2"]
with-serde_json-1 = ["tokio-postgres/with-serde_json-1"]
with-smol_str-01 = ["tokio-postgres/with-smol_str-01"]
with-uuid-0_8 = ["tokio-postgres/with-uuid-0_8"]
@@ -47,4 +48,4 @@ tokio-postgres = { version = "0.7.13", path = "../tokio-postgres" }
tokio = { version = "1.0", features = ["rt", "time"] }

[dev-dependencies]
criterion = "0.5"
criterion = "0.6"
2 changes: 2 additions & 0 deletions postgres/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Connection configuration.
#![allow(clippy::doc_overindented_list_items)]

use crate::connection::Connection;
use crate::Client;
use log::info;
3 changes: 1 addition & 2 deletions postgres/src/copy_in_writer.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@ impl Write for CopyInWriter<'_> {
}

fn flush(&mut self) -> io::Result<()> {
self.flush_inner()
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
self.flush_inner().map_err(io::Error::other)
}
}
2 changes: 1 addition & 1 deletion postgres/src/copy_out_reader.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ impl BufRead for CopyOutReader<'_> {
.block_on(async { stream.next().await.transpose() })
{
Ok(Some(cur)) => self.cur = cur,
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
Err(e) => return Err(io::Error::other(e)),
Ok(None) => break,
};
}
4 changes: 3 additions & 1 deletion tokio-postgres/Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ with-eui48-1 = ["postgres-types/with-eui48-1"]
with-geo-types-0_6 = ["postgres-types/with-geo-types-0_6"]
with-geo-types-0_7 = ["postgres-types/with-geo-types-0_7"]
with-jiff-0_1 = ["postgres-types/with-jiff-0_1"]
with-jiff-0_2 = ["postgres-types/with-jiff-0_2"]
with-serde_json-1 = ["postgres-types/with-serde_json-1"]
with-smol_str-01 = ["postgres-types/with-smol_str-01"]
with-uuid-0_8 = ["postgres-types/with-uuid-0_8"]
@@ -69,7 +70,7 @@ socket2 = { version = "0.5", features = ["all"] }

[dev-dependencies]
futures-executor = "0.3"
criterion = "0.5"
criterion = "0.6"
env_logger = "0.11"
tokio = { version = "1.0", features = [
"macros",
@@ -85,6 +86,7 @@ eui48-1 = { version = "1.0", package = "eui48", default-features = false }
geo-types-06 = { version = "0.6", package = "geo-types" }
geo-types-07 = { version = "0.7", package = "geo-types" }
jiff-01 = { version = "0.1", package = "jiff" }
jiff-02 = { version = "0.2", package = "jiff" }
serde-1 = { version = "1.0", package = "serde" }
serde_json-1 = { version = "1.0", package = "serde_json" }
smol_str-01 = { version = "0.1", package = "smol_str" }
2 changes: 2 additions & 0 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Connection configuration.
#![allow(clippy::doc_overindented_list_items)]

#[cfg(feature = "runtime")]
use crate::connect::connect;
use crate::connect_raw::connect_raw;
5 changes: 3 additions & 2 deletions tokio-postgres/src/connect_socket.rs
Original file line number Diff line number Diff line change
@@ -27,10 +27,11 @@ pub(crate) async fn connect_socket(
stream.set_nodelay(true).map_err(Error::connect)?;

let sock_ref = SockRef::from(&stream);

#[cfg(target_os = "linux")]
{
if let Some(tcp_user_timeout) = tcp_user_timeout {
sock_ref
.set_tcp_user_timeout(tcp_user_timeout)
.set_tcp_user_timeout(Some(tcp_user_timeout))
.map_err(Error::connect)?;
}

Loading