Description
Description
When accessing a Vertica Database via System.Data.Odbc, the expected behavior of closing the underlying connection upon calling ExecuteReaderAsync(CommandBehavior.CloseConnection) is not observed. Despite disposing of the DbDataReader object returned by this method, the connection.State remains Open, indicating that the associated connection is not being closed as intended.
Reproduction Steps
public static async Task ExecuteReaderAsync()
{
string sqlQuery = "SELECT {ColumnName} FROM {SchemaName.TableName};";
var connection = new OdbcConnection("Driver=Vertica;{VerticaDatabase_Connection_String}");
DbDataReader dataReader;
await using (var command = connection.CreateCommand())
{
command.CommandText = sqlQuery;
command.CommandType = CommandType.Text;
await connection.OpenAsync();
dataReader = await command.ExecuteReaderAsync(CommandBehavior.CloseConnection);
}
using (dataReader)
{
while (await dataReader.ReadAsync())
{
Console.WriteLine(dataReader["ColumnName"]);
}
}
Console.WriteLine(connection.State);
}
Expected behavior
When the ExecuteReaderAsync method is invoked with the CommandBehavior.CloseConnection enum, the underlying connection should automatically close upon disposing or closing the DbDataReader object returned by this method.
Actual behavior
Upon calling the ExecuteReaderAsync method with the CommandBehavior.CloseConnection enum, the underlying connection remains open even after disposing or closing the DbDataReader object returned by this method.
Regression?
I've tested two versions of System.Data.Odbc (6.0.1 & 8.0.0), and both exhibit the same issue.
Known Workarounds
No response
Configuration
- Which version of .NET is the code running on? -> .NET 6
- What OS and version ? -> Windows 11
- What is the architecture ? -> x64
Other information
No response