Skip to content

DuckDB.NET.Data.DuckDBException (0x0000001F): INTERNAL Error: Information loss on integer cast: value -1 outside of target range [0, 255] #303

@rynoV

Description

@rynoV
#:package DuckDB.NET.Data.Full@1.4.1
using System;
using DuckDB.NET.Data;

using var c = new DuckDBConnection(DuckDBConnectionStringBuilder.InMemoryConnectionString);
c.Open();

using (var comm = c.CreateCommand())
{
    comm.CommandText = "CREATE TABLE t(value DECIMAL);";
    comm.ExecuteNonQuery();
}

using (var comm = c.CreateCommand())
{
    comm.CommandText = "select count(*) from t where value = $value;";
    comm.Parameters.Add(new DuckDBParameter { Value = 0.09M, ParameterName = "value" });
    var count = (long)comm.ExecuteScalar();
    Console.WriteLine(count);
}
Output

Unhandled exception. DuckDB.NET.Data.DuckDBException (0x0000001F): INTERNAL Error: Information loss on integer cast: value -1 outside of target range [0, 255]

Stack Trace:

/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Exception::ToJSON(duckdb::ExceptionType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x56) [0x724e75e80526]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Exception::Exception(duckdb::ExceptionType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x14) [0x724e75e805e4]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::InternalException::InternalException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x11) [0x724e75e85421]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::InternalException::InternalException<int, unsigned char, unsigned char>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, unsigned char, unsigned char)+0x1e5) [0x724e75819305]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(+0x964535) [0x724e75164535]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(+0x976966) [0x724e75176966]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::BoundComparisonExpression::TryBindComparison(duckdb::ClientContext&, duckdb::LogicalType const&, duckdb::LogicalType const&, duckdb::LogicalType&, duckdb::ExpressionType)+0x136) [0x724e7543f016]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ExpressionBinder::BindExpression(duckdb::ComparisonExpression&, unsigned long)+0x236) [0x724e7544b026]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ExpressionBinder::BindExpression(duckdb::unique_ptr<duckdb::ParsedExpression, std::default_delete<duckdb::ParsedExpression>, true>&, unsigned long, bool)+0x299) [0x724e7551d1e9]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::WhereBinder::BindExpression(duckdb::unique_ptr<duckdb::ParsedExpression, std::default_delete<duckdb::ParsedExpression>, true>&, unsigned long, bool)+0x3e) [0x724e754df5ce]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ExpressionBinder::Bind(duckdb::unique_ptr<duckdb::ParsedExpression, std::default_delete<duckdb::ParsedExpression>, true>&, unsigned long, bool)+0xa0) [0x724e75511710]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ExpressionBinder::Bind(duckdb::unique_ptr<duckdb::ParsedExpression, std::default_delete<duckdb::ParsedExpression>, true>&, duckdb::optional_ptr<duckdb::LogicalType, true>, bool)+0x30) [0x724e75529a40]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::BindSelectNode(duckdb::SelectNode&, duckdb::unique_ptr<duckdb::BoundTableRef, std::default_delete<duckdb::BoundTableRef>, true>)+0x784) [0x724e75462b44]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::BindNode(duckdb::SelectNode&)+0x61) [0x724e75464e61]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::BindNode(duckdb::QueryNode&)+0x9e) [0x724e7551eaee]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::Bind(duckdb::QueryNode&)+0x2f) [0x724e7551eb4f]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::Bind(duckdb::SelectStatement&)+0x3a) [0x724e7546fcfa]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Binder::Bind(duckdb::SQLStatement&)+0x245) [0x724e7551f4a5]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::Planner::CreatePlan(duckdb::SQLStatement&)+0xa5) [0x724e7552bf35]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::CreatePreparedStatementInternal(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::unique_ptr<duckdb::SQLStatement, std::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, duckdb::BoundParameterData> > >, true>)+0x27e) [0x724e762e156e]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::CreatePreparedStatement(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::unique_ptr<duckdb::SQLStatement, std::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, duckdb::BoundParameterData> > >, true>, duckdb::PreparedStatementMode)+0x2f4) [0x724e762e2294]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::RebindPreparedStatement(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::shared_ptr<duckdb::PreparedStatementData, true>&, duckdb::PendingQueryParameters const&)+0x94) [0x724e762e2454]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::PendingPreparedStatement(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::shared_ptr<duckdb::PreparedStatementData, true>, duckdb::PendingQueryParameters const&)+0x3a9) [0x724e762e8069]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::PendingStatementOrPreparedStatement(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::unique_ptr<duckdb::SQLStatement, std::default_delete<duckdb::SQLStatement>, true>, duckdb::shared_ptr<duckdb::PreparedStatementData, true>&, duckdb::PendingQueryParameters const&)+0x1a1) [0x724e762ec881]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::PendingStatementOrPreparedStatementInternal(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::unique_ptr<duckdb::SQLStatement, std::default_delete<duckdb::SQLStatement>, true>, duckdb::shared_ptr<duckdb::PreparedStatementData, true>&, duckdb::PendingQueryParameters const&)+0x7f) [0x724e762ec99f]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::PendingQueryPreparedInternal(duckdb::ClientContextLock&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::shared_ptr<duckdb::PreparedStatementData, true>&, duckdb::PendingQueryParameters const&)+0x68) [0x724e762ecd48]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::ClientContext::PendingQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, duckdb::shared_ptr<duckdb::PreparedStatementData, true>&, duckdb::PendingQueryParameters const&)+0x4c) [0x724e762ecddc]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::PreparedStatement::PendingQuery(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, duckdb::BoundParameterData> > >&, bool)+0xf4) [0x724e762ecf14]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb::PreparedStatement::Execute(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, duckdb::BoundParameterData> > >&, bool)+0x1d) [0x724e762ecf7d]
/home/calum/.local/share/dotnet/runfile/t-6d1d3e88b705f3055f3901e4899177a17b5b202974bee56507a152e165feafac/bin/debug/runtimes/linux-x64/native/libduckdb.so(duckdb_execute_prepared+0x5a) [0x724e76206b9a]
[0x725e52ad6e2d]

This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/stable/dev/internal_errors
   at DuckDB.NET.Data.PreparedStatement.PreparedStatement.Execute(DuckDBParameterCollection parameterCollection, Boolean useStreamingMode)
   at DuckDB.NET.Data.PreparedStatement.PreparedStatement.PrepareMultiple(DuckDBNativeConnection connection, String query, DuckDBParameterCollection parameters, Boolean useStreamingMode)+MoveNext()
   at DuckDB.NET.Data.DuckDBDataReader.InitNextReader()
   at DuckDB.NET.Data.DuckDBDataReader..ctor(DuckDBCommand command, IEnumerable`1 queryResults, CommandBehavior behavior)
   at DuckDB.NET.Data.DuckDBCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at DuckDB.NET.Data.DuckDBCommand.ExecuteReader()
   at DuckDB.NET.Data.DuckDBCommand.ExecuteScalar()
   at Program.Main() in /home/calum/code/t.cs:line 22

I can't reproduce this on the duckdb command line with version 1.4.2. I also tried this with a local build of duckdb.net with 1.4.2 and had the same error. The error doesn't reproduce when the decimal value is at least 0.1

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