@@ -2272,8 +2272,8 @@ oldHashValues is not null &&
22722272 var newPkVal = row [ this . Columns [ this . PrimaryKeyIndex ] ] ? . ToString ( ) ?? string . Empty ;
22732273 if ( ! string . Equals ( newPkVal , oldPkValue ? . ToString ( ) , StringComparison . Ordinal ) )
22742274 {
2275- if ( ! string . IsNullOrEmpty ( oldPkValue ? . ToString ( ) ) )
2276- this . Index . Delete ( oldPkValue ! . ToString ( ) ! ) ;
2275+ if ( oldPkValue ? . ToString ( ) is { Length : > 0 } oldPkString )
2276+ this . Index . Delete ( oldPkString ) ;
22772277 if ( ! string . IsNullOrEmpty ( newPkVal ) )
22782278 this . Index . Insert ( newPkVal , oldPosition ) ;
22792279 }
@@ -2692,12 +2692,9 @@ private bool HasExplicitNamedIndex(string column)
26922692 // Transactional delete: buffer the physical offsets so the in-place marker is
26932693 // applied at COMMIT (rollback discards the buffer). Durable in O(delete) — the
26942694 // flush-time full-file rewrite is no longer needed for transactional deletes.
2695- foreach ( var position in positions )
2695+ foreach ( var position in positions . Where ( static position => position >= 0 ) )
26962696 {
2697- if ( position >= 0 )
2698- {
2699- this . storage . BufferTombstoneForCommit ( DataFile , position ) ;
2700- }
2697+ this . storage . BufferTombstoneForCommit ( DataFile , position ) ;
27012698 }
27022699 }
27032700 else
@@ -2755,10 +2752,10 @@ private void TombstoneRemainingVersionsOfDeletedKeys(List<(long storagePosition,
27552752 List < long > ? remainingPositions = null ;
27562753 if ( ! this . storage . AreRecordsEncrypted ( DataFile ) )
27572754 {
2758- remainingPositions = ScanLegacyPlaintextRemainingKeys ( DataFile , pkCol , deletedKeys ) ;
2755+ remainingPositions = ScanLegacyPlaintextRemainingKeys ( DataFile , deletedKeys ) ;
27592756 }
27602757
2761- remainingPositions ??= ScanLegacyRemainingKeysViaStorage ( DataFile , pkCol , deletedKeys ) ;
2758+ remainingPositions ??= ScanLegacyRemainingKeysViaStorage ( DataFile , deletedKeys ) ;
27622759 if ( remainingPositions is { Count : > 0 } )
27632760 {
27642761 TombstoneDeletedPositions ( remainingPositions . ToArray ( ) ) ;
@@ -2772,7 +2769,7 @@ private void TombstoneRemainingVersionsOfDeletedKeys(List<(long storagePosition,
27722769 /// <see langword="null"/> when the raw layout could not be parsed safely (the caller then falls
27732770 /// back to the storage-layer scan, which understands per-record encryption).
27742771 /// </summary>
2775- private List < long > ? ScanLegacyPlaintextRemainingKeys ( string dataFile , string pkCol , HashSet < string > deletedKeys )
2772+ private List < long > ? ScanLegacyPlaintextRemainingKeys ( string dataFile , HashSet < string > deletedKeys )
27762773 {
27772774 var matches = new List < long > ( ) ;
27782775 try
@@ -2822,7 +2819,7 @@ private void TombstoneRemainingVersionsOfDeletedKeys(List<(long storagePosition,
28222819 break ;
28232820 }
28242821
2825- if ( TryReadPrimaryKeyFromLegacyRecord ( recordData , pkCol , out var pkStr ) && deletedKeys . Contains ( pkStr ) )
2822+ if ( TryReadPrimaryKeyFromLegacyRecord ( recordData , out var pkStr ) && deletedKeys . Contains ( pkStr ) )
28262823 {
28272824 matches . Add ( position ) ;
28282825 }
@@ -2843,12 +2840,12 @@ private void TombstoneRemainingVersionsOfDeletedKeys(List<(long storagePosition,
28432840 /// plaintext raw scan is unavailable): iterates the records through
28442841 /// <c>storage.ReadAllRecords</c>, which decrypts payloads and already skips tombstone markers.
28452842 /// </summary>
2846- private List < long > ScanLegacyRemainingKeysViaStorage ( string dataFile , string pkCol , HashSet < string > deletedKeys )
2843+ private List < long > ScanLegacyRemainingKeysViaStorage ( string dataFile , HashSet < string > deletedKeys )
28472844 {
28482845 var matches = new List < long > ( ) ;
2849- foreach ( var ( recordOffset , recordData ) in this . storage ! . ReadAllRecords ( dataFile ) )
2846+ foreach ( var ( recordOffset , recordData ) in this . storage . ReadAllRecords ( dataFile ) )
28502847 {
2851- if ( TryReadPrimaryKeyFromLegacyRecord ( recordData , pkCol , out var pkStr ) && deletedKeys . Contains ( pkStr ) )
2848+ if ( TryReadPrimaryKeyFromLegacyRecord ( recordData , out var pkStr ) && deletedKeys . Contains ( pkStr ) )
28522849 {
28532850 matches . Add ( recordOffset ) ;
28542851 }
@@ -2861,7 +2858,7 @@ private List<long> ScanLegacyRemainingKeysViaStorage(string dataFile, string pkC
28612858 /// Walks a legacy variable-length record and returns the value of the primary-key column
28622859 /// (the same layout walk used by the reopen index rebuild).
28632860 /// </summary>
2864- private bool TryReadPrimaryKeyFromLegacyRecord ( byte [ ] recordData , string pkCol , out string ? pkValue )
2861+ private bool TryReadPrimaryKeyFromLegacyRecord ( byte [ ] recordData , out string ? pkValue )
28652862 {
28662863 pkValue = null ;
28672864 try
0 commit comments