Bug #87868 Unexpected ColumnSize for CHAR(36) and BLOB columns in GetSchemaTable
Submitted: 26 Sep 2017 12:34 Modified: 12 Dec 2017 23:49
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.9.9 OS:Microsoft Windows (10.0.15063 x64)
Assigned to: CPU Architecture:Any

[26 Sep 2017 12:34] Bradley Grainger
The "ColumnSize" value returned by MySqlDataReader.GetSchemaTable has unexpected values for CHAR(36) and the various BLOB data types.

CHAR(36) has a ColumnSize of 36, 72, 108, or 144 depending on the table's character set. 

The ColumnSize for TINYBLOB/BLOB/etc. appears to be divided by 3.

How to repeat:
Execute the following SQL:
	create schema schema_table collate utf8_bin;
	create table schema_table.datatypes(
		char36 char(36),
		char37 char(37),			
		`tinyblob` tinyblob,
		`blob` blob
	insert into schema_table.datatypes values('test', 'test', _binary'test', _binary'test');

Then run this C# code:
	using (var connection = new MySqlConnection("... connection string ..."))
		using (var cmd = connection.CreateCommand())
			cmd.CommandText = "SELECT * FROM schema_table.datatypes;";
			using (var reader = cmd.ExecuteReader())
				var schemaTable = reader.GetSchemaTable();
				Console.WriteLine(schemaTable.Rows[0]["ColumnSize"]); // prints 108; expected 36
				Console.WriteLine(schemaTable.Rows[1]["ColumnSize"]); // prints 37, as expected
				Console.WriteLine(schemaTable.Rows[2]["ColumnSize"]); // prints 85; expected 255
				Console.WriteLine(schemaTable.Rows[3]["ColumnSize"]); // prints 21845; expected 65535

Suggested fix:
The ColumnSize returned in GetSchemaTable should match the column definition in the "CREATE TABLE" SQL, regardless of the table's/schema's default character set.
[27 Sep 2017 5:32] Chiranjeevi Battula
Hello Bradley Grainger,

Thank you for the bug report and test case.
Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.9 version.

[27 Sep 2017 5:32] Chiranjeevi Battula

Attachment: Bug_87868.JPG (image/jpeg, text), 174.83 KiB.

[12 Dec 2017 23:49] Christine Cole
Posted by developer:
Fixed as of the upcoming MySQL Connector/NET 6.9.11 release, and here's the changelog entry:

The MySqlDataReader.GetSchemaTable method returned different column-size
values when used with different character sets.

Thank you for the bug report.