Skip to content

Arithmetic operation resulted in an overflow. #190

Open
@Schoof-T

Description

@Schoof-T

Describe the bug
When executing a procedure that has response data I get the exception 'Arithmetic operation resulted in an overflow.'

To Reproduce
Please provide C#/SQL necessary to reproduce the issue, and steps to follow:

  1. Table with the following columns
ALTER TABLE "User" ADD "UserID" NUMERIC(16,0) NOT NULL;
ALTER TABLE "User" ADD "LoginID" NVARCHAR(30) NOT NULL UNIQUE;
ALTER TABLE "User" ADD "Name" NVARCHAR(100) NOT NULL;
ALTER TABLE "User" ADD "Password" NVARCHAR(50) NULL DEFAULT '';
ALTER TABLE "User" ADD "EMail" NVARCHAR(100) NULL;
ALTER TABLE "User" ADD "IsCentral" SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE "User" ADD "TypeOfUser" SMALLINT NULL DEFAULT 6;
ALTER TABLE "User" ADD "Evaluation" SMALLINT NULL;
ALTER TABLE "User" ADD "Created_By" NVARCHAR(30) NOT NULL;
ALTER TABLE "User" ADD "Last_Updated_Date" TIMESTAMP NULL;
ALTER TABLE "User" ADD "Last_Updated_By" NVARCHAR(30) NULL;
ALTER TABLE "User" ADD "Creation_Date" TIMESTAMP NOT NULL DEFAULT CURRENT TIMESTAMP;
ALTER TABLE "User" ADD "Log_Annul" SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE "User" ADD "Status" SMALLINT NOT NULL DEFAULT 1;
ALTER TABLE "User" ADD "Last_Modified" TIMESTAMP NOT NULL DEFAULT TIMESTAMP;
ALTER TABLE "User" ADD "SID" NVARCHAR(100) NULL;
ALTER TABLE "User" ADD "PersonID" NUMERIC(16,0) NULL;;
  1. The following procedure
ALTER PROCEDURE "SP_Select_User"(
        in @UserID numeric(16) default null,
        in @SID nvarchar(100) default null,
        in @LoginID nvarchar(30) default null,
        in @Name nvarchar(100) default null )
        begin
        select U.UserID,U.LoginID,U.Name,U.Password,U.Email,U.TypeOfUser,U.SID,U.log_Annul,u.PersonID
        from user as U
        where(@UserID is null or U.UserID = @UserID)
        and(@LoginID is null or U.loginID = @LoginID)
        and(@Name is null or U.Name = @Name)
        and(@SID is null or U.SID = @SID)
        end
  1. Execute the following C#
            using (var conn = new AseConnection(_configuration["ConnectionStrings:Connection"]))
            {
                await conn.OpenAsync();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SP_Select_User";
                    cmd.CommandType = CommandType.StoredProcedure;

                    var parameterkes = new Dictionary<string, object>
                    {
                        { "USERID", null },
                        { "SID", "THISISMYSID" },
                        { "LOGINID", null },
                        { "NAME", null }
                    };

                    foreach (var parameter in parameters)
                    {
                        cmd.Parameters.AddWithValue(parameter.Key, parameter.Value ?? DBNull.Value);
                    }

                    using (var reader = await cmd.ExecuteReaderAsync())
                    {
                        var firstName = reader.GetString(0);
                        var lastName = reader.GetString(1);
                        ....
                    }
                }
            }
  1. Observe that the following output occurs at cmd.ExecuteReaderAsync():

System.OverflowException: 'Arithmetic operation resulted in an overflow.'
This exception was originally thrown at this call stack:
AdoNetCore.AseClient.Internal.StreamReadExtensions.ReadAseDecimal(System.IO.Stream, byte, byte) in StreamReadExtensions.cs
AdoNetCore.AseClient.Internal.ValueReader.ReadTDS_NUMN(System.IO.Stream, AdoNetCore.AseClient.Internal.FormatItem, AdoNetCore.AseClient.Internal.DbEnvironment) in ValueReader.cs
AdoNetCore.AseClient.Internal.ValueReader.ReadInternal(System.IO.Stream, AdoNetCore.AseClient.Internal.FormatItem, AdoNetCore.AseClient.Internal.DbEnvironment) in ValueReader.cs
AdoNetCore.AseClient.Token.RowToken.Read(System.IO.Stream, AdoNetCore.AseClient.Internal.DbEnvironment, AdoNetCore.AseClient.Interface.IFormatToken) in RowToken.cs
AdoNetCore.AseClient.Token.RowToken.Create(System.IO.Stream, AdoNetCore.AseClient.Internal.DbEnvironment, AdoNetCore.AseClient.Interface.IFormatToken) in RowToken.cs
AdoNetCore.AseClient.Internal.TokenReader.Read(AdoNetCore.AseClient.Internal.TokenReceiveStream, AdoNetCore.AseClient.Internal.DbEnvironment) in TokenReader.cs
AdoNetCore.AseClient.Internal.InternalConnection.InternalExecuteQueryAsync(AdoNetCore.AseClient.AseCommand, AdoNetCore.AseClient.AseTransaction, System.Threading.Tasks.TaskCompletionSource<System.Data.Common.DbDataReader>, System.Data.CommandBehavior) in InternalConnection.cs
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
...
[Call Stack Truncated]

Expected behavior
Not crashing and being able to read the data.

Environment

  • Core 3.1
  • AdoNetCore.AseClient 0.18.0)
  • SQL Anywhere 17

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    unsupported databaseIssue is experienced on a database that is not supported (ASE 15/16) by this driver

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions