mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Query execution settings support (#812)
* WIP * WIP 3 * WIP 3 * Additional query settings updates * Add settings tets * Address code review feeback * Updates from testing
This commit is contained in:
@@ -17,9 +17,9 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
Options = new Dictionary<string, object>();
|
Options = new Dictionary<string, object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetOptionValue<T>(string name)
|
public T GetOptionValue<T>(string name, T defaultValue = default(T))
|
||||||
{
|
{
|
||||||
T result = default(T);
|
T result = defaultValue;
|
||||||
if (Options != null && Options.ContainsKey(name))
|
if (Options != null && Options.ContainsKey(name))
|
||||||
{
|
{
|
||||||
object value = Options[name];
|
object value = Options[name];
|
||||||
@@ -29,7 +29,7 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
result = default(T);
|
result = defaultValue;
|
||||||
Logger.Write(TraceEventType.Warning, string.Format(CultureInfo.InvariantCulture,
|
Logger.Write(TraceEventType.Warning, string.Format(CultureInfo.InvariantCulture,
|
||||||
"Cannot convert option value {0}:{1} to {2}", name, value ?? "", typeof(T)));
|
"Cannot convert option value {0}:{1} to {2}", name, value ?? "", typeof(T)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
internal class JobNotificationsActions : ManagementActionBase
|
internal class JobNotificationsActions : ManagementActionBase
|
||||||
{
|
{
|
||||||
private JobData data;
|
private JobData data;
|
||||||
private bool loading = false;
|
|
||||||
|
|
||||||
public JobNotificationsActions(CDataContainer dataContainer, JobData data)
|
public JobNotificationsActions(CDataContainer dataContainer, JobData data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -545,10 +545,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the file open notification
|
/// Handle the file open notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="uri"></param>
|
||||||
/// <param name="scriptFile"></param>
|
/// <param name="scriptFile"></param>
|
||||||
/// <param name="eventContext"></param>
|
/// <param name="eventContext"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task HandleDidOpenTextDocumentNotification(
|
public async Task HandleDidOpenTextDocumentNotification(
|
||||||
|
string uri,
|
||||||
ScriptFile scriptFile,
|
ScriptFile scriptFile,
|
||||||
EventContext eventContext)
|
EventContext eventContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,13 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
|||||||
private CDataContainer dataContainer;
|
private CDataContainer dataContainer;
|
||||||
//whether we assume complete ownership over it.
|
//whether we assume complete ownership over it.
|
||||||
//We set this member once the dataContainer is set to be non-null
|
//We set this member once the dataContainer is set to be non-null
|
||||||
private bool ownDataContainer = true;
|
private bool ownDataContainer = true;
|
||||||
|
|
||||||
//if derived class tries to call a protected method that relies on service provider,
|
|
||||||
//and the service provider hasn't been set yet, we will cache the values and will
|
|
||||||
//propagate them when we get the provider set
|
|
||||||
//private System.Drawing.Icon cachedIcon = null;
|
|
||||||
private string cachedCaption = null;
|
|
||||||
|
|
||||||
//SMO Server connection that MUST be used for all enumerator calls
|
//SMO Server connection that MUST be used for all enumerator calls
|
||||||
//We'll get this object out of CDataContainer, that must be initialized
|
//We'll get this object out of CDataContainer, that must be initialized
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||||
{
|
{
|
||||||
@@ -94,7 +95,13 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// <param name="connection">The information of the connection to use to execute the query</param>
|
/// <param name="connection">The information of the connection to use to execute the query</param>
|
||||||
/// <param name="settings">Settings for how to execute the query, from the user</param>
|
/// <param name="settings">Settings for how to execute the query, from the user</param>
|
||||||
/// <param name="outputFactory">Factory for creating output files</param>
|
/// <param name="outputFactory">Factory for creating output files</param>
|
||||||
public Query(string queryText, ConnectionInfo connection, QueryExecutionSettings settings, IFileStreamFactory outputFactory, bool getFullColumnSchema = false)
|
public Query(
|
||||||
|
string queryText,
|
||||||
|
ConnectionInfo connection,
|
||||||
|
QueryExecutionSettings settings,
|
||||||
|
IFileStreamFactory outputFactory,
|
||||||
|
bool getFullColumnSchema = false,
|
||||||
|
bool applyExecutionSettings = false)
|
||||||
{
|
{
|
||||||
// Sanity check for input
|
// Sanity check for input
|
||||||
Validate.IsNotNull(nameof(queryText), queryText);
|
Validate.IsNotNull(nameof(queryText), queryText);
|
||||||
@@ -129,20 +136,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
BeforeBatches = new List<Batch>();
|
BeforeBatches = new List<Batch>();
|
||||||
AfterBatches = new List<Batch>();
|
AfterBatches = new List<Batch>();
|
||||||
|
|
||||||
if (DoesSupportExecutionPlan(connection))
|
if (applyExecutionSettings)
|
||||||
{
|
{
|
||||||
// Checking settings for execution plan options
|
ApplyExecutionSettings(connection, settings, outputFactory);
|
||||||
if (settings.ExecutionPlanOptions.IncludeEstimatedExecutionPlanXml)
|
|
||||||
{
|
|
||||||
// Enable set showplan xml
|
|
||||||
AddBatch(string.Format(SetShowPlanXml, On), BeforeBatches, outputFactory);
|
|
||||||
AddBatch(string.Format(SetShowPlanXml, Off), AfterBatches, outputFactory);
|
|
||||||
}
|
|
||||||
else if (settings.ExecutionPlanOptions.IncludeActualExecutionPlanXml)
|
|
||||||
{
|
|
||||||
AddBatch(string.Format(SetStatisticsXml, On), BeforeBatches, outputFactory);
|
|
||||||
AddBatch(string.Format(SetStatisticsXml, Off), AfterBatches, outputFactory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,6 +505,118 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
batchSet.Add(new Batch(query, null, batchSet.Count, outputFactory, 1));
|
batchSet.Add(new Batch(query, null, batchSet.Count, outputFactory, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ApplyExecutionSettings(
|
||||||
|
ConnectionInfo connection,
|
||||||
|
QueryExecutionSettings settings,
|
||||||
|
IFileStreamFactory outputFactory)
|
||||||
|
{
|
||||||
|
QuerySettingsHelper helper = new QuerySettingsHelper(settings);
|
||||||
|
|
||||||
|
// set query execution plan options
|
||||||
|
if (DoesSupportExecutionPlan(connection))
|
||||||
|
{
|
||||||
|
// Checking settings for execution plan options
|
||||||
|
if (settings.ExecutionPlanOptions.IncludeEstimatedExecutionPlanXml)
|
||||||
|
{
|
||||||
|
// Enable set showplan xml
|
||||||
|
AddBatch(string.Format(SetShowPlanXml, On), BeforeBatches, outputFactory);
|
||||||
|
AddBatch(string.Format(SetShowPlanXml, Off), AfterBatches, outputFactory);
|
||||||
|
}
|
||||||
|
else if (settings.ExecutionPlanOptions.IncludeActualExecutionPlanXml)
|
||||||
|
{
|
||||||
|
AddBatch(string.Format(SetStatisticsXml, On), BeforeBatches, outputFactory);
|
||||||
|
AddBatch(string.Format(SetStatisticsXml, Off), AfterBatches, outputFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder builderBefore = new StringBuilder(512);
|
||||||
|
StringBuilder builderAfter = new StringBuilder(512);
|
||||||
|
|
||||||
|
if (!connection.IsSqlDW)
|
||||||
|
{
|
||||||
|
// "set noexec off" should be the very first command, cause everything after
|
||||||
|
// corresponding "set noexec on" is not executed until "set noexec off"
|
||||||
|
// is encounted
|
||||||
|
if (!settings.NoExec)
|
||||||
|
{
|
||||||
|
builderBefore.AppendFormat("{0} ", helper.SetNoExecString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.StatisticsIO)
|
||||||
|
{
|
||||||
|
builderBefore.AppendFormat("{0} ", helper.GetSetStatisticsIOString(true));
|
||||||
|
builderAfter.AppendFormat("{0} ", helper.GetSetStatisticsIOString (false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.StatisticsTime)
|
||||||
|
{
|
||||||
|
builderBefore.AppendFormat("{0} ", helper.GetSetStatisticsTimeString (true));
|
||||||
|
builderAfter.AppendFormat("{0} ", helper.GetSetStatisticsTimeString(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.ParseOnly)
|
||||||
|
{
|
||||||
|
builderBefore.AppendFormat("{0} ", helper.GetSetParseOnlyString(true));
|
||||||
|
builderAfter.AppendFormat("{0} ", helper.GetSetParseOnlyString(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// append first part of exec options
|
||||||
|
builderBefore.AppendFormat("{0} {1} {2}",
|
||||||
|
helper.SetRowCountString, helper.SetTextSizeString, helper.SetNoCountString);
|
||||||
|
|
||||||
|
if (!connection.IsSqlDW)
|
||||||
|
{
|
||||||
|
// append second part of exec options
|
||||||
|
builderBefore.AppendFormat(" {0} {1} {2} {3} {4} {5} {6}",
|
||||||
|
helper.SetConcatenationNullString,
|
||||||
|
helper.SetArithAbortString,
|
||||||
|
helper.SetLockTimeoutString,
|
||||||
|
helper.SetQueryGovernorCostString,
|
||||||
|
helper.SetDeadlockPriorityString,
|
||||||
|
helper.SetTransactionIsolationLevelString,
|
||||||
|
// We treat XACT_ABORT special in that we don't add anything if the option
|
||||||
|
// isn't checked. This is because we don't want to be overwriting the server
|
||||||
|
// if it has a default of ON since that's something people would specifically
|
||||||
|
// set and having a client change it could be dangerous (the reverse is much
|
||||||
|
// less risky)
|
||||||
|
|
||||||
|
// The full fix would probably be to make the options tri-state instead of
|
||||||
|
// just on/off, where the default is to use the servers default. Until that
|
||||||
|
// happens though this is the best solution we came up with. See TFS#7937925
|
||||||
|
|
||||||
|
// Note that users can always specifically add SET XACT_ABORT OFF to their
|
||||||
|
// queries if they do truly want to set it off. We just don't want to
|
||||||
|
// do it silently (since the default is going to be off)
|
||||||
|
settings.XactAbortOn ? helper.SetXactAbortString : string.Empty);
|
||||||
|
|
||||||
|
// append Ansi options
|
||||||
|
builderBefore.AppendFormat(" {0} {1} {2} {3} {4} {5} {6}",
|
||||||
|
helper.SetAnsiNullsString, helper.SetAnsiNullDefaultString, helper.SetAnsiPaddingString,
|
||||||
|
helper.SetAnsiWarningsString, helper.SetCursorCloseOnCommitString,
|
||||||
|
helper.SetImplicitTransactionString, helper.SetQuotedIdentifierString);
|
||||||
|
|
||||||
|
// "set noexec on" should be the very last command, cause everything after it is not
|
||||||
|
// being executed unitl "set noexec off" is encounered
|
||||||
|
if (settings.NoExec)
|
||||||
|
{
|
||||||
|
builderBefore.AppendFormat("{0} ", helper.SetNoExecString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add connection option statements before query execution
|
||||||
|
if (builderBefore.Length > 0)
|
||||||
|
{
|
||||||
|
AddBatch(builderBefore.ToString(), BeforeBatches, outputFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add connection option statements after query execution
|
||||||
|
if (builderAfter.Length > 0)
|
||||||
|
{
|
||||||
|
AddBatch(builderAfter.ToString(), AfterBatches, outputFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Implementation
|
#region IDisposable Implementation
|
||||||
@@ -541,7 +649,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Does this connection support XML Execution plans
|
/// Does this connection support XML Execution plans
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool DoesSupportExecutionPlan(ConnectionInfo connectionInfo) {
|
private bool DoesSupportExecutionPlan(ConnectionInfo connectionInfo)
|
||||||
|
{
|
||||||
// Determining which execution plan options may be applied (may be added to for pre-yukon support)
|
// Determining which execution plan options may be applied (may be added to for pre-yukon support)
|
||||||
return (!connectionInfo.IsSqlDW && connectionInfo.MajorVersion >= 9);
|
return (!connectionInfo.IsSqlDW && connectionInfo.MajorVersion >= 9);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parameters for the query execution options request
|
||||||
|
/// </summary>
|
||||||
|
public class QueryExecutionOptionsParams
|
||||||
|
{
|
||||||
|
public string OwnerUri { get; set; }
|
||||||
|
|
||||||
|
public QueryExecutionSettings Options { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QueryExecutionOptionsRequest
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
RequestType<QueryExecutionOptionsParams, bool> Type =
|
||||||
|
RequestType<QueryExecutionOptionsParams, bool>.Create("query/setexecutionoptions");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,6 +109,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal ConcurrentDictionary<string, Query> ActiveQueries => queries.Value;
|
internal ConcurrentDictionary<string, Query> ActiveQueries => queries.Value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The collection of query execution options
|
||||||
|
/// </summary>
|
||||||
|
internal ConcurrentDictionary<string, QueryExecutionSettings> ActiveQueryExecutionSettings => queryExecutionSettings.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal task for testability
|
/// Internal task for testability
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -127,6 +132,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
private readonly Lazy<ConcurrentDictionary<string, Query>> queries =
|
private readonly Lazy<ConcurrentDictionary<string, Query>> queries =
|
||||||
new Lazy<ConcurrentDictionary<string, Query>>(() => new ConcurrentDictionary<string, Query>());
|
new Lazy<ConcurrentDictionary<string, Query>>(() => new ConcurrentDictionary<string, Query>());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal storage of active query settings
|
||||||
|
/// </summary>
|
||||||
|
private readonly Lazy<ConcurrentDictionary<string, QueryExecutionSettings>> queryExecutionSettings =
|
||||||
|
new Lazy<ConcurrentDictionary<string, QueryExecutionSettings>>(() => new ConcurrentDictionary<string, QueryExecutionSettings>());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Settings that will be used to execute queries. Internal for unit testing
|
/// Settings that will be used to execute queries. Internal for unit testing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -165,6 +176,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
serviceHost.SetRequestHandler(SaveResultsAsXmlRequest.Type, HandleSaveResultsAsXmlRequest);
|
serviceHost.SetRequestHandler(SaveResultsAsXmlRequest.Type, HandleSaveResultsAsXmlRequest);
|
||||||
serviceHost.SetRequestHandler(QueryExecutionPlanRequest.Type, HandleExecutionPlanRequest);
|
serviceHost.SetRequestHandler(QueryExecutionPlanRequest.Type, HandleExecutionPlanRequest);
|
||||||
serviceHost.SetRequestHandler(SimpleExecuteRequest.Type, HandleSimpleExecuteRequest);
|
serviceHost.SetRequestHandler(SimpleExecuteRequest.Type, HandleSimpleExecuteRequest);
|
||||||
|
serviceHost.SetRequestHandler(QueryExecutionOptionsRequest.Type, HandleQueryExecutionOptionsRequest);
|
||||||
|
|
||||||
|
// Register the file open update handler
|
||||||
|
WorkspaceService<SqlToolsSettings>.Instance.RegisterTextDocCloseCallback(HandleDidCloseTextDocumentNotification);
|
||||||
|
|
||||||
// Register handler for shutdown event
|
// Register handler for shutdown event
|
||||||
serviceHost.RegisterShutdownTask((shutdownParams, requestContext) =>
|
serviceHost.RegisterShutdownTask((shutdownParams, requestContext) =>
|
||||||
@@ -203,7 +218,15 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
// Use the internal handler to launch the query
|
// Use the internal handler to launch the query
|
||||||
WorkTask = Task.Run(async () =>
|
WorkTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await InterServiceExecuteQuery(executeParams, null, requestContext, queryCreateSuccessAction, queryCreateFailureAction, null, null);
|
await InterServiceExecuteQuery(
|
||||||
|
executeParams,
|
||||||
|
null,
|
||||||
|
requestContext,
|
||||||
|
queryCreateSuccessAction,
|
||||||
|
queryCreateFailureAction,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isQueryEditor(executeParams.OwnerUri));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -351,6 +374,33 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles a request to set query execution options
|
||||||
|
/// </summary>
|
||||||
|
internal async Task HandleQueryExecutionOptionsRequest(QueryExecutionOptionsParams queryExecutionOptionsParams,
|
||||||
|
RequestContext<bool> requestContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string uri = queryExecutionOptionsParams.OwnerUri;
|
||||||
|
if (ActiveQueryExecutionSettings.ContainsKey(uri))
|
||||||
|
{
|
||||||
|
QueryExecutionSettings settings;
|
||||||
|
ActiveQueryExecutionSettings.TryRemove(uri, out settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveQueryExecutionSettings.TryAdd(uri, queryExecutionOptionsParams.Options);
|
||||||
|
|
||||||
|
await requestContext.SendResult(true);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// This was unexpected, so send back as error
|
||||||
|
await requestContext.SendError(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles a request to get an execution plan
|
/// Handles a request to get an execution plan
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -524,7 +574,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
Func<Query, Task<bool>> queryCreateSuccessFunc,
|
Func<Query, Task<bool>> queryCreateSuccessFunc,
|
||||||
Func<string, Task> queryCreateFailFunc,
|
Func<string, Task> queryCreateFailFunc,
|
||||||
Query.QueryAsyncEventHandler querySuccessFunc,
|
Query.QueryAsyncEventHandler querySuccessFunc,
|
||||||
Query.QueryAsyncErrorEventHandler queryFailureFunc)
|
Query.QueryAsyncErrorEventHandler queryFailureFunc,
|
||||||
|
bool applyExecutionSettings = false)
|
||||||
{
|
{
|
||||||
Validate.IsNotNull(nameof(executeParams), executeParams);
|
Validate.IsNotNull(nameof(executeParams), executeParams);
|
||||||
Validate.IsNotNull(nameof(queryEventSender), queryEventSender);
|
Validate.IsNotNull(nameof(queryEventSender), queryEventSender);
|
||||||
@@ -533,7 +584,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get a new active query
|
// Get a new active query
|
||||||
newQuery = CreateQuery(executeParams, connInfo);
|
newQuery = CreateQuery(executeParams, connInfo, applyExecutionSettings);
|
||||||
if (queryCreateSuccessFunc != null && !await queryCreateSuccessFunc(newQuery))
|
if (queryCreateSuccessFunc != null && !await queryCreateSuccessFunc(newQuery))
|
||||||
{
|
{
|
||||||
// The callback doesn't want us to continue, for some reason
|
// The callback doesn't want us to continue, for some reason
|
||||||
@@ -615,19 +666,49 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
subsetParams.RowsStartIndex, subsetParams.RowsCount);
|
subsetParams.RowsStartIndex, subsetParams.RowsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle the file open notification
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scriptFile"></param>
|
||||||
|
/// <param name="eventContext"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task HandleDidCloseTextDocumentNotification(
|
||||||
|
string uri,
|
||||||
|
ScriptFile scriptFile,
|
||||||
|
EventContext eventContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// remove any query execution settings when an editor is closed
|
||||||
|
if (this.ActiveQueryExecutionSettings.ContainsKey(uri))
|
||||||
|
{
|
||||||
|
QueryExecutionSettings settings;
|
||||||
|
this.ActiveQueryExecutionSettings.TryRemove(uri, out settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Write(TraceEventType.Error, "Unknown error " + ex.ToString());
|
||||||
|
}
|
||||||
|
await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Helpers
|
#region Private Helpers
|
||||||
|
|
||||||
|
private Query CreateQuery(
|
||||||
|
ExecuteRequestParamsBase executeParams,
|
||||||
private Query CreateQuery(ExecuteRequestParamsBase executeParams, ConnectionInfo connInfo)
|
ConnectionInfo connInfo,
|
||||||
|
bool applyExecutionSettings)
|
||||||
{
|
{
|
||||||
// Attempt to get the connection for the editor
|
// Attempt to get the connection for the editor
|
||||||
ConnectionInfo connectionInfo;
|
ConnectionInfo connectionInfo;
|
||||||
if (connInfo != null) {
|
if (connInfo != null)
|
||||||
|
{
|
||||||
connectionInfo = connInfo;
|
connectionInfo = connInfo;
|
||||||
} else if (!ConnectionService.TryFindConnection(executeParams.OwnerUri, out connectionInfo))
|
}
|
||||||
|
else if (!ConnectionService.TryFindConnection(executeParams.OwnerUri, out connectionInfo))
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(executeParams.OwnerUri), SR.QueryServiceQueryInvalidOwnerUri);
|
throw new ArgumentOutOfRangeException(nameof(executeParams.OwnerUri), SR.QueryServiceQueryInvalidOwnerUri);
|
||||||
}
|
}
|
||||||
@@ -643,15 +724,39 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
oldQuery.Dispose();
|
oldQuery.Dispose();
|
||||||
ActiveQueries.TryRemove(executeParams.OwnerUri, out oldQuery);
|
ActiveQueries.TryRemove(executeParams.OwnerUri, out oldQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the current settings for executing the query with
|
// check if there are active query execution settings for the editor, otherwise, use the global settings
|
||||||
QueryExecutionSettings settings = Settings.QueryExecutionSettings;
|
QueryExecutionSettings settings;
|
||||||
|
if (this.ActiveQueryExecutionSettings.TryGetValue(executeParams.OwnerUri, out settings))
|
||||||
// Apply execution parameter settings
|
{
|
||||||
settings.ExecutionPlanOptions = executeParams.ExecutionPlanOptions;
|
// special-case handling for query plan options to maintain compat with query execution API parameters
|
||||||
|
// the logic is that if either the query execute API parameters or the active query setttings
|
||||||
|
// request a plan then enable the query option
|
||||||
|
ExecutionPlanOptions executionPlanOptions = executeParams.ExecutionPlanOptions;
|
||||||
|
if (settings.IncludeActualExecutionPlanXml)
|
||||||
|
{
|
||||||
|
executionPlanOptions.IncludeActualExecutionPlanXml = settings.IncludeActualExecutionPlanXml;
|
||||||
|
}
|
||||||
|
if (settings.IncludeEstimatedExecutionPlanXml)
|
||||||
|
{
|
||||||
|
executionPlanOptions.IncludeEstimatedExecutionPlanXml = settings.IncludeEstimatedExecutionPlanXml;
|
||||||
|
}
|
||||||
|
settings.ExecutionPlanOptions = executionPlanOptions;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settings = Settings.QueryExecutionSettings;
|
||||||
|
settings.ExecutionPlanOptions = executeParams.ExecutionPlanOptions;
|
||||||
|
}
|
||||||
|
|
||||||
// If we can't add the query now, it's assumed the query is in progress
|
// If we can't add the query now, it's assumed the query is in progress
|
||||||
Query newQuery = new Query(GetSqlText(executeParams), connectionInfo, settings, BufferFileFactory, executeParams.GetFullColumnSchema);
|
Query newQuery = new Query(
|
||||||
|
GetSqlText(executeParams),
|
||||||
|
connectionInfo,
|
||||||
|
settings,
|
||||||
|
BufferFileFactory,
|
||||||
|
executeParams.GetFullColumnSchema,
|
||||||
|
applyExecutionSettings);
|
||||||
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
|
if (!ActiveQueries.TryAdd(executeParams.OwnerUri, newQuery))
|
||||||
{
|
{
|
||||||
newQuery.Dispose();
|
newQuery.Dispose();
|
||||||
@@ -949,6 +1054,18 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify if the URI maps to a query editor document
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool isQueryEditor(string uri)
|
||||||
|
{
|
||||||
|
return (!string.IsNullOrWhiteSpace(uri)
|
||||||
|
&& (uri.StartsWith("untitled:")
|
||||||
|
|| uri.StartsWith("file:")));
|
||||||
|
}
|
||||||
|
|
||||||
~QueryExecutionService()
|
~QueryExecutionService()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Service for executing queries
|
||||||
|
/// </summary>
|
||||||
|
public class QuerySettingsHelper
|
||||||
|
{
|
||||||
|
//strings for various "SET <option> ON/OFF" statements
|
||||||
|
private static readonly string s_On = "ON";
|
||||||
|
private static readonly string s_Off = "OFF";
|
||||||
|
private static readonly string s_Low = "LOW";
|
||||||
|
private static readonly string s_Normal = "NORMAL";
|
||||||
|
private static readonly string s_SetNoCount = "SET NOCOUNT {0}";
|
||||||
|
private static readonly string s_SetConcatenationNull = "SET CONCAT_NULL_YIELDS_NULL {0}";
|
||||||
|
private static readonly string s_SetNumericAbort = "SET NUMERIC_ROUNDABORT {0}";
|
||||||
|
private static readonly string s_SetXACTAbort = "SET XACT_ABORT {0}";
|
||||||
|
private static readonly string s_SetArithAbort = "SET ARITHABORT {0}";
|
||||||
|
private static readonly string s_SetRowCount = "SET ROWCOUNT {0}";
|
||||||
|
private static readonly string s_SetLockTimeout = "SET LOCK_TIMEOUT {0}";
|
||||||
|
private static readonly string s_SetTextSize = "SET TEXTSIZE {0}";
|
||||||
|
private static readonly string s_SetQueryGovernorCost = "SET QUERY_GOVERNOR_COST_LIMIT {0}";
|
||||||
|
private static readonly string s_SetDeadlockPriority = "SET DEADLOCK_PRIORITY {0}";
|
||||||
|
private static readonly string s_SetTranIsolationLevel = "SET TRANSACTION ISOLATION LEVEL {0}";
|
||||||
|
private static readonly string s_SetAnsiNulls = "SET ANSI_NULLS {0}";
|
||||||
|
private static readonly string s_SetAnsiNullDefault = "SET ANSI_NULL_DFLT_ON {0}";
|
||||||
|
private static readonly string s_SetAnsiPadding = "SET ANSI_PADDING {0}";
|
||||||
|
private static readonly string s_SetAnsiWarnings = "SET ANSI_WARNINGS {0}";
|
||||||
|
private static readonly string s_SetCursorCloseOnCommit = "SET CURSOR_CLOSE_ON_COMMIT {0}";
|
||||||
|
private static readonly string s_SetImplicitTransaction = "SET IMPLICIT_TRANSACTIONS {0}";
|
||||||
|
private static readonly string s_SetQuotedIdentifier = "SET QUOTED_IDENTIFIER {0}";
|
||||||
|
private static readonly string s_SetNoExec = "SET NOEXEC {0}";
|
||||||
|
private static readonly string s_SetStatisticsTime = "SET STATISTICS TIME {0}";
|
||||||
|
private static readonly string s_SetStatisticsIO = "SET STATISTICS IO {0}";
|
||||||
|
private static readonly string s_SetParseOnly = "SET PARSEONLY {0}";
|
||||||
|
|
||||||
|
private QueryExecutionSettings settings;
|
||||||
|
|
||||||
|
public QuerySettingsHelper(QueryExecutionSettings settings)
|
||||||
|
{
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetNoCountString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetNoCount, (this.settings.NoCount ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetConcatenationNullString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetConcatenationNull, (this.settings.ConcatNullYieldsNull ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetNumericAbortString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetNumericAbort, (this.settings.ArithAbort ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetXactAbortString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetXACTAbort, (this.settings.XactAbortOn ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetArithAbortString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetArithAbort, (this.settings.ArithAbort ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetRowCountString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetRowCount, this.settings.RowCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetLockTimeoutString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetLockTimeout, this.settings.LockTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetTextSizeString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetTextSize, this.settings.TextSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetQueryGovernorCostString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetQueryGovernorCost, this.settings.QueryGovernorCostLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetDeadlockPriorityString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
|
||||||
|
bool isDeadlockPriorityLow = string.Compare(this.settings.DeadlockPriority, "low", StringComparison.OrdinalIgnoreCase) == 0;
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetDeadlockPriority, (isDeadlockPriorityLow ? s_Low : s_Normal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetTransactionIsolationLevelString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetTranIsolationLevel, this.settings.TransactionIsolationLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetAnsiNullsString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetAnsiNulls, (this.settings.AnsiNulls ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetAnsiNullDefaultString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetAnsiNullDefault, (this.settings.AnsiNullDefaultOn ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetAnsiPaddingString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetAnsiPadding, (this.settings.AnsiPadding ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetAnsiWarningsString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetAnsiWarnings, (this.settings.AnsiWarnings ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetCursorCloseOnCommitString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetCursorCloseOnCommit, (this.settings.CursorCloseOnCommit ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetImplicitTransactionString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetImplicitTransaction, (this.settings.ImplicitTransactions ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetQuotedIdentifierString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetQuotedIdentifier, (this.settings.QuotedIdentifier ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SetNoExecString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetNoExec, (this.settings.NoExec ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetSetStatisticsTimeString(bool? on)
|
||||||
|
{
|
||||||
|
on = on ?? this.settings.StatisticsTime;
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetStatisticsTime, (on.Value ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetSetStatisticsIOString(bool? on)
|
||||||
|
{
|
||||||
|
on = on ?? this.settings.StatisticsIO;
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetStatisticsIO, (on.Value ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetSetParseOnlyString(bool? on)
|
||||||
|
{
|
||||||
|
on = on ?? this.settings.ParseOnly;
|
||||||
|
return string.Format(System.Globalization.CultureInfo.InvariantCulture, s_SetParseOnly, (on.Value ? s_On : s_Off));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||||
|
using Microsoft.SqlTools.Utility;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collection of settings related to the execution of queries
|
/// Collection of settings related to the execution of queries
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class QueryExecutionSettings
|
public class QueryExecutionSettings : GeneralRequestDetails
|
||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// Default selection of returning an actual XML showplan with all batches
|
/// Default selection of returning an actual XML showplan with all batches
|
||||||
/// Do not return any execution plan by default
|
/// Do not return any execution plan by default
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly ExecutionPlanOptions DefaultExecutionPlanOptions = new ExecutionPlanOptions
|
private static ExecutionPlanOptions DefaultExecutionPlanOptions = new ExecutionPlanOptions
|
||||||
{
|
{
|
||||||
IncludeActualExecutionPlanXml = false,
|
IncludeActualExecutionPlanXml = false,
|
||||||
IncludeEstimatedExecutionPlanXml = false
|
IncludeEstimatedExecutionPlanXml = false
|
||||||
@@ -45,20 +46,128 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const bool DefaultDisplayBitAsNumber = true;
|
private const bool DefaultDisplayBitAsNumber = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default row count
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultRowCount = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default text size
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultTextSize = 2147483647;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default execution timeout
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultExecutionTimeout = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default no count
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultNoCount = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default no exec
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultNoExec = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default parse only
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultParseOnly = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default arith abort
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultArithAbort = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default concat null yields null
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultConcatNullYieldsNull = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default statistics time
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultStatisticsTime = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default statistics IO
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultStatisticsIO = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default transaction abort ON
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultXactAbortOn = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default ANSI padding
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultAnsiPadding = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default ANSI warnings
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultAnsiWarnings = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default ANSI Nulls
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultAnsiNulls = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default use ANSI defaults
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultAnsiDefaults = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default quoted identifier
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultQuotedIdentifier = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default ANSI NULL default ON
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultAnsiNullDefaultOn = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default implicit transactions
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultImplicitTransactions = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default cursor close on commit
|
||||||
|
/// </summary>
|
||||||
|
private const bool DefaultCursorCloseOnCommit = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default transaction isolation level
|
||||||
|
/// </summary>
|
||||||
|
private const string DefaultTransactionIsolationLevel = "READ UNCOMMITTED";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default deadlock priority
|
||||||
|
/// </summary>
|
||||||
|
private const string DefaultDeadlockPriority = "Normal";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default lock timeout
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultLockTimeout = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// default query governor cost limit
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultQueryGovernorCostLimit = 0;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Member Variables
|
#region Member Variables
|
||||||
|
|
||||||
private string batchSeparator;
|
|
||||||
|
|
||||||
private int? maxCharsToStore;
|
|
||||||
|
|
||||||
private int? maxXmlCharsToStore;
|
|
||||||
|
|
||||||
private ExecutionPlanOptions? executionPlanOptions;
|
private ExecutionPlanOptions? executionPlanOptions;
|
||||||
|
|
||||||
private bool? displayBitAsNumber;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
@@ -68,8 +177,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string BatchSeparator
|
public string BatchSeparator
|
||||||
{
|
{
|
||||||
get { return batchSeparator ?? DefaultBatchSeparator; }
|
get
|
||||||
set { batchSeparator = value; }
|
{
|
||||||
|
return GetOptionValue<string>("batchSeparator", DefaultBatchSeparator);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("batchSeparator", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -78,8 +193,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxCharsToStore
|
public int MaxCharsToStore
|
||||||
{
|
{
|
||||||
get { return maxCharsToStore ?? DefaultMaxCharsToStore; }
|
get
|
||||||
set { maxCharsToStore = value; }
|
{
|
||||||
|
return GetOptionValue<int>("maxCharsToStore", DefaultMaxCharsToStore);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("maxCharsToStore", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -88,8 +209,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxXmlCharsToStore
|
public int MaxXmlCharsToStore
|
||||||
{
|
{
|
||||||
get { return maxXmlCharsToStore ?? DefaultMaxXmlCharsToStore; }
|
get
|
||||||
set { maxXmlCharsToStore = value; }
|
{
|
||||||
|
return GetOptionValue<int>("maxXmlCharsToStore", DefaultMaxXmlCharsToStore);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("maxXmlCharsToStore", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -108,8 +235,389 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool DisplayBitAsNumber
|
public bool DisplayBitAsNumber
|
||||||
{
|
{
|
||||||
get { return displayBitAsNumber ?? DefaultDisplayBitAsNumber; }
|
get
|
||||||
set { displayBitAsNumber = value; }
|
{
|
||||||
|
return GetOptionValue<bool>("displayBitAsNumber", DefaultDisplayBitAsNumber);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("displayBitAsNumber", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set row count
|
||||||
|
/// </summary>
|
||||||
|
public int RowCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<int>("rowCount", DefaultRowCount);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("rowCount", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set text size
|
||||||
|
/// </summary>
|
||||||
|
public int TextSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<int>("textSize", DefaultTextSize);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("textSize", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set execution timeout
|
||||||
|
/// </summary>
|
||||||
|
public int ExecutionTimeout
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<int>("executionTimeout", DefaultExecutionTimeout);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("executionTimeout", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set no count
|
||||||
|
/// </summary>
|
||||||
|
public bool NoCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("noCount", DefaultNoCount);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("noCount", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set no exec
|
||||||
|
/// </summary>
|
||||||
|
public bool NoExec
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("noExec", DefaultNoExec);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("noExec", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set parse only
|
||||||
|
/// </summary>
|
||||||
|
public bool ParseOnly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("parseOnly", DefaultParseOnly);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("parseOnly", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set arith abort
|
||||||
|
/// </summary>
|
||||||
|
public bool ArithAbort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("arithAbort", DefaultArithAbort);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("arithAbort", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set concat null yields null
|
||||||
|
/// </summary>
|
||||||
|
public bool ConcatNullYieldsNull
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("concatNullYieldsNull", DefaultConcatNullYieldsNull);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("concatNullYieldsNull", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set statistics time
|
||||||
|
/// </summary>
|
||||||
|
public bool StatisticsTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("statisticsTime", DefaultStatisticsTime);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("statisticsTime", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set statistics I\O
|
||||||
|
/// </summary>
|
||||||
|
public bool StatisticsIO
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("statisticsIO", DefaultStatisticsIO);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("statisticsIO", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set transaction abort ON
|
||||||
|
/// </summary>
|
||||||
|
public bool XactAbortOn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("xactAbortOn", DefaultXactAbortOn);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("xactAbortOn", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set transaction isolation level
|
||||||
|
/// </summary>
|
||||||
|
public string TransactionIsolationLevel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<string>("transactionIsolationLevel", DefaultTransactionIsolationLevel);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("transactionIsolationLevel", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set deadlock priority
|
||||||
|
/// </summary>
|
||||||
|
public string DeadlockPriority
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<string>("deadlockPriority", DefaultDeadlockPriority);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("deadlockPriority", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set lock timeout
|
||||||
|
/// </summary>
|
||||||
|
public int LockTimeout
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<int>("lockTimeout", DefaultLockTimeout);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("lockTimeout", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set query governor cost limit
|
||||||
|
/// </summary>
|
||||||
|
public int QueryGovernorCostLimit
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<int>("queryGovernorCostLimit", DefaultQueryGovernorCostLimit);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("queryGovernorCostLimit", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set ANSI defaults ON
|
||||||
|
/// </summary>
|
||||||
|
public bool AnsiDefaults
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("ansiDefaults", DefaultAnsiDefaults);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("ansiDefaults", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set quoted identifier
|
||||||
|
/// </summary>
|
||||||
|
public bool QuotedIdentifier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("quotedIdentifier", DefaultQuotedIdentifier);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("quotedIdentifier", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set ANSI null default on
|
||||||
|
/// </summary>
|
||||||
|
public bool AnsiNullDefaultOn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("ansiNullDefaultOn", DefaultAnsiNullDefaultOn);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("ansiNullDefaultOn", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set implicit transactions
|
||||||
|
/// </summary>
|
||||||
|
public bool ImplicitTransactions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("implicitTransactions", DefaultImplicitTransactions);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("implicitTransactions", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set cursor close on commit
|
||||||
|
/// </summary>
|
||||||
|
public bool CursorCloseOnCommit
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("cursorCloseOnCommit", DefaultCursorCloseOnCommit);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("cursorCloseOnCommit", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set ANSI padding
|
||||||
|
/// </summary>
|
||||||
|
public bool AnsiPadding
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("ansiPadding", DefaultAnsiPadding);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("ansiPadding", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set ANSI warnings
|
||||||
|
/// </summary>
|
||||||
|
public bool AnsiWarnings
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("ansiWarnings", DefaultAnsiWarnings);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("ansiWarnings", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set ANSI nulls
|
||||||
|
/// </summary>
|
||||||
|
public bool AnsiNulls
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("ansiNulls", DefaultAnsiNulls);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("ansiNulls", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setting to return the actual execution plan as XML
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeActualExecutionPlanXml
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("includeActualExecutionPlanXml");
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("includeActualExecutionPlanXml", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setting to return the estimated execution plan as XML
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeEstimatedExecutionPlanXml
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetOptionValue<bool>("includeEstimatedExecutionPlanXml");
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetOptionValue("includeEstimatedExecutionPlanXml", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -127,6 +635,28 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
MaxXmlCharsToStore = newSettings.MaxXmlCharsToStore;
|
MaxXmlCharsToStore = newSettings.MaxXmlCharsToStore;
|
||||||
ExecutionPlanOptions = newSettings.ExecutionPlanOptions;
|
ExecutionPlanOptions = newSettings.ExecutionPlanOptions;
|
||||||
DisplayBitAsNumber = newSettings.DisplayBitAsNumber;
|
DisplayBitAsNumber = newSettings.DisplayBitAsNumber;
|
||||||
|
RowCount = newSettings.RowCount;
|
||||||
|
TextSize = newSettings.TextSize;
|
||||||
|
ExecutionTimeout = newSettings.ExecutionTimeout;
|
||||||
|
NoCount = newSettings.NoCount;
|
||||||
|
NoExec = newSettings.NoExec;
|
||||||
|
ParseOnly = newSettings.ParseOnly;
|
||||||
|
ArithAbort = newSettings.ArithAbort;
|
||||||
|
StatisticsTime = newSettings.StatisticsTime;
|
||||||
|
StatisticsIO = newSettings.StatisticsIO;
|
||||||
|
XactAbortOn = newSettings.XactAbortOn;
|
||||||
|
TransactionIsolationLevel = newSettings.TransactionIsolationLevel;
|
||||||
|
DeadlockPriority = newSettings.DeadlockPriority;
|
||||||
|
LockTimeout = newSettings.LockTimeout;
|
||||||
|
QueryGovernorCostLimit = newSettings.QueryGovernorCostLimit;
|
||||||
|
AnsiDefaults = newSettings.AnsiDefaults;
|
||||||
|
QuotedIdentifier = newSettings.QuotedIdentifier;
|
||||||
|
AnsiNullDefaultOn = newSettings.AnsiNullDefaultOn;
|
||||||
|
ImplicitTransactions = newSettings.ImplicitTransactions;
|
||||||
|
CursorCloseOnCommit = newSettings.CursorCloseOnCommit;
|
||||||
|
AnsiPadding = newSettings.AnsiPadding;
|
||||||
|
AnsiWarnings = newSettings.AnsiWarnings;
|
||||||
|
AnsiNulls = newSettings.AnsiNulls;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query excution settings forwarding property
|
/// Query execution settings forwarding property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public QueryExecutionSettings QueryExecutionSettings
|
public QueryExecutionSettings QueryExecutionSettings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the detailed IntelliSense settings
|
/// Gets or sets the detailed IntelliSense settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("intelliSense")]
|
||||||
public IntelliSenseSettings IntelliSense { get; set; }
|
public IntelliSenseSettings IntelliSense { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -83,16 +83,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate for callbacks that occur when a text document is opened
|
/// Delegate for callbacks that occur when a text document is opened
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="uri">Request uri</param>
|
||||||
/// <param name="openFile">File that was opened</param>
|
/// <param name="openFile">File that was opened</param>
|
||||||
/// <param name="eventContext">Context of the event raised for the changed files</param>
|
/// <param name="eventContext">Context of the event raised for the changed files</param>
|
||||||
public delegate Task TextDocOpenCallback(ScriptFile openFile, EventContext eventContext);
|
public delegate Task TextDocOpenCallback(string uri, ScriptFile openFile, EventContext eventContext);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate for callbacks that occur when a text document is closed
|
/// Delegate for callbacks that occur when a text document is closed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="uri">Request uri</param>
|
||||||
/// <param name="closedFile">File that was closed</param>
|
/// <param name="closedFile">File that was closed</param>
|
||||||
/// <param name="eventContext">Context of the event raised for changed files</param>
|
/// <param name="eventContext">Context of the event raised for changed files</param>
|
||||||
public delegate Task TextDocCloseCallback(ScriptFile closedFile, EventContext eventContext);
|
public delegate Task TextDocCloseCallback(string uri, ScriptFile closedFile, EventContext eventContext);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of callbacks to call when the configuration of the workspace changes
|
/// List of callbacks to call when the configuration of the workspace changes
|
||||||
@@ -263,7 +265,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
}
|
}
|
||||||
// Propagate the changes to the event handlers
|
// Propagate the changes to the event handlers
|
||||||
var textDocOpenTasks = TextDocOpenCallbacks.Select(
|
var textDocOpenTasks = TextDocOpenCallbacks.Select(
|
||||||
t => t(openedFile, eventContext));
|
t => t(openParams.TextDocument.Uri, openedFile, eventContext));
|
||||||
|
|
||||||
await Task.WhenAll(textDocOpenTasks);
|
await Task.WhenAll(textDocOpenTasks);
|
||||||
}
|
}
|
||||||
@@ -300,7 +302,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
|||||||
Workspace.CloseFile(closedFile);
|
Workspace.CloseFile(closedFile);
|
||||||
|
|
||||||
// Send out a notification to other services that have subscribed to this event
|
// Send out a notification to other services that have subscribed to this event
|
||||||
var textDocClosedTasks = TextDocCloseCallbacks.Select(t => t(closedFile, eventContext));
|
var textDocClosedTasks = TextDocCloseCallbacks.Select(t => t(closeParams.TextDocument.Uri, closedFile, eventContext));
|
||||||
await Task.WhenAll(textDocClosedTasks);
|
await Task.WhenAll(textDocClosedTasks);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -73,6 +73,28 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
|||||||
DisplayBitAsNumber = false,
|
DisplayBitAsNumber = false,
|
||||||
MaxXmlCharsToStore = 1,
|
MaxXmlCharsToStore = 1,
|
||||||
MaxCharsToStore = 1,
|
MaxCharsToStore = 1,
|
||||||
|
RowCount = 0,
|
||||||
|
TextSize = 1000,
|
||||||
|
ExecutionTimeout = 5000,
|
||||||
|
NoCount = true,
|
||||||
|
NoExec = true,
|
||||||
|
ParseOnly = true,
|
||||||
|
ArithAbort = true,
|
||||||
|
StatisticsTime = true,
|
||||||
|
StatisticsIO = true,
|
||||||
|
XactAbortOn = true,
|
||||||
|
TransactionIsolationLevel = "REPEATABLE READ",
|
||||||
|
DeadlockPriority = "LOW",
|
||||||
|
LockTimeout = 5000,
|
||||||
|
QueryGovernorCostLimit = 2000,
|
||||||
|
AnsiDefaults = false,
|
||||||
|
QuotedIdentifier = true,
|
||||||
|
AnsiNullDefaultOn = true,
|
||||||
|
ImplicitTransactions = true,
|
||||||
|
CursorCloseOnCommit = true,
|
||||||
|
AnsiPadding = true,
|
||||||
|
AnsiWarnings = true,
|
||||||
|
AnsiNulls = true,
|
||||||
ExecutionPlanOptions = new ExecutionPlanOptions
|
ExecutionPlanOptions = new ExecutionPlanOptions
|
||||||
{
|
{
|
||||||
IncludeActualExecutionPlanXml = true,
|
IncludeActualExecutionPlanXml = true,
|
||||||
@@ -80,8 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
|||||||
},
|
},
|
||||||
BatchSeparator = "YO"
|
BatchSeparator = "YO"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
qes.UpdateSettings(settings, null, new EventContext());
|
qes.UpdateSettings(settings, null, new EventContext());
|
||||||
|
|
||||||
@@ -92,7 +113,29 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
|||||||
Assert.Equal(1, qes.Settings.QueryExecutionSettings.MaxCharsToStore);
|
Assert.Equal(1, qes.Settings.QueryExecutionSettings.MaxCharsToStore);
|
||||||
Assert.Equal(1, qes.Settings.QueryExecutionSettings.MaxXmlCharsToStore);
|
Assert.Equal(1, qes.Settings.QueryExecutionSettings.MaxXmlCharsToStore);
|
||||||
Assert.Equal("YO", qes.Settings.QueryExecutionSettings.BatchSeparator);
|
Assert.Equal("YO", qes.Settings.QueryExecutionSettings.BatchSeparator);
|
||||||
|
Assert.Equal(1, qes.Settings.QueryExecutionSettings.MaxCharsToStore);
|
||||||
|
Assert.Equal(0, qes.Settings.QueryExecutionSettings.RowCount);
|
||||||
|
Assert.Equal(1000, qes.Settings.QueryExecutionSettings.TextSize);
|
||||||
|
Assert.Equal(5000, qes.Settings.QueryExecutionSettings.ExecutionTimeout);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.NoCount);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.NoExec);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.ParseOnly);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.ArithAbort);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.StatisticsTime);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.StatisticsIO);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.XactAbortOn);
|
||||||
|
Assert.Equal("REPEATABLE READ", qes.Settings.QueryExecutionSettings.TransactionIsolationLevel);
|
||||||
|
Assert.Equal("LOW", qes.Settings.QueryExecutionSettings.DeadlockPriority);
|
||||||
|
Assert.Equal(5000, qes.Settings.QueryExecutionSettings.LockTimeout);
|
||||||
|
Assert.Equal(2000, qes.Settings.QueryExecutionSettings.QueryGovernorCostLimit);
|
||||||
|
Assert.False(qes.Settings.QueryExecutionSettings.AnsiDefaults);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.QuotedIdentifier);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.AnsiNullDefaultOn);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.ImplicitTransactions);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.CursorCloseOnCommit);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.AnsiPadding);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.AnsiWarnings);
|
||||||
|
Assert.True(qes.Settings.QueryExecutionSettings.AnsiNulls);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Workspace
|
|||||||
|
|
||||||
// ... And there is a callback registered for the file closed event
|
// ... And there is a callback registered for the file closed event
|
||||||
ScriptFile closedFile = null;
|
ScriptFile closedFile = null;
|
||||||
workspaceService.RegisterTextDocCloseCallback((f, c) =>
|
string closedUri = null;
|
||||||
|
workspaceService.RegisterTextDocCloseCallback((u, f, c) =>
|
||||||
{
|
{
|
||||||
|
closedUri = u;
|
||||||
closedFile = f;
|
closedFile = f;
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
});
|
});
|
||||||
@@ -55,6 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Workspace
|
|||||||
// ... The provided script file should be the one we created
|
// ... The provided script file should be the one we created
|
||||||
Assert.NotNull(closedFile);
|
Assert.NotNull(closedFile);
|
||||||
Assert.Equal(openedFile, closedFile);
|
Assert.Equal(openedFile, closedFile);
|
||||||
|
Assert.Equal(TestObjects.ScriptUri, closedUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -68,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Workspace
|
|||||||
|
|
||||||
// ... And there is a callback registered for the file closed event
|
// ... And there is a callback registered for the file closed event
|
||||||
bool callbackCalled = false;
|
bool callbackCalled = false;
|
||||||
workspaceService.RegisterTextDocCloseCallback((f, c) =>
|
workspaceService.RegisterTextDocCloseCallback((u, f, c) =>
|
||||||
{
|
{
|
||||||
callbackCalled = true;
|
callbackCalled = true;
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user