Skip to content

Cannot get value from Columm type float , double or decimal in mysql 5.8 aka 8.2 #3144

@sirlordt

Description

@sirlordt

Bug Description

When i try to get values of columns float, double or decimal. The main thread is panicked.

let data_decimal = row.get::<Option<f64>, _>(1); //Panic
let data_float = row.get::<Option<f64>, _>(2); //Panic
let data_double = row.get::<Option<f64>, _>(3); //Panic

###CallStack

thread 'main' panicked at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/byteorder-1.5.0/src/lib.rs:2139:31:
range end index 8 out of range for slice of length 4
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::slice::index::slice_end_index_len_fail_rt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:76:5
   3: core::slice::index::slice_end_index_len_fail
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:68:9
   4: <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:394:13
   5: <core::ops::range::RangeTo<usize> as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:441:9
   6: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:18:9
   7: <byteorder::LittleEndian as byteorder::ByteOrder>::read_u64
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/byteorder-1.5.0/src/lib.rs:2139:31
   8: byteorder::ByteOrder::read_f64
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/byteorder-1.5.0/src/lib.rs:749:24
   9: sqlx_mysql::types::float::<impl sqlx_core::decode::Decode<sqlx_mysql::database::MySql> for f64>::decode
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-mysql-0.7.4/src/types/float.rs:73:41
  10: <core::option::Option<T> as sqlx_core::decode::Decode<DB>>::decode
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.4/src/decode.rs:76:21
  11: sqlx_core::row::Row::try_get
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.4/src/row.rs:128:9
  12: sqlx_core::row::Row::get
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.4/src/row.rs:72:9
  13: sqlx_mysql_tokio_01::do_query_01_mysql::{{closure}}
             at ./src/main.rs:110:82
  14: sqlx_mysql_tokio_01::main::{{closure}}
             at ./src/main.rs:159:10
  15: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/park.rs:281:63
  16: tokio::runtime::coop::with_budget
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
  17: tokio::runtime::coop::budget
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
  18: tokio::runtime::park::CachedParkThread::block_on
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/park.rs:281:31
  19: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/blocking.rs:66:9
  20: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  21: tokio::runtime::context::runtime::enter_runtime
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/runtime.rs:65:16
  22: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  23: tokio::runtime::runtime::Runtime::block_on
             at /home/dsystems01/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/runtime.rs:350:45
  24: sqlx_mysql_tokio_01::main
             at ./src/main.rs:135:5
  25: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Minimal Reproduction

Define a table like

CREATE TABLE test (
decimal decimal(10,2) DEFAULT NULL,
float float(10,2) DEFAULT NULL,
double double(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

Insert info

Insert Into test values(10.340,10.345,10.234)

Info

  • SQLx version: [0.7]
  • SQLx features enabled: ["runtime-tokio", "macros", "mysql", "time"]
  • Database server and version: [MYSQL 5.8]
  • Operating system: [LINUX UBUNTU 22.04]
  • rustc --version: [rustc 1.76.0 (07dca489a 2024-02-04)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions