Skip to content

Commit ca8eebd

Browse files
committed
Merge branch 'main' into MergeTdsParserStateObject-3
# Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs # src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
2 parents 9b98c8e + 6beab6a commit ca8eebd

File tree

102 files changed

+727
-1998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+727
-1998
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,7 @@ dotnet_code_quality.ca1802.api_surface = private, internal
169169

170170
[*.cs]
171171
dotnet_code_quality.CA2100.excluded_type_names_with_derived_types = Microsoft.Data.SqlClient.ManualTesting.Tests.*
172+
dotnet_diagnostic.xUnit1031.severity=none
173+
dotnet_diagnostic.xUnit1030.severity=none
174+
175+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ If you believe you have found a security vulnerability in any Microsoft-owned re
8585

8686
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
8787

88-
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
88+
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
8989

9090
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
9191

build.proj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
<FunctionalTests Include="**/tools/TDS/TDS/TDS.csproj" />
5454
<FunctionalTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
5555
<FunctionalTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
56-
<FunctionalTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
5756
<FunctionalTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
5857
<FunctionalTests Include="**/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
5958
<FunctionalTests Include="**/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj" />
@@ -64,7 +63,6 @@
6463
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj" />
6564
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj" />
6665
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj" />
67-
<ManualTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
6866
<ManualTests Include="**/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj"/>
6967
<ManualTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
7068
<ManualTests Include="**/CustomConfigurableRetryLogic/CustomRetryLogicProvider.csproj" />

src/Microsoft.Data.SqlClient.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.Al
7272
EndProject
7373
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "add-ons", "add-ons", "{C9726AED-D6A3-4AAC-BA04-92DD1F079594}"
7474
EndProject
75-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.XUnitExtensions", "Microsoft.Data.SqlClient\tests\tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj", "{FDA6971D-9F57-4DA4-B10A-261C91684CFC}"
76-
EndProject
7775
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{ED952CF7-84DF-437A-B066-F516E9BE1C2C}"
7876
EndProject
7977
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{71F356DC-DFA3-4163-8BFE-D268722CE189}"

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@
969969
<PackageReference Condition="$(TargetGroup) == 'netstandard' and '$(TargetsWindows)' == 'true' and '$(IsUAPAssembly)' != 'true'" Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" />
970970
<PackageReference Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerVersion)" />
971971
<PackageReference Include="System.Security.Permissions" Version="$(SystemSecurityPermissionsVersion)" />
972-
<PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
972+
<PackageReference Condition="$(TargetGroup) == 'netstandard'" Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
973973
<PackageReference Include="System.Text.Encoding.CodePages" Version="$(SystemTextEncodingCodePagesVersion)" />
974974
<PackageReference Include="System.Text.Encodings.Web" Version="$(SystemTextEncodingsWebVersion)" />
975975
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" Version="$(MicrosoftDataSqlClientSNIRuntimeVersion)" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,21 +3147,6 @@ private bool TryHasMoreResults(out bool moreResults)
31473147

31483148
switch (token)
31493149
{
3150-
case TdsEnums.SQLALTROW:
3151-
if (_altRowStatus == ALTROWSTATUS.Null)
3152-
{
3153-
// cache the regular metadata
3154-
_altMetaDataSetCollection.metaDataSet = _metaData;
3155-
_metaData = null;
3156-
}
3157-
else
3158-
{
3159-
Debug.Assert(_altRowStatus == ALTROWSTATUS.Done, "invalid AltRowStatus");
3160-
}
3161-
_altRowStatus = ALTROWSTATUS.AltRow;
3162-
_hasRows = true;
3163-
moreResults = true;
3164-
return true;
31653150
case TdsEnums.SQLROW:
31663151
case TdsEnums.SQLNBCROW:
31673152
// always happens if there is a row following an altrow
@@ -3177,6 +3162,23 @@ private bool TryHasMoreResults(out bool moreResults)
31773162
case TdsEnums.SQLCOLMETADATA:
31783163
moreResults = true;
31793164
return true;
3165+
3166+
// deprecated
3167+
case TdsEnums.SQLALTROW:
3168+
if (_altRowStatus == ALTROWSTATUS.Null)
3169+
{
3170+
// cache the regular metadata
3171+
_altMetaDataSetCollection.metaDataSet = _metaData;
3172+
_metaData = null;
3173+
}
3174+
else
3175+
{
3176+
Debug.Assert(_altRowStatus == ALTROWSTATUS.Done, "invalid AltRowStatus");
3177+
}
3178+
_altRowStatus = ALTROWSTATUS.AltRow;
3179+
_hasRows = true;
3180+
moreResults = true;
3181+
return true;
31803182
}
31813183

31823184
// TryRun() will immediately return if the TdsParser is closed/broken, causing us to enter an infinite loop

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -348,31 +348,34 @@ public void SinglePhaseCommit(SinglePhaseEnlistment enlistment)
348348
#endif
349349
try
350350
{
351-
Exception commitException = null;
352-
353-
lock (connection)
351+
// If the connection is doomed, we can be certain that the
352+
// transaction will eventually be rolled back or has already been aborted externally, and we shouldn't
353+
// attempt to commit it.
354+
if (connection.IsConnectionDoomed)
354355
{
355-
// If the connection is doomed, we can be certain that the
356-
// transaction will eventually be rolled back or has already been aborted externally, and we shouldn't
357-
// attempt to commit it.
358-
if (connection.IsConnectionDoomed)
356+
lock (connection)
359357
{
360358
_active = false; // set to inactive first, doesn't matter how the rest completes, this transaction is done.
361359
_connection = null;
362-
363-
enlistment.Aborted(SQL.ConnectionDoomed());
364360
}
365-
else
361+
362+
enlistment.Aborted(SQL.ConnectionDoomed());
363+
}
364+
else
365+
{
366+
Exception commitException;
367+
lock (connection)
366368
{
367369
try
368370
{
369371
// Now that we've acquired the lock, make sure we still have valid state for this operation.
370372
ValidateActiveOnConnection(connection);
371373

372374
_active = false; // set to inactive first, doesn't matter how the rest completes, this transaction is done.
373-
_connection = null; // Set prior to ExecuteTransaction call in case this initiates a TransactionEnd event
375+
_connection = null; // Set prior to ExecuteTransaction call in case this initiates a TransactionEnd event
374376

375377
connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Commit, null, System.Data.IsolationLevel.Unspecified, _internalTransaction, true);
378+
commitException = null;
376379
}
377380
catch (SqlException e)
378381
{
@@ -391,42 +394,41 @@ public void SinglePhaseCommit(SinglePhaseEnlistment enlistment)
391394
ADP.TraceExceptionWithoutRethrow(e);
392395
connection.DoomThisConnection();
393396
}
394-
if (commitException != null)
397+
}
398+
if (commitException != null)
399+
{
400+
// connection.ExecuteTransaction failed with exception
401+
if (_internalTransaction.IsCommitted)
395402
{
396-
// connection.ExecuteTransaction failed with exception
397-
if (_internalTransaction.IsCommitted)
398-
{
399-
// Even though we got an exception, the transaction
400-
// was committed by the server.
401-
enlistment.Committed();
402-
}
403-
else if (_internalTransaction.IsAborted)
404-
{
405-
// The transaction was aborted, report that to
406-
// SysTx.
407-
enlistment.Aborted(commitException);
408-
}
409-
else
410-
{
411-
// The transaction is still active, we cannot
412-
// know the state of the transaction.
413-
enlistment.InDoubt(commitException);
414-
}
415-
416-
// We eat the exception. This is called on the SysTx
417-
// thread, not the applications thread. If we don't
418-
// eat the exception an UnhandledException will occur,
419-
// causing the process to FailFast.
403+
// Even though we got an exception, the transaction
404+
// was committed by the server.
405+
enlistment.Committed();
406+
}
407+
else if (_internalTransaction.IsAborted)
408+
{
409+
// The transaction was aborted, report that to
410+
// SysTx.
411+
enlistment.Aborted(commitException);
412+
}
413+
else
414+
{
415+
// The transaction is still active, we cannot
416+
// know the state of the transaction.
417+
enlistment.InDoubt(commitException);
420418
}
421419

422-
connection.CleanupConnectionOnTransactionCompletion(_atomicTransaction);
420+
// We eat the exception. This is called on the SysTx
421+
// thread, not the applications thread. If we don't
422+
// eat the exception an UnhandledException will occur,
423+
// causing the process to FailFast.
423424
}
424-
}
425425

426-
if (commitException == null)
427-
{
428-
// connection.ExecuteTransaction succeeded
429-
enlistment.Committed();
426+
connection.CleanupConnectionOnTransactionCompletion(_atomicTransaction);
427+
if (commitException == null)
428+
{
429+
// connection.ExecuteTransaction succeeded
430+
enlistment.Committed();
431+
}
430432
}
431433
}
432434
catch (System.OutOfMemoryException e)

0 commit comments

Comments
 (0)