Bug #100208 GetSchema("Procedures") returns ROUTINE_DEFINITION of "System.Byte[]"
Submitted: 14 Jul 2020 6:39 Modified: 27 Jul 2020 18:40
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.21 OS:Windows (10)
Assigned to: CPU Architecture:Any

[14 Jul 2020 6:39] Bradley Grainger
Description:
As of Connector/NET 8.0.21, the "ROUTINE_DEFINITION" column in the DataTable returned by MySqlConnection.GetSchema("Procedures") is always the literal string "System.Byte[]", instead of the actual routine definition. This is a regression from 8.0.20.

How to repeat:
Run the following C# code:

using var connection = new MySqlConnection(connectionString);
connection.Open();

var table = connection.GetSchema("Procedures");
var column = table.Rows[0]["ROUTINE_DEFINITION"];

// prints: System.String
Console.WriteLine(column.GetType());

// prints: System.Byte[]
// in 8.0.20, this would print something like: BEGIN RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -2), '/', 1), 64); END
Console.WriteLine(column);
[14 Jul 2020 8:40] MySQL Verification Team
Hello Bradley,

Thank you for the report and test case.
Quickly ran your test case but seeing the actual routine definition as expected. Is anything which I'm missing which triggers the reported issue? Please let us know

- Env used
- VS 2019, .NET core 3.1 on Win 10

using MySql.Data.MySqlClient;
using System;

namespace Bug100208
{
    class Program
    {
        static void Main(string[] args)
        {
            using var connection = new MySqlConnection("server=localhost;port=3306;user id=root;password=mysql123!");
            connection.Open();

            var table = connection.GetSchema("Procedures");
            var column = table.Rows[0]["ROUTINE_DEFINITION"];

            // prints: System.String
            Console.WriteLine(column.GetType());

            // prints: System.Byte[]
            // in 8.0.20, this would print something like: BEGIN RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -2), '/', 1), 64); END
            Console.WriteLine(column);
        }
    }
}

- C/NET 8.0.21
System.String
BEGIN
    RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\', '/'), '/', -2), '/', 1), 64);
END

C:\Work\MySQLNet\source\Bug100208\Bug100208\bin\Debug\netcoreapp3.1\Bug100208.exe (process 20616) exited with code 0.
Press any key to close this window . . .

- C/NET 8.0.20

System.String
BEGIN
    RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\', '/'), '/', -2), '/', 1), 64);
END

C:\Work\MySQLNet\source\Bug100208\Bug100208\bin\Release\netcoreapp3.1\Bug100208.exe (process 23400) exited with code 0.
Press any key to close this window . . .

regards,
Umesh
[14 Jul 2020 15:07] Bradley Grainger
Thanks for the quick follow-up.

Maybe there might be a MySQL server configuration that causes it to send the ROUTINE_DEFINITION as a BLOB not a VARCHAR. I'll have to look into that further and see if I can determine what triggers it.
[14 Jul 2020 15:26] Bradley Grainger
The problem occurs with MySQL 5.7 but not 8.0.

I can reproduce the problem by running the server using Docker:

docker run -d --rm -e MYSQL_ROOT_PASSWORD=pass -p 3306:3306 mysql:5.7.31

However, I get the same results as your example output with the latest MySQL version:

docker run -d --rm -e MYSQL_ROOT_PASSWORD=pass -p 3306:3306 mysql:8.0.21

And again, note that there was no problem with mysql:5.7.31 when using MySql.Data 8.0.20.
[14 Jul 2020 15:33] Bradley Grainger
This change looks like it could be related: https://github.com/mysql/mysql-connector-net/commit/ea9f84899822936b401eafd251488f8e73f8d3...

If GetValue(GetOrdinal(column)) returns a byte[], then ToString will just return "System.Byte[]".
[15 Jul 2020 5:28] MySQL Verification Team
Thank you for the feedback.
Verified as described.

- MySQL Server 5.7.30, C/NET 8.0.21, VS 2019

System.String
System.Byte[]

C:\Work\MySQLNet\source\Bug100208\Bug100208\bin\Release\netcoreapp3.1\Bug100208.exe (process 9788) exited with code 0.
Press any key to close this window . . .
[27 Jul 2020 18:40] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.22 release, and here's the proposed changelog entry from the documentation team:

MySqlConnection.GetSchema("Procedures") returned the literal string
System.Byte[] as the value of the ROUTINE_DEFINITION column, rather
than the actual routine definition.

Thank you for the bug report.