Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/dolthub/fslock v0.0.3
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
github.com/dolthub/vitess v0.0.0-20250530231040-bfd522856394
github.com/dolthub/vitess v0.0.0-20250604183826-4944a453aecb
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568
Expand Down Expand Up @@ -60,7 +60,7 @@ require (
github.com/creasty/defaults v1.6.0
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20250603224837-4f0d9584b901
github.com/dolthub/go-mysql-server v0.20.1-0.20250604212210-442c793fb712
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/esote/minmaxheap v1.0.0
github.com/goccy/go-json v0.10.2
Expand Down
8 changes: 4 additions & 4 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.20.1-0.20250603224837-4f0d9584b901 h1:ARO4cKH/8Cg3vH2sPdr2ZPjm4Ssv1N3CSvoqLn/Lzss=
github.com/dolthub/go-mysql-server v0.20.1-0.20250603224837-4f0d9584b901/go.mod h1:nzF9N8zhb7MhYypvwvHfKrN/MaDfuX4K5zXsiK0XvDg=
github.com/dolthub/go-mysql-server v0.20.1-0.20250604212210-442c793fb712 h1:/cBPiX/pGQA4wR9vjcYISKOPzpilp9wQ1S9l5TL8bPc=
github.com/dolthub/go-mysql-server v0.20.1-0.20250604212210-442c793fb712/go.mod h1:Mz7jj+Wf9PziDgkvQ6DqmwMkFRSsHymCqmSoEw2Httw=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand All @@ -231,8 +231,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/vitess v0.0.0-20250530231040-bfd522856394 h1:sMwntvk7O9dttaJLqnOvy8zgk0ah9qnyWkAahfOgnIo=
github.com/dolthub/vitess v0.0.0-20250530231040-bfd522856394/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250604183826-4944a453aecb h1:/Tti0IJASR0xHMA5TRFalVUTGLKZsjcAhpWpCtJMadY=
github.com/dolthub/vitess v0.0.0-20250604183826-4944a453aecb/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
35 changes: 18 additions & 17 deletions go/libraries/doltcore/schema/index_coll.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sort"
"strings"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression/function/vector"
)

Expand Down Expand Up @@ -133,23 +134,26 @@ func NewIndexCollection(cols *ColCollection, pkCols *ColCollection) IndexCollect
return ixc
}

func (ixc indexCollectionImpl) Copy() IndexCollection {
func (ixc *indexCollectionImpl) Copy() IndexCollection {
// no need to copy the colColl, it's immutable
nixc := &indexCollectionImpl{
colColl: ixc.colColl,
}

if ixc.pks != nil {
pks := make([]uint64, len(ixc.pks))
copy(pks, ixc.pks)
ixc.pks = pks
nixc.pks = make([]uint64, len(ixc.pks))
copy(nixc.pks, ixc.pks)
}

if ixc.indexes != nil {
indexes := make(map[string]*indexImpl, len(ixc.indexes))
nixc.indexes = make(map[string]*indexImpl, len(ixc.indexes))
for name, index := range ixc.indexes {
indexes[name] = index.copy()
nixc.indexes[name] = index.copy()
}
ixc.indexes = indexes
}

if ixc.colTagToIndex != nil {
colTagToIndex := make(map[uint64][]*indexImpl, len(ixc.colTagToIndex))
nixc.colTagToIndex = make(map[uint64][]*indexImpl, len(ixc.colTagToIndex))
for tag, indexes := range ixc.colTagToIndex {
var indexesCopy []*indexImpl
if indexes != nil {
Expand All @@ -158,13 +162,11 @@ func (ixc indexCollectionImpl) Copy() IndexCollection {
indexesCopy[i] = index.copy()
}
}
colTagToIndex[tag] = indexesCopy
nixc.colTagToIndex[tag] = indexesCopy
}
ixc.colTagToIndex = colTagToIndex
}

// no need to copy the colColl, it's immutable
return &ixc
return nixc
}

func (ixc *indexCollectionImpl) AddIndex(indexes ...Index) {
Expand Down Expand Up @@ -202,7 +204,7 @@ func (ixc *indexCollectionImpl) AddIndexByColTags(indexName string, tags []uint6
return nil, fmt.Errorf("indexes cannot be prefixed with `dolt_`")
}
if ixc.Contains(lowerName) {
return nil, fmt.Errorf("`%s` already exists as an index for this table", lowerName)
return nil, sql.ErrDuplicateKey.New(lowerName)
}
if !ixc.tagsExist(tags...) {
return nil, fmt.Errorf("tags %v do not exist on this table", tags)
Expand Down Expand Up @@ -454,7 +456,7 @@ func (ixc *indexCollectionImpl) Merge(indexes ...Index) {
func (ixc *indexCollectionImpl) RemoveIndex(indexName string) (Index, error) {
lowerName := strings.ToLower(indexName)
if !ixc.Contains(lowerName) {
return nil, fmt.Errorf("`%s` does not exist as an index for this table", lowerName)
return nil, sql.ErrIndexNotFound.New(indexName)
}
index := ixc.indexes[lowerName]
delete(ixc.indexes, lowerName)
Expand All @@ -473,12 +475,11 @@ func (ixc *indexCollectionImpl) RemoveIndex(indexName string) (Index, error) {
func (ixc *indexCollectionImpl) RenameIndex(oldName, newName string) (Index, error) {
lowerCaseOldName := strings.ToLower(oldName)
lowerCaseNewName := strings.ToLower(newName)

if !ixc.Contains(lowerCaseOldName) {
return nil, fmt.Errorf("`%s` does not exist as an index for this table", oldName)
return nil, sql.ErrIndexNotFound.New(oldName)
}
if ixc.Contains(lowerCaseNewName) {
return nil, fmt.Errorf("`%s` already exists as an index for this table", newName)
return nil, sql.ErrDuplicateKey.New(newName)
}
index := ixc.indexes[lowerCaseOldName]
delete(ixc.indexes, lowerCaseOldName)
Expand Down