Skip to content

Commit 7184881

Browse files
committed
undo what wasn't necesary
1 parent 410a6dd commit 7184881

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/SqlServer/src/Eventuous.SqlServer/Scripts/2_AppendEvents.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ BEGIN
2929
@current_version = @current_version OUTPUT,
3030
@stream_id = @stream_id OUTPUT;
3131

32+
SET @new_version = @current_version + @count_messages;
33+
3234
BEGIN TRY
33-
SET @new_version = @current_version + @count_messages;
3435

3536
/*
3637
If another writer raced us, the unique constraint (StreamId,StreamPosition) will throw here.
@@ -84,7 +85,8 @@ BEGIN
8485
UPDATE s
8586
SET [Version] = @new_version
8687
FROM __schema__.Streams s
87-
WHERE s.StreamId = @stream_id;
88+
WHERE s.StreamId = @stream_id
89+
AND s.[Version] = @current_version;
8890

8991
-- final GlobalPosition value to return
9092
SELECT @position = (

0 commit comments

Comments
 (0)