Skip to content

Commit 3a1bc1c

Browse files
committed
Fix cursor leak.
1 parent 84020af commit 3a1bc1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

BTDB/ODBLayer/RelationDBManipulator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ public int RemoveByPrimaryKeyPrefix(in ReadOnlySpan<byte> keyBytesPrefix)
697697
{
698698
Span<byte> buf = stackalloc byte[4096];
699699
Span<byte> keyBuffer = stackalloc byte[1024];
700+
using var tempCursor = _kvtr.CreateCursor();
700701
var needImplementFreeContent = _relationInfo.NeedImplementFreeContent();
701702
using var enumerator = new RelationPrimaryKeyEnumerator<T>(_transaction, _relationInfo, keyBytesPrefix, 0)
702703
.GetEnumerator();
@@ -717,7 +718,6 @@ public int RemoveByPrimaryKeyPrefix(in ReadOnlySpan<byte> keyBytesPrefix)
717718

718719
if (_hasSecondaryIndexes)
719720
{
720-
using var tempCursor = _kvtr.CreateCursor();
721721
RemoveSecondaryIndexes(tempCursor,
722722
((RelationPrimaryKeyEnumerator<T>)enumerator).Cursor.GetKeySpan(ref keyBuffer, true),
723723
valueBytes);
@@ -772,7 +772,7 @@ public int RemoveByPrimaryKeyPrefixPartial(in ReadOnlySpan<byte> keyBytesPrefix,
772772

773773
if (_hasSecondaryIndexes)
774774
{
775-
var tempCursor = _kvtr.CreateCursor();
775+
using var tempCursor = _kvtr.CreateCursor();
776776
RemoveSecondaryIndexes(tempCursor,
777777
((RelationPrimaryKeyEnumerator<T>)enumerator).Cursor.GetKeySpan(ref keyBuffer), valueBytes);
778778
}

0 commit comments

Comments
 (0)