Skip to content

Commit 637f7b0

Browse files
committed
Use Output-clause in SqlServerFunctionStore's RestartExecution-method
1 parent eafb3a2 commit 637f7b0

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlGenerator.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,17 @@ public StoreCommand RestartExecution(StoredId storedId, int expectedEpoch, long
367367
Status = {(int)Status.Executing},
368368
Expires = @LeaseExpiration,
369369
Interrupted = 0
370-
WHERE FlowType = @FlowType AND FlowInstance = @FlowInstance AND Epoch = @ExpectedEpoch;
371-
372-
SELECT ParamJson,
373-
Status,
374-
ResultJson,
375-
ExceptionJson,
376-
Expires,
377-
Epoch,
378-
Interrupted,
379-
Timestamp,
380-
HumanInstanceId,
381-
Parent
382-
FROM {tablePrefix}
383-
WHERE FlowType = @FlowType AND FlowInstance = @FlowInstance";
370+
OUTPUT inserted.ParamJson,
371+
inserted.Status,
372+
inserted.ResultJson,
373+
inserted.ExceptionJson,
374+
inserted.Expires,
375+
inserted.Epoch,
376+
inserted.Interrupted,
377+
inserted.Timestamp,
378+
inserted.HumanInstanceId,
379+
inserted.Parent
380+
WHERE FlowType = @FlowType AND FlowInstance = @FlowInstance AND Epoch = @ExpectedEpoch;";
384381

385382
var storeCommand = StoreCommand.Create(_restartExecutionSql);
386383
storeCommand.AddParameter("@LeaseExpiration", leaseExpiration);

Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@ WHEN NOT MATCHED THEN
259259
.ToSqlCommand(conn);
260260

261261
await using var reader = await command.ExecuteReaderAsync();
262-
if (reader.RecordsAffected != 1)
263-
return null;
264-
265262
var sf = _sqlGenerator.ReadToStoredFlow(storedId, reader);
266263
if (sf?.Epoch != expectedEpoch + 1)
267264
return null;

0 commit comments

Comments
 (0)