Skip to content

Commit 1c246cb

Browse files
committed
Fix trailing comment being counted as a separate result set.
1 parent 2fe3e71 commit 1c246cb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ private async Task<ResultSet> ScanResultSetAsyncAwaited(IOBehavior ioBehavior, R
144144
try
145145
{
146146
m_resultSetBuffered = await resultSet.ReadResultSetHeaderAsync(ioBehavior).ConfigureAwait(false);
147+
if (m_resultSetBuffered.BufferState == ResultSetState.NoMoreData)
148+
m_resultSetBuffered = null;
147149
return m_resultSetBuffered;
148150
}
149151
catch (MySqlException ex) when (ex.Number == (int) MySqlErrorCode.QueryInterrupted)

tests/SideBySide/QueryTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,23 @@ public void ExecuteScalarReturnsDBNull()
532532
}
533533
}
534534

535+
[Fact]
536+
public void TrailingCommentIsNotAResultSet()
537+
{
538+
using (var command = m_database.Connection.CreateCommand())
539+
{
540+
command.CommandText = "select 0; -- trailing comment";
541+
using (var reader = command.ExecuteReader())
542+
{
543+
Assert.True(reader.Read());
544+
Assert.Equal(0, reader.GetInt32(0));
545+
Assert.False(reader.NextResult());
546+
Assert.False(reader.HasRows);
547+
Assert.False(reader.Read());
548+
}
549+
}
550+
}
551+
535552
[Fact]
536553
public void SumBytes()
537554
{

0 commit comments

Comments
 (0)