From de0fa82fc676b09c1ad18dfea8b3626b20aab847 Mon Sep 17 00:00:00 2001 From: Alex Ma Date: Mon, 20 Sep 2021 10:26:56 -0700 Subject: [PATCH] Fix for cancel query by adding synchronous readers. (#1246) * added WIP sync execute method * added syncexecuteonce * replaced executeonce with synchronous reading * removed batch.cs change * restore space --- .../QueryExecution/Batch.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs index db8639683a..efee66971e 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs @@ -421,14 +421,14 @@ 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(); - 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()); } } } @@ -436,7 +436,7 @@ private async Task ExecuteOnce(DbConnection conn, CancellationToken cancellation ConnectionService.EnsureConnectionIsOpen(conn); // Execute the command to get back a reader - using (DbDataReader reader = await dbCommand.ExecuteReaderAsync(cancellationToken)) + using (DbDataReader reader = dbCommand.ExecuteReader()) { do { @@ -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