-
- Notifications
You must be signed in to change notification settings - Fork 74
Closed
Description
In Firebird4, when parameter get up-scaled to INT128
in the query ExecuteReader
throws an InvalidCastException
due to attempt to cast a boxed _value
to BigInteger
even if parameter was explicitly set to a different type.
NETProvider/src/FirebirdSql.Data.FirebirdClient/Common/DbValue.cs
Lines 250 to 253 in ebd58c4
public BigInteger GetInt128() | |
{ | |
return (BigInteger)_value; | |
} |
Code to reproduce:
var cmd = connection.CreateCommand(); cmd.CommandText = "select 1 from RDB$DATABASE where (cast(1 as bigint) * cast(1 as bigint)) = @x"; var p = cmd.CreateParameter(); p.ParameterName = "x"; p.DbType = DbType.Int32; p.Value = 2; cmd.Parameters.Add(p); _ = cmd.ExecuteReader();
Stack trace:
System.InvalidCastException : Unable to cast object of type 'System.Int32' to type 'System.Numerics.BigInteger'. at FirebirdSql.Data.Common.DbValue.GetInt128() at FirebirdSql.Data.Client.Managed.Version10.GdsStatement.WriteRawParameter(IXdrWriter xdr, DbField field) at FirebirdSql.Data.Client.Managed.Version13.GdsStatement.WriteParameters() at FirebirdSql.Data.Client.Managed.Version10.GdsStatement.SendExecuteToBuffer() at FirebirdSql.Data.Client.Managed.Version12.GdsStatement.Execute() at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader()