From cfdcd109d8582ac7cb5b69c48bb426f31f39e948 Mon Sep 17 00:00:00 2001 From: Patrick DeVivo Date: Wed, 11 Aug 2021 20:59:52 -0400 Subject: [PATCH] =?UTF-8?q?implement=20BestIndex=20estimated=20cost=20and?= =?UTF-8?q?=20usable=20constraint=20for=20when=20rep=E2=80=A6=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * implement BestIndex estimated cost and usable constraint for when repository is supplied * same fix for `refs` table * rm the estimated cost changes for now --- extensions/internal/git/log.go | 5 +++++ extensions/internal/git/refs.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/extensions/internal/git/log.go b/extensions/internal/git/log.go index 503ea58b..90978996 100644 --- a/extensions/internal/git/log.go +++ b/extensions/internal/git/log.go @@ -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 } diff --git a/extensions/internal/git/refs.go b/extensions/internal/git/refs.go index d863fdaf..7217d8ef 100644 --- a/extensions/internal/git/refs.go +++ b/extensions/internal/git/refs.go @@ -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 }