-
Notifications
You must be signed in to change notification settings - Fork 317
Merge | SqlCommand The Mop Up #3738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
52102e8
Merge AsyncState class, _cachedAsyncState and CachedAsyncState
benrr101 e980e0f
Add partial for batch RPC mode methods
benrr101 9332cf6
Merge:
benrr101 06ec76e
Merge AddBatchCommand
benrr101 d47b9d2
Merge SetBatchRPCMode and SetBatchRPCModeReadyToExecute
benrr101 09d6cc9
Merge ClearBatchCommand (and make it private)
benrr101 e6b56c2
Merging _RPCList and _currentlyExecutingBatch
benrr101 54af4d5
Merge DebugForceAsyncWriteDelay
benrr101 f7b4bd9
Merge MaxRPCNameLength, s_cancelIgnoreFailure, CancelIgnoreFailureCal…
benrr101 f906eb1
Merge: s_diagnosticListener, _parentOperationStarted, _rpcArrayOf1, _…
benrr101 5473e48
Merge WriteBeginExecuteEvent and WriteEndExecuteEvent (interted if an…
benrr101 8aeab64
Merge CheckThrowSNIException (made private, rewritten as ?.), OnConne…
benrr101 28d7c31
Merge BuildParamList (combine a bunch of StringBuilder.Append into Ap…
benrr101 c2a3f95
Merge ParseAndQuoteIdentifier and QuoteIdentifier (using netcore vers…
benrr101 b871633
Merge GetRPCObject
benrr101 1d34c06
Merge SetUpRPCParameters
benrr101 32feb5a
Merge ShouldSendParameter, CountSendableParameters (inverted logic), …
benrr101 7700e4e
Merge GetSetOptionsString (made static, renamed to GetOptionsSetStrin…
benrr101 29ee4fa
Merging GetParameterForOutputValueExtraction (made static, rewrote to…
benrr101 a2c2953
Merge ReliablePutStateObject, PutStateObject, GetCurrentParameterColl…
benrr101 7b94854
Merge GetStateObject
benrr101 7528548
Merge ValidateCommand, ValidateAsyncCommand
benrr101 dac10ad
Merge CheckNotificationStateAndAutoEnlist, RegisterForConnectionClose…
benrr101 96132fa
Merge DeriveParameters, GetParameterDirectionFromOleDbDirection
benrr101 13eae89
Merge TriggerInternalEndAndRetryIfNecessary and CreateLocalCompletion…
benrr101 1a881c6
Merge OnStatementCompleted
benrr101 8f55436
Merge UnquoteProcedureName and UnquoteProcedurePart
benrr101 c743710
Merge ThrowIfReconnectionHasBeenCanceled (inverted, using conditional…
benrr101 87cfc4f
Merge WaitForAsyncResults
benrr101 7a079cf
Merge VerifyEndExecuteState (THE LAST ONE)
benrr101 0088f9d
Delete pre-merge (and now empty) SqlCommand files
benrr101 c7c6a77
PR comments from copilot
benrr101 fd6d1c2
Revert a couple changes on BuildParamList
benrr101 6e2188e
Found a bug in BuildParamList, rolling back a couple changes that wer…
benrr101 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,780 changes: 0 additions & 1,780 deletions
1,780
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.netcore.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,791 changes: 0 additions & 1,791 deletions
1,791
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.netfx.cs
This file was deleted.
Oops, something went wrong.
141 changes: 141 additions & 0 deletions
141
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.Batch.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Data; | ||
| using System.Diagnostics; | ||
|
|
||
| namespace Microsoft.Data.SqlClient | ||
| { | ||
| // @TODO: There's a good question here - should this be a separate type of SqlCommand? | ||
| public sealed partial class SqlCommand | ||
| { | ||
| #region Internal Methods | ||
|
|
||
| internal void AddBatchCommand(SqlBatchCommand batchCommand) | ||
| { | ||
| Debug.Assert(_batchRPCMode, "Command is not in batch RPC Mode"); | ||
| Debug.Assert(_RPCList is not null); | ||
|
|
||
| _SqlRPC rpc = new _SqlRPC { batchCommand = batchCommand }; | ||
| string commandText = batchCommand.CommandText; | ||
| CommandType cmdType = batchCommand.CommandType; | ||
|
|
||
| CommandText = commandText; | ||
| CommandType = cmdType; | ||
|
|
||
| SetColumnEncryptionSetting(batchCommand.ColumnEncryptionSetting); | ||
|
|
||
| // @TODO: Hmm, maybe we could have get/put become a IDisposable thing | ||
| GetStateObject(); | ||
| if (cmdType is CommandType.StoredProcedure) | ||
| { | ||
| BuildRPC(inSchema: false, batchCommand.Parameters, ref rpc); | ||
| } | ||
| else | ||
| { | ||
| // All batch sql statements must be executed inside sp_executesql, including those | ||
| // without parameters | ||
| BuildExecuteSql(CommandBehavior.Default, commandText, batchCommand.Parameters, ref rpc); | ||
| } | ||
|
|
||
| _RPCList.Add(rpc); | ||
| ReliablePutStateObject(); | ||
| } | ||
|
|
||
| internal SqlBatchCommand GetBatchCommand(int index) => | ||
| _RPCList[index].batchCommand; | ||
|
|
||
| // @TODO: This should be a property. | ||
| internal SqlBatchCommand GetCurrentBatchCommand() | ||
| { | ||
| return _batchRPCMode | ||
| ? _RPCList[_currentlyExecutingBatch].batchCommand | ||
| : _rpcArrayOf1?[0].batchCommand; | ||
| } | ||
|
|
||
| // @TODO: 1) This should be a property | ||
| // @TODO: 2) This could be a `int?` | ||
| internal int GetCurrentBatchIndex() => | ||
| _batchRPCMode ? _currentlyExecutingBatch : -1; | ||
|
|
||
| // @TODO: Indicate this is for batch RPC usage | ||
| internal SqlException GetErrors(int commandIndex) | ||
| { | ||
| SqlException result = null; | ||
|
|
||
| _SqlRPC rpc = _RPCList[commandIndex]; | ||
| int length = rpc.errorsIndexEnd - rpc.errorsIndexStart; | ||
| if (length > 0) | ||
| { | ||
| SqlErrorCollection errors = new SqlErrorCollection(); | ||
| for (int i = rpc.errorsIndexStart; i < rpc.errorsIndexEnd; i++) | ||
| { | ||
| errors.Add(rpc.errors[i]); | ||
| } | ||
| for (int i = rpc.warningsIndexStart; i < rpc.warningsIndexEnd; i++) | ||
| { | ||
| errors.Add(rpc.warnings[i]); | ||
| } | ||
|
|
||
| result = SqlException.CreateException( | ||
| errors, | ||
| _activeConnection.ServerVersion, | ||
| _activeConnection.ClientConnectionId, | ||
| innerException: null, | ||
| batchCommand: null); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| // @TODO: Should be renamed to indicate only applies to batch RPC mode | ||
| internal int? GetRecordsAffected(int commandIndex) | ||
| { | ||
| Debug.Assert(_batchRPCMode, "Command is not in batch RPC mode"); | ||
| Debug.Assert(_RPCList is not null, "Batch commands have been cleared"); | ||
| return _RPCList[commandIndex].recordsAffected; | ||
| } | ||
|
|
||
| // @TODO: Rename to match naming conventions | ||
| internal void SetBatchRPCMode(bool value, int commandCount = 1) | ||
| { | ||
| _batchRPCMode = value; | ||
| ClearBatchCommand(); | ||
| if (_batchRPCMode) | ||
| { | ||
| if (_RPCList is null) | ||
| { | ||
| // @TODO: Could this be done with an array? | ||
| _RPCList = new List<_SqlRPC>(commandCount); | ||
| } | ||
| else | ||
| { | ||
| _RPCList.Capacity = commandCount; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // @TODO: Rename to match naming conventions | ||
| internal void SetBatchRPCModeReadyToExecute() | ||
| { | ||
| Debug.Assert(_batchRPCMode, "Command is not in batch RPC Mode"); | ||
| Debug.Assert(_RPCList is not null, "No batch commands specified"); | ||
|
|
||
| _currentlyExecutingBatch = 0; | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Private Methods | ||
|
|
||
| private void ClearBatchCommand() | ||
| { | ||
| _RPCList?.Clear(); | ||
| _currentlyExecutingBatch = 0; | ||
| } | ||
|
|
||
| #endregion | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.