mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-15 01:25:40 -05:00
Fixes: The streaming protocol is now tightened to ensure that only the last message for a result set contain isCompleted=true. Now isCompleted=true is never sent in isAvailable message. Tightened logic in sending messages to make sure that no duplicate messages get sent out due to concurrent processing. Made a fix to a null reference exception when processing special action which was a pre-existing benign bug. Testing: Added 1 more new test that runs existing tests concurrently 1000 times to make sure no random timing issues are observed and tightened verifications to existing tests to ensure no duplicate messages and only one isComplete=true message is sent across. * tightening the protocal to ensure only one message (the last one) with completed=true is sent back for a single result set within a query batch
81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
using System;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|
{
|
|
/// <summary>
|
|
/// Class that represents a Special Action which occured by user request during the query
|
|
/// </summary>
|
|
public class SpecialAction {
|
|
|
|
#region Private Class variables
|
|
|
|
// Underlying representation as bitwise flags to simplify logic
|
|
[Flags]
|
|
private enum ActionFlags
|
|
{
|
|
None = 0,
|
|
// All added options must be powers of 2
|
|
ExpectYukonXmlShowPlan = 1
|
|
}
|
|
|
|
private ActionFlags flags;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// The type of XML execution plan that is contained with in a result set
|
|
/// </summary>
|
|
public SpecialAction()
|
|
{
|
|
flags = ActionFlags.None;
|
|
}
|
|
|
|
#region Public Functions
|
|
/// <summary>
|
|
/// No Special action performed
|
|
/// </summary>
|
|
public bool None
|
|
{
|
|
get { return flags == ActionFlags.None; }
|
|
set
|
|
{
|
|
flags = ActionFlags.None;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Contains an XML execution plan result set
|
|
/// </summary>
|
|
public bool ExpectYukonXMLShowPlan
|
|
{
|
|
get { return flags.HasFlag(ActionFlags.ExpectYukonXmlShowPlan); }
|
|
set
|
|
{
|
|
if (value)
|
|
{
|
|
// OR flags with value to apply
|
|
flags |= ActionFlags.ExpectYukonXmlShowPlan;
|
|
}
|
|
else
|
|
{
|
|
// AND flags with the inverse of the value we want to remove
|
|
flags &= ~(ActionFlags.ExpectYukonXmlShowPlan);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggregate this special action with the input
|
|
/// </summary>
|
|
public void CombineSpecialAction(SpecialAction action)
|
|
{
|
|
flags |= ((action?.flags) ?? ActionFlags.None);
|
|
}
|
|
public override string ToString() => $"ActionFlag:'{flags}', ExpectYukonXMLShowPlan:'{ExpectYukonXMLShowPlan}'";
|
|
#endregion
|
|
};
|
|
}
|