Skip to content

Commit

Permalink
implement BestIndex estimated cost and usable constraint for when rep… (
Browse files Browse the repository at this point in the history
#153)

* implement BestIndex estimated cost and usable constraint for when repository is supplied

* same fix for `refs` table

* rm the estimated cost changes for now
  • Loading branch information
patrickdevivo authored Aug 12, 2021
1 parent f776ddf commit cfdcd10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extensions/internal/git/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func (tab *gitLogTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexIn
return nil, sqlite.SQLITE_CONSTRAINT
}

// if repository is provided, it must be usable
if idx == 9 && !constraint.Usable {
return nil, sqlite.SQLITE_CONSTRAINT
}

if !constraint.Usable {
continue
}
Expand Down
5 changes: 5 additions & 0 deletions extensions/internal/git/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func (tab *gitRefTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexIn
out.ConstraintUsage = make([]*sqlite.ConstraintUsage, len(input.Constraints))

for i, constraint := range input.Constraints {
// if repository is provided, it must be usable
if constraint.ColumnIndex == 6 && !constraint.Usable {
return nil, sqlite.SQLITE_CONSTRAINT
}

if !constraint.Usable {
continue // we do not support unusable constraint at all
}
Expand Down

0 comments on commit cfdcd10

Please sign in to comment.