Skip to content

time types panic on overflow #1171

Open
@allan2

Description

@allan2

When constructing time types using out-of-range values, panic occurs.
This affects most of the FromSql and ToSql implementations for time 0.2 and 0.3.

let row = client.query_one("SELECT 'infinity'::timestamp", &[])?;
let res = row.try_get::<_, time::PrimitiveDateTime>(0);  // this panics

Minimal example here --> allan2/postgres-time-overflow

The fix is to use fallible operations like checked_add and try_from.
An infinity test like test_special_params_without_wrapper should also be added for time. [1].

I have a PR in the works but I will wait for #1164 and #1170 first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions