Bug #101485 MySql.Data NuGet Package 8.0.22 JSON Issue
Submitted: 5 Nov 2020 23:13 Modified: 10 Aug 2022 21:16
Reporter: Matthew Clark Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: C#, json, MySQL, MySql.Data, nuget, regression

[5 Nov 2020 23:13] Matthew Clark
Description:
8.0.22 NuGet Package for MySql.Data breaks with C# code passing a JSON string to a JSON stored proc parameter. 

How to repeat:
C#
new MySqlParameter {ParameterName = "p_jsonValue", Value = jsonData.Json.ToString()}

MySQL Stored Proc:
IN p_jsonValue JSON

Always fails to pass data type.

Suggested fix:
This works in version 8.0.20 of the NuGet Package
[6 Nov 2020 7:53] MySQL Verification Team
Hello Matthew Clark,

Thank you for the report and feedback.
May I request you to please provide a simple test case(ideally, C# Program.cs, SQL statement to create stored procedure, create table and sample dataset if any) which manifest the reported problem? Thank you.

regards,
Umesh
[6 Nov 2020 13:22] Matthew Clark
Contains project file, setup script (replace databasename), and program.cs

Attachment: MySqlError.zip (application/x-zip-compressed, text), 1.49 KiB.

[6 Nov 2020 13:23] Matthew Clark
Attached sample console app.
If you update the csproj file from:
<PackageReference Include="MySql.Data" Version="8.0.22" />
to
<PackageReference Include="MySql.Data" Version="8.0.20" />

The stored procedure will work. In reproducing the error it does seem more related if you have new lines in JSON string passed which works on 8.0.20 automatically but not on 8.0.22
[7 Nov 2020 5:29] MySQL Verification Team
Thank you for providing the requested details.

regards,
Umesh
[7 Nov 2020 5:29] MySQL Verification Team
- C/NET 8.0.22

nter DB Server Name
localhost
Enter DB database name
bug
Enter SQL username
ushastry
Enter SQL password
mysql123
MySqlDb::RunStoredProcedure() Error running stored procedure: MySql.Data.MySqlClient.MySqlException (0x80004005): Unhandled type encountered
   at MySql.Data.Types.MetaData.NameToType(String typeName, Boolean unsigned, Boolean realAsFloat, MySqlConnection connection)
   at MySql.Data.MySqlClient.StoredProcedure.GetAndFixParameter(String spName, MySqlSchemaRow param, Boolean realAsFloat, MySqlParameter returnParameter)
   at MySql.Data.MySqlClient.StoredProcedure.CheckParameters(String spName)
   at MySql.Data.MySqlClient.StoredProcedure.Resolve(Boolean preparing)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at MySqlError.Program.Main(String[] args) in C:\Work\MySQLNet\source\101485\Program.cs:line 31
Press Enter To Exit

-- C/NET 8.0.20

Enter DB Server Name
localhost
Enter DB database name
bug
Enter SQL username
ushastry
Enter SQL password
mysql123
Stored Proc Executed Successfully
Press Enter To Exit
[9 Nov 2020 1:09] Bradley Grainger
Confirmed the following exception (for MySql.Data 8.0.22) in a MySqlConnector integration test: https://github.com/mysql-net/MySqlConnector/commit/89bb1026d47ee76694a12ec5cd1f55407b2283b...

MySql.Data.MySqlClient.MySqlException : Unhandled type encountered
Stack Trace:
   at MySql.Data.Types.MetaData.NameToType(String typeName, Boolean unsigned, Boolean realAsFloat, MySqlConnection connection)
   at MySql.Data.MySqlClient.StoredProcedure.GetAndFixParameter(String spName, MySqlSchemaRow param, Boolean realAsFloat, MySqlParameter returnParameter)
   at MySql.Data.MySqlClient.StoredProcedure.CheckParameters(String spName)
   at MySql.Data.MySqlClient.StoredProcedure.Resolve(Boolean preparing)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()

Doesn't repro in MySqlConnector: https://www.nuget.org/packages/MySqlConnector/
[10 Aug 2022 21:16] Daniel Valdez
Duplicate of Bug #101302.