jhspetersson / fselect

Find files with SQL-like queries
https://fselect.rocks
Apache License 2.0
4.02k stars 85 forks source link

thread 'main' panicked at 'Illegal datetime format' #130

Closed steffenbusch closed 1 year ago

steffenbusch commented 1 year ago

I have made a small typo and used CUR_DATE instead of CURDATE in a query within the fselect interactive mode and got this panic termination instead of an error message:

[stbu@instance-20221129-1409 ~]$ RUST_BACKTRACE=full fselect -i
query> select * from /tmp where modified = CUR_DATE
thread 'main' panicked at 'Illegal datetime format', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/fselect-0.8.2/src/function.rs:209:22
stack backtrace:
   0:     0xaaaadc0a4f24 - std::backtrace_rs::backtrace::libunwind::trace::hc7f75b32c0689d70
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0xaaaadc0a4f24 - std::backtrace_rs::backtrace::trace_unsynchronized::h164689022fd6f73e
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0xaaaadc0a4f24 - std::sys_common::backtrace::_print_fmt::he9484e79d39a3f7a
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:65:5
   3:     0xaaaadc0a4f24 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e6dff1da54ef98d
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:44:22
   4:     0xaaaadbf63ce8 - core::fmt::write::hc446e03b1e01cc30
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/fmt/mod.rs:1213:17
   5:     0xaaaadc0881d4 - std::io::Write::write_fmt::h526cc884fdeb5eb2
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/io/mod.rs:1682:15
   6:     0xaaaadc0a5f1c - std::sys_common::backtrace::_print::h393dd98b7ebd466b
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:47:5
   7:     0xaaaadc0a5f1c - std::sys_common::backtrace::print::hebc7712091d53c41
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:34:9
   8:     0xaaaadc0a5b7c - std::panicking::default_hook::{{closure}}::h39baab9c8bcc3210
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:267:22
   9:     0xaaaadc0a6aa4 - std::panicking::default_hook::he6636537b1f4983b
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:286:9
  10:     0xaaaadc0a6aa4 - std::panicking::rust_panic_with_hook::h2719e7603a56e8f6
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:688:13
  11:     0xaaaadc0a65ac - std::panicking::begin_panic_handler::{{closure}}::h26590c80f5c9d176
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:577:13
  12:     0xaaaadc0a6544 - std::sys_common::backtrace::__rust_end_short_backtrace::hbbb8802048d8b87b
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/sys_common/backtrace.rs:137:18
  13:     0xaaaadc0a6520 - rust_begin_unwind
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
  14:     0xaaaadbf1f4a4 - core::panicking::panic_fmt::h44474eb81d069883
                               at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
  15:     0xaaaadbfc5fdc - fselect::function::Variant::to_datetime::hdd8f58092f4a09bc
  16:     0xaaaadbf9b790 - fselect::searcher::Searcher::conforms::h863b7effd039f0b8
  17:     0xaaaadbf98b9c - fselect::searcher::Searcher::check_file::ha41929d9610c0994
  18:     0xaaaadbf92290 - fselect::searcher::Searcher::visit_dir::h51bc5acbab8d67a7
  19:     0xaaaadbf8e400 - fselect::searcher::Searcher::list_search_results::hfa2fbb5ce9a0b591
  20:     0xaaaadbfdf5ec - fselect::exec_search::hec15703fba59e4bd
  21:     0xaaaadbfd6208 - fselect::main::h4ed73a46c323d07c
  22:     0xaaaadbfeee7c - std::sys_common::backtrace::__rust_begin_short_backtrace::h5f8bf84eec1dcf65
  23:     0xaaaadbfd4c64 - main
  24:     0xffffa44da6a4 - __libc_start_main
  25:     0xaaaadbf3588c - <unknown>
[stbu@instance-20221129-1409 ~]$

My environment:

jhspetersson commented 1 year ago

Thank you very much for reporting the issue! Replaced panic with an error message, and added a synonym for CURDATE function... just in case :)

steffenbusch commented 1 year ago

Thank you very much. fselect is an awesome tool.