Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2253,40 +2253,40 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
}
}

if (null != dataStream)
byte peekedToken;
if (!stateObj.TryPeekByte(out peekedToken))
{ // temporarily cache next byte
return false;
}

if (TdsEnums.SQLDATACLASSIFICATION == peekedToken)
{
byte peekedToken;
if (!stateObj.TryPeekByte(out peekedToken))
{ // temporarily cache next byte
byte dataClassificationToken;
if (!stateObj.TryReadByte(out dataClassificationToken))
{
return false;
}
Debug.Assert(TdsEnums.SQLDATACLASSIFICATION == dataClassificationToken);

if (TdsEnums.SQLDATACLASSIFICATION == peekedToken)
SensitivityClassification sensitivityClassification;
if (!TryProcessDataClassification(stateObj, out sensitivityClassification))
{
byte dataClassificationToken;
if (!stateObj.TryReadByte(out dataClassificationToken))
{
return false;
}
Debug.Assert(TdsEnums.SQLDATACLASSIFICATION == dataClassificationToken);

SensitivityClassification sensitivityClassification;
if (!TryProcessDataClassification(stateObj, out sensitivityClassification))
{
return false;
}
if (!dataStream.TrySetSensitivityClassification(sensitivityClassification))
{
return false;
}
return false;
}
if (null != dataStream && !dataStream.TrySetSensitivityClassification(sensitivityClassification))
{
return false;
}

// update peekedToken
if (!stateObj.TryPeekByte(out peekedToken))
{
return false;
}
// update peekedToken
if (!stateObj.TryPeekByte(out peekedToken))
{
return false;
}
}

if (null != dataStream)
{
if (!dataStream.TrySetMetaData(stateObj._cleanupMetaData, (TdsEnums.SQLTABNAME == peekedToken || TdsEnums.SQLCOLINFO == peekedToken)))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2584,40 +2584,40 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
}
}

if (null != dataStream)
byte peekedToken;
if (!stateObj.TryPeekByte(out peekedToken))
{ // temporarily cache next byte
return false;
}

if (TdsEnums.SQLDATACLASSIFICATION == peekedToken)
{
byte peekedToken;
if (!stateObj.TryPeekByte(out peekedToken))
{ // temporarily cache next byte
byte dataClassificationToken;
if (!stateObj.TryReadByte(out dataClassificationToken))
{
return false;
}
Debug.Assert(TdsEnums.SQLDATACLASSIFICATION == dataClassificationToken);

if (TdsEnums.SQLDATACLASSIFICATION == peekedToken)
SensitivityClassification sensitivityClassification;
if (!TryProcessDataClassification(stateObj, out sensitivityClassification))
{
byte dataClassificationToken;
if (!stateObj.TryReadByte(out dataClassificationToken))
{
return false;
}
Debug.Assert(TdsEnums.SQLDATACLASSIFICATION == dataClassificationToken);

SensitivityClassification sensitivityClassification;
if (!TryProcessDataClassification(stateObj, out sensitivityClassification))
{
return false;
}
if (!dataStream.TrySetSensitivityClassification(sensitivityClassification))
{
return false;
}
return false;
}
if (null != dataStream && !dataStream.TrySetSensitivityClassification(sensitivityClassification))
{
return false;
}

// update peekedToken
if (!stateObj.TryPeekByte(out peekedToken))
{
return false;
}
// update peekedToken
if (!stateObj.TryPeekByte(out peekedToken))
{
return false;
}
}

if (null != dataStream)
{
if (!dataStream.TrySetMetaData(stateObj._cleanupMetaData, (TdsEnums.SQLTABNAME == peekedToken || TdsEnums.SQLCOLINFO == peekedToken)))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,31 @@ public static bool IsDatabasePresent(string name)
return present;
}

/// <summary>
/// Checks if object SYS.SENSITIVITY_CLASSIFICATIONS exists in SQL Server
/// </summary>
/// <returns>True, if target SQL Server supports Data Classification</returns>
public static bool IsSupportedDataClassification()
{
try
{
using (var connection = new SqlConnection(TCPConnectionString))
using (var command = new SqlCommand("SELECT * FROM SYS.SENSITIVITY_CLASSIFICATIONS", connection))
{
connection.Open();
command.ExecuteNonQuery();
}
}
catch (SqlException e)
{
// Check for Error 208: Invalid Object Name
if (e.Errors != null && e.Errors[0].Number == 208)
{
return false;
}
}
return true;
}
public static bool IsUdtTestDatabasePresent() => IsDatabasePresent(UdtTestDbName);

public static bool AreConnStringsSetup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Compile Include="AlwaysEncrypted\TestTrustedMasterKeyPaths.cs" />
<Compile Include="DataCommon\AADUtility.cs" />
<Compile Include="DataCommon\CheckConnStrSetupFactAttribute.cs" />
<Compile Include="SQL\DataClassificationTest\DataClassificationTest.cs" />
<Compile Include="TracingTests\EventSourceTest.cs" />
<Compile Include="SQL\AdapterTest\AdapterTest.cs" />
<Compile Include="SQL\AsyncTest\BeginExecAsyncTest.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
public class ConnectionBehaviorTest
{
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[CheckConnStrSetupFact]
public void ConnectionBehaviorClose()
{
using (SqlConnection sqlConnection = new SqlConnection((new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString) { MaxPoolSize = 1 }).ConnectionString))
Expand All @@ -31,7 +31,7 @@ public void ConnectionBehaviorClose()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[CheckConnStrSetupFact]
public void ConnectionBehaviorCloseAsync()
{
using (SqlConnection sqlConnection = new SqlConnection((new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString) { MaxPoolSize = 1 }).ConnectionString))
Expand Down
Loading