Skip to content

Commit

Permalink
feat(embedded/sql): query including historical rows
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>
  • Loading branch information
jeroiraz committed Oct 3, 2023
1 parent 716dd6f commit 9d666ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
22 changes: 12 additions & 10 deletions embedded/sql/row_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ type RowReader interface {
}

type ScanSpecs struct {
Index *Index
rangesByColID map[uint32]*typedValueRange
DescOrder bool
Index *Index
rangesByColID map[uint32]*typedValueRange
IncludeHistory bool
DescOrder bool
}

type Row struct {
Expand Down Expand Up @@ -250,13 +251,14 @@ func keyReaderSpecFrom(sqlPrefix []byte, table *Table, scanSpecs *ScanSpecs) (sp
}

return &store.KeyReaderSpec{
SeekKey: seekKey,
InclusiveSeek: true,
EndKey: endKey,
InclusiveEnd: true,
Prefix: prefix,
DescOrder: scanSpecs.DescOrder,
Filters: []store.FilterFn{store.IgnoreExpired, store.IgnoreDeleted},
SeekKey: seekKey,
InclusiveSeek: true,
EndKey: endKey,
InclusiveEnd: true,
Prefix: prefix,
DescOrder: scanSpecs.DescOrder,
Filters: []store.FilterFn{store.IgnoreExpired, store.IgnoreDeleted},
IncludeHistory: scanSpecs.IncludeHistory,
}, nil
}

Expand Down
8 changes: 5 additions & 3 deletions embedded/sql/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,7 @@ type DataSource interface {

type SelectStmt struct {
distinct bool
history bool
selectors []Selector
ds DataSource
indexOn []string
Expand Down Expand Up @@ -2563,9 +2564,10 @@ func (stmt *SelectStmt) genScanSpecs(tx *SQLTx, params map[string]interface{}) (
}

return &ScanSpecs{
Index: sortingIndex,
rangesByColID: rangesByColID,
DescOrder: descOrder,
Index: sortingIndex,
rangesByColID: rangesByColID,
IncludeHistory: stmt.history,
DescOrder: descOrder,
}, nil
}

Expand Down

0 comments on commit 9d666ea

Please sign in to comment.