Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 4 additions & 13 deletions src/SharpCoreDB/DataStructures/Table.CRUD.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -2525,13 +2525,7 @@ this.storage is null ||
continue;
}

foreach (var colIdx in repoints)
{
if (!indexedColumns.Contains(colIdx))
{
indexedColumns.Add(colIdx);
}
}
indexedColumns.AddRange(repoints.Where(colIdx => !indexedColumns.Contains(colIdx)));
}

foreach (var colIdx in indexedColumns)
Expand DownExpand Up@@ -3745,7 +3739,7 @@ this.storage is null ||
/// whole-file snapshot. Returns null when the position/length is not fully contained in the
/// snapshot (caller falls back to the per-record read).
/// </summary>
private byte[]? TrySlicePayloadFromFile(byte[] wholeFile, long position)
private static byte[]? TrySlicePayloadFromFile(byte[] wholeFile, long position)
{
if (position < 0 || position + 4 > wholeFile.Length)
{
Expand DownExpand Up@@ -3973,12 +3967,9 @@ this.storage is null ||
{
// Transactional delete: buffer the physical offsets so the in-place marker is applied
// at COMMIT (see DeleteRecordsCore — rollback discards the buffer).
foreach (var position in positions)
foreach (var position in positions.Where(static position => position >= 0))
{
if (position >= 0)
{
this.storage.BufferTombstoneForCommit(DataFile, position);
}
this.storage.BufferTombstoneForCommit(DataFile, position);
}
}
else
Expand Down
21 changes: 10 additions & 11 deletions src/SharpCoreDB/Services/SqlParser.Core.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -311,20 +311,19 @@ public List<Dictionary<string, object>> ExecuteQuery(CachedQueryPlan plan, Dicti
// B8: direct hash-index point lookup for `WHERE indexed_col = @param|literal`. This
// skips building a WHERE string and re-parsing it inside SelectInternal — the single
// biggest overhead difference vs the Direct API (FindByIndex) on point reads.
if (TryResolveWhereValue(simple, parameters, out var whereValue) && whereValue is not null)
if (TryResolveWhereValue(simple, parameters, out var whereValue) &&
whereValue is not null &&
table is DataStructures.Table concrete &&
concrete.TrySelectIndexedPointLookup(simple.WhereColumn, whereValue, out var indexRows))
{
if (table is DataStructures.Table concrete &&
concrete.TrySelectIndexedPointLookup(simple.WhereColumn, whereValue, out var indexRows))
{
if (simple.Offset.HasValue && simple.Offset.Value > 0)
indexRows = [.. indexRows.Skip(simple.Offset.Value)];
if (simple.Offset.HasValue && simple.Offset.Value > 0)
indexRows = [.. indexRows.Skip(simple.Offset.Value)];

if (simple.Limit.HasValue && simple.Limit.Value > 0)
indexRows = [.. indexRows.Take(simple.Limit.Value)];
if (simple.Limit.HasValue && simple.Limit.Value > 0)
indexRows = [.. indexRows.Take(simple.Limit.Value)];

results = concrete.DeduplicateByPrimaryKey(indexRows);
return true;
}
results = concrete.DeduplicateByPrimaryKey(indexRows);
return true;
}

// Fallback: build the WHERE string exactly like the legacy binder and let the table
Expand Down
Loading