From 3392f93a2eceefc6d53c7d783cef7984ebcf7791 Mon Sep 17 00:00:00 2001 From: Kevin Cunnane Date: Wed, 25 Oct 2017 12:06:22 -0700 Subject: [PATCH] Add rowcount check so that no results error is sent for a query where no rows are returned (#525) --- .../QueryExecution/QueryExecutionService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs index 29d3ad98..e2dc2c25 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs @@ -229,13 +229,15 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution try { // check to make sure any results were recieved - if (query.Batches.Length == 0 || query.Batches[0].ResultSets.Count == 0) + if (query.Batches.Length == 0 + || query.Batches[0].ResultSets.Count == 0 + || query.Batches[0].ResultSets[0].RowCount == 0) { await requestContext.SendError(SR.QueryServiceResultSetHasNoResults); return; } - var rowCount = query.Batches[0].ResultSets[0].RowCount; + long rowCount = query.Batches[0].ResultSets[0].RowCount; // check to make sure there is a safe amount of rows to load into memory if (rowCount > Int32.MaxValue) {