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

Error in MySqlCommandBuilder.DeriveParameters() on procedure with Param-Type DECIMAL(10,0) UNSIGNED #1272

Closed
JoySurfer opened this issue Dec 29, 2022 · 2 comments
Assignees
Labels

Comments

@JoySurfer
Copy link

JoySurfer commented Dec 29, 2022

Software versions
MySqlConnector version: 2.2.4
Server type (MySQL, MariaDB, Aurora, etc.) and version: MariaDB 10.6.11
.NET version: 4.8.1
(Optional) ORM NuGet packages and versions:

Describe the bug
I want to use MySqlCommandBuilder.DeriveParameters to derive the params of a procedure "TestParam" with Param-Type DECIMAL(10,0) UNSIGNED and get an System.NullReferenceException

I created two procedures to verify, that the error comes from the Param-Type UNSIGNED.
The procedure TestParamX works fine.

CREATE PROCEDURE `TestParam`(
            IN `Param` DECIMAL(10,0) UNSIGNED
            )
        BEGIN

        END

CREATE PROCEDURE `TestParamX`(
            IN `Param` DECIMAL(10,0)
            )
        BEGIN

        END

Exception
System.NullReferenceException
HResult=0x80004003
Nachricht = Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Quelle = MySqlConnector
Stapelüberwachung:
at MySqlConnector.Core.CachedParameter..ctor(Int32 ordinalPosition, String mode, String name, String dataType, Boolean unsigned, Int32 length)
at MySqlConnector.Core.CachedProcedure.d__0.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at MySqlConnector.MySqlConnection.d__85.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MySqlConnector.MySqlCommandBuilder.d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MySqlConnector.MySqlCommandBuilder.DeriveParameters(MySqlCommand command)
at TestParam.Program.Main(String[] args) in

Diese Ausnahme wurde ursprünglich von dieser Aufrufliste ausgelöst:
[Externer Code]
TestParam.Program.Main(string[]) in Program.cs

Code sample

internal class Program
    {
        static void Main(string[] args)
        {
            var _strBuilder = new MySqlConnectionStringBuilder
            {
                Server = <server>,
                Database = <database>,
                UserID = <user>,
                Password = <password>,
                Pooling = true,
            };

            MySqlConnection _conn = new MySqlConnection(_strBuilder.ConnectionString);
            _conn.Open();

            var _cmd1 = new MySqlCommand("TestParamX", _conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            MySqlCommandBuilder.DeriveParameters(_cmd1);

            var _cmd2 = new MySqlCommand("TestParam", _conn)
            {
                CommandType = CommandType.StoredProcedure
            };

            MySqlCommandBuilder.DeriveParameters(_cmd2);

            _conn.Close();
        }
    }
/* A concise code sample to reproduce the bug */

Expected behavior
The MySqlCommandBuilder.DeriveParameters-method should derive the Param-Type DECIMAL(10,0) UNSIGNED without System.NullReferenceException.

Additional context
Add any other context about the problem here.

bgrainger added a commit that referenced this issue Dec 29, 2022
Signed-off-by: Bradley Grainger <bgrainger@gmail.com>
@bgrainger bgrainger self-assigned this Dec 29, 2022
@bgrainger bgrainger added the bug label Dec 29, 2022
@bgrainger
Copy link
Member

Thanks for the great bug report. This will be fixed in the next release. I can't think of a workaround until then (other than avoiding DeriveParameters).

@bgrainger
Copy link
Member

Fixed in 2.2.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants