Description
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.