Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for cancel query by adding synchronous readers. #1246

Merged
merged 5 commits into from Sep 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs
Expand Up @@ -421,22 +421,22 @@ private async Task ExecuteOnce(DbConnection conn, CancellationToken cancellation
// key columns in the result set, even if they weren't part of the select statement.
// Extra key columns get added to the end, so just correlate via Column Ordinal.
columnSchemas = new List<DbColumn[]>();
using (DbDataReader reader = await dbCommand.ExecuteReaderAsync(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly, cancellationToken))
using (DbDataReader reader = dbCommand.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
{
if (reader != null && reader.CanGetColumnSchema())
{
do
{
columnSchemas.Add(reader.GetColumnSchema().ToArray());
} while (await reader.NextResultAsync(cancellationToken));
} while (reader.NextResult());
}
}
}

ConnectionService.EnsureConnectionIsOpen(conn);

// Execute the command to get back a reader
using (DbDataReader reader = await dbCommand.ExecuteReaderAsync(cancellationToken))
using (DbDataReader reader = dbCommand.ExecuteReader())
{
do
{
Expand Down Expand Up @@ -464,7 +464,7 @@ private async Task ExecuteOnce(DbConnection conn, CancellationToken cancellation
// Read until we hit the end of the result set
await resultSet.ReadResultToEnd(reader, cancellationToken);

} while (await reader.NextResultAsync(cancellationToken));
} while (reader.NextResult());

// If there were no messages, for whatever reason (NO COUNT set, messages
// were emitted, records returned), output a "successful" message
Expand Down