Bug #120347 "IsAutoIncrement" in GetSchemaTable is False in 9.7.0 (regression)
Submitted: 27 Apr 4:05 Modified: 27 Apr 4:08
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:9.7.0 OS:Windows (11)
Assigned to: CPU Architecture:x86

[27 Apr 4:05] Bradley Grainger
Description:
The MySqlDataReader.GetSchemaTable method returns a schema table for the current result set. If an "auto_increment" column is being queried, it is expected that the "IsAutoIncrement" field in the row in the schema table representing that column will be True.

It was True in MySQL Connector/NET 9.6.0 and earlier. In 9.7.0 it now incorrectly returns False.

How to repeat:
Create test.cs as follows and execute 'dotnet run test.cs' (with .NET 10):

#:property PublishAot=false
// use 9.6.0 below to see the expected behavior in the previous version
#:package MySql.Data@9.7.0

using MySql.Data.MySqlClient;

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

using var command = new MySqlCommand("""
	DROP TABLE IF EXISTS test;
	CREATE TABLE test(rowid integer not null primary key auto_increment);
	""", connection);
command.ExecuteNonQuery();

command.CommandText = "select rowid from test";
using (var reader = command.ExecuteReader())
{
	// prints False; expected True
    Console.WriteLine(reader.GetSchemaTable().Rows[0]["IsAutoIncrement"]);
}
await using (var reader = await command.ExecuteReaderAsync())
{
	// prints False; expected True
	Console.WriteLine((await reader.GetSchemaTableAsync()).Rows[0]["IsAutoIncrement"]);
}
[27 Apr 4:08] Bradley Grainger
The same regression (change from True to False) also happens for the "IsKey" column.