Skip to content

Panic on infinity timestamp

Hello, thank you for making this helpful plugin. I noticed I would get a panic when trying to query rows from a table with an infinity timestamp value set. I was able to create a minimal reproducible example by running nuql query example "select 'infinity'::timestamptz". Doing so results in the crash. I ran the command with the environment variable RUST_BACKTRACE=full set. I am running this against PostgreSQL 11, but I suspect the version doesn't matter.

$ nuql query example "select 'infinity'::timestamptz"
thread 'plugin runner (primary)' panicked at /Users/buddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.39/src/naive/datetime/mod.rs:1631:38:
`NaiveDateTime + TimeDelta` overflowed
stack backtrace:
   0:        0x1052cb96c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha6cefd14d2f2d7e5
   1:        0x1052ea6c8 - core::fmt::write::h1e382716c466cb87
   2:        0x1052cb670 - std::io::Write::write_fmt::ha2e990706db73f8b
   3:        0x1052cb81c - std::sys::backtrace::BacktraceLock::print::h8074bfd934e129d0
   4:        0x1052c9de0 - std::panicking::default_hook::{{closure}}::h44ee746bd38cf66b
   5:        0x1052c9c6c - std::panicking::default_hook::hce6f69ba25229e55
   6:        0x1052ca2cc - std::panicking::rust_panic_with_hook::h81be36b1a1b75dad
   7:        0x1052cbe54 - std::panicking::begin_panic_handler::{{closure}}::h9b9000402640b825
   8:        0x1052cbbc4 - std::sys::backtrace::__rust_end_short_backtrace::h8226ce5e419b1bf0
   9:        0x1052c9e78 - _rust_begin_unwind
  10:        0x105309c34 - core::panicking::panic_fmt::h6a643067d42d3a70
  11:        0x105309b30 - core::option::expect_failed::h5dcf0fdf5c88b091
  12:        0x1050a158c - sqlx_postgres::types::chrono::datetime::<impl sqlx_core::decode::Decode<sqlx_postgres::database::Postgres> for chrono::naive::datetime::NaiveDateTime>::decode::h3e120db61085e14a
  13:        0x1050a15e8 - sqlx_postgres::types::chrono::datetime::<impl sqlx_core::decode::Decode<sqlx_postgres::database::Postgres> for chrono::datetime::DateTime<chrono::offset::fixed::FixedOffset>>::decode::h4fd5b1bec15a1173
  14:        0x10507b1a0 - sqlx_core::row::Row::try_get::h85f678611a926e66
  15:        0x10505c478 - futures_executor::local_pool::block_on::h5dbcdfc4f9a234f1
  16:        0x105070b14 - <nu_plugin_nupsql::query_commands::NuqlQuery as nu_plugin::plugin::command::SimplePluginCommand>::run::h6741e6992d930ef6
  17:        0x10506c8a8 - <T as nu_plugin::plugin::command::PluginCommand>::run::h4e541a04b2127048
  18:        0x104ff4df8 - nu_plugin::plugin::serve_plugin_io::{{closure}}::{{closure}}::h2cef89365d9da7cb
  19:        0x104fe7624 - std::sys::backtrace::__rust_begin_short_backtrace::h5ffa64193eeceb5d
  20:        0x104fec680 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h127b250f63779b20
  21:        0x1052af410 - std::sys::pal::unix::thread::Thread::new::thread_start::hf56e185417a4372a
  22:        0x181d2c2e4 - __pthread_deallocate
Error:
  × Failed to receive response to plugin call from `nupsql`
   ╭─[entry #2:1:1]
 1 │ nuql query example "select 'infinity'::timestamptz as ts"
   · ─────┬────
   ·      ╰── while waiting for this operation to complete
   ╰────
  help: try restarting the plugin with `plugin use 'nupsql'`