Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aaecb8c
Add SqlCommand.Reader partial
benrr101 Jul 29, 2025
ca78936
Merge ExecuteReader
benrr101 Jul 29, 2025
6381283
Merge RunExecuteReaderWithRetry
benrr101 Jul 29, 2025
6e39ea1
Merge RunExecuteReader#1
benrr101 Jul 29, 2025
57c7ee3
Merge RunExecuteReader#2
benrr101 Aug 5, 2025
bbe110e
Refactor out RunExecuteReaderTdsSetupReconnectContinuation (to match …
benrr101 Jul 31, 2025
16ca4d9
Factor out RunExecuteReaderTdsSetupContinuation (to match netcore)
benrr101 Jul 31, 2025
4ffe25a
Merge RunExecuteReaderTds
benrr101 Jul 31, 2025
912bc28
Merge RunExecuteReaderTdsSetupReconnectContinuation
benrr101 Aug 1, 2025
a92378f
Merge RunExecuteReaderTdsSetupContinuation
benrr101 Aug 1, 2025
187ee9a
Merge RunExecuteReaderTdsWithTransparentParameterEncryption
benrr101 Aug 1, 2025
4981042
Merge GenerateEnclavePackage
benrr101 Aug 1, 2025
3a5d3bc
Merge FinishExecuteReader
benrr101 Aug 1, 2025
2e78c26
Merge BuildRPC
benrr101 Aug 4, 2025
0cfc252
Merge BuildExecute
benrr101 Aug 4, 2025
d816be3
Merge BuildExecuteSql
benrr101 Aug 4, 2025
3cfd99d
Merge BuildPrepExec
benrr101 Aug 4, 2025
47906b0
Merge BeginExecuteReader
benrr101 Aug 4, 2025
075dfc4
Merging BeginExecuteReaderInternal
benrr101 Aug 4, 2025
d029e00
Merge BeginExecuteReaderInternalReadStage
benrr101 Aug 4, 2025
d1b6e16
Merge EndExecuteReader
benrr101 Aug 4, 2025
a61fdd0
Merge EndExecuteReaderInternal
benrr101 Aug 4, 2025
936f0d1
Merge InternalEndExecuteReader
benrr101 Aug 4, 2025
44d98d7
Merge CompleteAsyncExecuteReader
benrr101 Aug 4, 2025
75d2ad8
Merge ExecuteReaderAsync
benrr101 Aug 5, 2025
446e44a
Merge InternalExecuteReaderWithRetryAsync
benrr101 Aug 5, 2025
1cdf11c
Merge InternalExecuteReaderAsync
benrr101 Aug 5, 2025
ef4b823
Merge CleanupExecuteReaderAsync
benrr101 Aug 5, 2025
2c32217
F goes after E
benrr101 Aug 5, 2025
533d10e
Merge EndExecuteReaderAsync
benrr101 Aug 5, 2025
e622555
Merge ExecuteDbDataReader
benrr101 Aug 5, 2025
61f7b4a
Merge ExecuteDbDataReaderAsync
benrr101 Aug 5, 2025
4cba491
Merge SetCachedCommandExecuteReaderAsyncContext
benrr101 Aug 5, 2025
6a89074
Merge ExecuteReaderAsyncCallContext
benrr101 Aug 5, 2025
c0ba212
Address feedback from @edwardneal
benrr101 Oct 1, 2025
776caec
Add `?` to _activeConnection references in trace logging - fixes the …
benrr101 Oct 1, 2025
bc76b9b
Merge branch 'main' into dev/russellben/merge/sqlcommand-nocer-reader
benrr101 Oct 2, 2025
cb11f43
Add back line from netfx
benrr101 Oct 2, 2025
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 @@ -2733,69 +2733,6 @@ private void ReadDescribeEncryptionParameterResults(
}
}

private SqlDataReader RunExecuteReaderTdsWithTransparentParameterEncryption(
CommandBehavior cmdBehavior,
RunBehavior runBehavior,
bool returnStream,
bool isAsync,
int timeout,
out Task task,
bool asyncWrite,
bool isRetry,
SqlDataReader ds = null,
Task describeParameterEncryptionTask = null)
{
Debug.Assert(!asyncWrite || isAsync, "AsyncWrite should be always accompanied by Async");

if (ds == null && returnStream)
{
ds = new SqlDataReader(this, cmdBehavior);
}

if (describeParameterEncryptionTask != null)
{
long parameterEncryptionStart = ADP.TimerCurrent();
TaskCompletionSource<object> completion = new TaskCompletionSource<object>();
AsyncHelper.ContinueTaskWithState(describeParameterEncryptionTask, completion, this,
(object state) =>
{
SqlCommand command = (SqlCommand)state;
Task subTask = null;
command.GenerateEnclavePackage();
command.RunExecuteReaderTds(cmdBehavior, runBehavior, returnStream, isAsync, TdsParserStaticMethods.GetRemainingTimeout(timeout, parameterEncryptionStart), out subTask, asyncWrite, isRetry, ds);
if (subTask == null)
{
completion.SetResult(null);
}
else
{
AsyncHelper.ContinueTaskWithState(subTask, completion, completion, static (object state) => ((TaskCompletionSource<object>)state).SetResult(null));
}
},
onFailure: static (Exception exception, object state) =>
{
((SqlCommand)state).CachedAsyncState?.ResetAsyncState();
if (exception != null)
{
throw exception;
}
},
onCancellation: static (object state) =>
{
((SqlCommand)state).CachedAsyncState?.ResetAsyncState();
}
);
task = completion.Task;
return ds;
}
else
{
// Synchronous execution.
GenerateEnclavePackage();
return RunExecuteReaderTds(cmdBehavior, runBehavior, returnStream, isAsync, timeout, out task, asyncWrite, isRetry, ds);
}
}

private void GenerateEnclavePackage()
{
if (keysToBeSentToEnclave == null || keysToBeSentToEnclave.Count <= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2689,67 +2689,6 @@ private void ReadDescribeEncryptionParameterResults(
}
}

private SqlDataReader RunExecuteReaderTdsWithTransparentParameterEncryption(
CommandBehavior cmdBehavior,
RunBehavior runBehavior,
bool returnStream,
bool isAsync,
int timeout,
out Task task,
bool asyncWrite,
bool isRetry,
SqlDataReader ds = null,
Task describeParameterEncryptionTask = null)
{
Debug.Assert(!asyncWrite || isAsync, "AsyncWrite should be always accompanied by Async");

if (ds == null && returnStream)
{
ds = new SqlDataReader(this, cmdBehavior);
}

if (describeParameterEncryptionTask != null)
{
long parameterEncryptionStart = ADP.TimerCurrent();
TaskCompletionSource<object> completion = new TaskCompletionSource<object>();
AsyncHelper.ContinueTaskWithState(describeParameterEncryptionTask, completion, this,
(object state) =>
{
SqlCommand command = (SqlCommand)state;
Task subTask = null;
command.GenerateEnclavePackage();
command.RunExecuteReaderTds(cmdBehavior, runBehavior, returnStream, isAsync, TdsParserStaticMethods.GetRemainingTimeout(timeout, parameterEncryptionStart), out subTask, asyncWrite, isRetry, ds);
if (subTask == null)
{
completion.SetResult(null);
}
else
{
AsyncHelper.ContinueTaskWithState(subTask, completion, completion, static (object state2) => ((TaskCompletionSource<object>)state2).SetResult(null));
}
},
onFailure: static (Exception exception, object state) =>
{
((SqlCommand)state).CachedAsyncState?.ResetAsyncState();
if (exception != null)
{
throw exception;
}
},
onCancellation: static (object state) => ((SqlCommand)state).CachedAsyncState?.ResetAsyncState(),
connectionToDoom: null,
connectionToAbort: _activeConnection);
task = completion.Task;
return ds;
}
else
{
// Synchronous execution.
GenerateEnclavePackage();
return RunExecuteReaderTds(cmdBehavior, runBehavior, returnStream, isAsync, timeout, out task, asyncWrite, isRetry, ds);
}
}

private void GenerateEnclavePackage()
{
if (keysToBeSentToEnclave == null || keysToBeSentToEnclave.Count <= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,99 @@ private void RunExecuteReaderTdsSetupReconnectContinuation(
});
}

private SqlDataReader RunExecuteReaderTdsWithTransparentParameterEncryption(
CommandBehavior cmdBehavior,
RunBehavior runBehavior,
bool returnStream,
bool isAsync,
int timeout,
out Task task,
bool asyncWrite,
bool isRetry,
SqlDataReader ds = null,
Task describeParameterEncryptionTask = null) // @TODO: This task should likely come from this method otherwise this is just setting up a continuation
{
Debug.Assert(!asyncWrite || isAsync, "AsyncWrite should be always accompanied by Async");

if (ds is null && returnStream)
{
ds = new SqlDataReader(command: this, cmdBehavior);
}

if (describeParameterEncryptionTask is not null)
{
// @TODO: I guess this means async execution? Using tasks as the primary means of determining async vs sync is clunky. It would be better to have separate async vs sync pathways.
long parameterEncryptionStart = ADP.TimerCurrent();

// @TODO: This can totally be a non-generic TCS
// @TODO: This is a prime candidate for proper async-await execution
TaskCompletionSource<object> completion = new TaskCompletionSource<object>();
AsyncHelper.ContinueTaskWithState(
task: describeParameterEncryptionTask,
completion: completion,
state: this,
onSuccess: state =>
{
SqlCommand command = (SqlCommand)state;
command.GenerateEnclavePackage();
command.RunExecuteReaderTds(
cmdBehavior,
runBehavior,
returnStream,
isAsync,
TdsParserStaticMethods.GetRemainingTimeout(timeout, parameterEncryptionStart),
out Task subTask,
asyncWrite,
isRetry,
ds);

if (subTask is null)
{
// @TODO: Why would this ever be the case? We should structure this so that it doesn't need to be checked.
completion.SetResult(null);
}
else
{
AsyncHelper.ContinueTaskWithState(
task: subTask,
completion: completion,
state: completion,
onSuccess: static state => ((TaskCompletionSource<object>)state).SetResult(null));
}
},
onFailure: static (exception, state) =>
{
((SqlCommand)state).CachedAsyncState?.ResetAsyncState();
if (exception is not null)
{
throw exception;
}
},
onCancellation: static state =>
{
((SqlCommand)state).CachedAsyncState?.ResetAsyncState();
});

task = completion.Task;
return ds;
}
else
{
// Synchronous execution
GenerateEnclavePackage();
return RunExecuteReaderTds(
cmdBehavior,
runBehavior,
returnStream,
isAsync,
timeout,
out task,
asyncWrite,
isRetry,
ds);
}
}

private SqlDataReader RunExecuteReaderWithRetry(
CommandBehavior cmdBehavior,
RunBehavior runBehavior,
Expand Down