diff --git a/go/go.mod b/go/go.mod index 196f0a582c3..cbf06a9ffae 100644 --- a/go/go.mod +++ b/go/go.mod @@ -57,7 +57,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 github.com/creasty/defaults v1.6.0 github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 - github.com/dolthub/go-mysql-server v0.18.2-0.20240815142344-761713e36043 + github.com/dolthub/go-mysql-server v0.18.2-0.20240816004605-0fd0947fb3d8 github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 github.com/dolthub/swiss v0.1.0 github.com/goccy/go-json v0.10.2 diff --git a/go/go.sum b/go/go.sum index 4c7f7852b92..9d01a312bd2 100644 --- a/go/go.sum +++ b/go/go.sum @@ -183,8 +183,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-20230524105445-af7e7991c97e h1:kPsT4a47cw1+y/N5SSCkma7FhAPw7KeGmD6c9PBZW9Y= github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168= -github.com/dolthub/go-mysql-server v0.18.2-0.20240815142344-761713e36043 h1:KgrDVE4o4Y04XLnAs5BGv6I6z+Rd82FWntCbQEmbTKs= -github.com/dolthub/go-mysql-server v0.18.2-0.20240815142344-761713e36043/go.mod h1:nbdOzd0ceWONE80vbfwoRBjut7z3CIj69ZgDF/cKuaA= +github.com/dolthub/go-mysql-server v0.18.2-0.20240816004605-0fd0947fb3d8 h1:IMlS4ycXRhjRmYTgXCLX1jVSzeKlPCUpO5RHREzbCKY= +github.com/dolthub/go-mysql-server v0.18.2-0.20240816004605-0fd0947fb3d8/go.mod h1:nbdOzd0ceWONE80vbfwoRBjut7z3CIj69ZgDF/cKuaA= 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= diff --git a/go/libraries/doltcore/schema/index_coll.go b/go/libraries/doltcore/schema/index_coll.go index c09f256ae70..00c8c71c6de 100644 --- a/go/libraries/doltcore/schema/index_coll.go +++ b/go/libraries/doltcore/schema/index_coll.go @@ -41,7 +41,7 @@ type IndexCollection interface { Equals(other IndexCollection) bool // GetByName returns the index with the given name, or nil if it does not exist. GetByName(indexName string) Index - // GetByName returns the index with a matching case-insensitive name, the bool return value indicates if a match was found. + // GetByNameCaseInsensitive returns the index with a matching case-insensitive name, the bool return value indicates if a match was found. GetByNameCaseInsensitive(indexName string) (Index, bool) // GetIndexByColumnNames returns whether the collection contains an index that has this exact collection and ordering of columns. GetIndexByColumnNames(cols ...string) (Index, bool) @@ -173,10 +173,6 @@ func (ixc *indexCollectionImpl) AddIndex(indexes ...Index) { if ok { ixc.removeIndex(oldNamedIndex) } - oldTaggedIndex := ixc.containsColumnTagCollection(index.tags...) - if oldTaggedIndex != nil { - ixc.removeIndex(oldTaggedIndex) - } ixc.indexes[lowerName] = index for _, tag := range index.tags { ixc.colTagToIndex[tag] = append(ixc.colTagToIndex[tag], index) diff --git a/go/libraries/doltcore/schema/index_test.go b/go/libraries/doltcore/schema/index_test.go index 5c3ad696c99..c5b65ebadff 100644 --- a/go/libraries/doltcore/schema/index_test.go +++ b/go/libraries/doltcore/schema/index_test.go @@ -84,56 +84,30 @@ func TestIndexCollectionAddIndex(t *testing.T) { indexColl.clear(t) } - const prefix = "new_" - - t.Run("Tag Overwrites", func(t *testing.T) { + t.Run("Duplicate column set", func(t *testing.T) { for _, testIndex := range testIndexes { indexColl.AddIndex(testIndex) newIndex := testIndex.copy() - newIndex.name = prefix + testIndex.name + newIndex.name = "dupe_" + testIndex.name indexColl.AddIndex(newIndex) assert.Equal(t, newIndex, indexColl.GetByName(newIndex.Name())) - assert.Nil(t, indexColl.GetByName(testIndex.Name())) + assert.Equal(t, testIndex, indexColl.GetByName(testIndex.Name())) assert.Contains(t, indexColl.AllIndexes(), newIndex) - assert.NotContains(t, indexColl.AllIndexes(), testIndex) + assert.Contains(t, indexColl.AllIndexes(), testIndex) for _, tag := range newIndex.IndexedColumnTags() { assert.Contains(t, indexColl.IndexesWithTag(tag), newIndex) - assert.NotContains(t, indexColl.IndexesWithTag(tag), testIndex) + assert.Contains(t, indexColl.IndexesWithTag(tag), testIndex) } for _, col := range newIndex.ColumnNames() { assert.Contains(t, indexColl.IndexesWithColumn(col), newIndex) - assert.NotContains(t, indexColl.IndexesWithColumn(col), testIndex) + assert.Contains(t, indexColl.IndexesWithColumn(col), testIndex) } assert.True(t, indexColl.Contains(newIndex.Name())) - assert.False(t, indexColl.Contains(testIndex.Name())) + assert.True(t, indexColl.Contains(testIndex.Name())) assert.True(t, indexColl.hasIndexOnColumns(newIndex.ColumnNames()...)) assert.True(t, indexColl.hasIndexOnTags(newIndex.IndexedColumnTags()...)) } }) - - t.Run("Name Overwrites", func(t *testing.T) { - // should be able to reduce collection to one index - lastStanding := &indexImpl{ - name: "none", - tags: []uint64{4}, - allTags: []uint64{4, 1, 2}, - indexColl: indexColl, - } - - for _, testIndex := range testIndexes { - lastStanding.name = prefix + testIndex.name - indexColl.AddIndex(lastStanding) - } - - assert.Equal(t, map[string]*indexImpl{lastStanding.name: lastStanding}, indexColl.indexes) - for tag, indexes := range indexColl.colTagToIndex { - if tag == 4 { - assert.Equal(t, indexes, []*indexImpl{lastStanding}) - } else { - assert.Empty(t, indexes) - } - } - }) } func TestIndexCollectionAddIndexByColNames(t *testing.T) {