Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic operation resulted in an overflow. #190

Open
Schoof-T opened this issue Aug 11, 2020 · 2 comments
Open

Arithmetic operation resulted in an overflow. #190

Schoof-T opened this issue Aug 11, 2020 · 2 comments
Labels
unsupported database Issue is experienced on a database that is not supported (ASE 15/16) by this driver

Comments

@Schoof-T
Copy link

Schoof-T commented Aug 11, 2020

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

@formicas formicas added the unsupported database Issue is experienced on a database that is not supported (ASE 15/16) by this driver label Aug 12, 2020
@formicas
Copy link
Contributor

@TSSchoof thanks for the detailed repro instructions. It'll be interesting to see if this can be reproduced against an ASE DB.

@Schoof-T
Copy link
Author

Schoof-T commented Aug 12, 2020

@formicas Oh my apologies, I thought SQL Anywhere17 was also supported. :)
It's a shame because there aren't any other .NET Core tools out there that do work with Sybase. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unsupported database Issue is experienced on a database that is not supported (ASE 15/16) by this driver
Projects
None yet
Development

No branches or pull requests

2 participants