mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-27 23:51:59 -05:00
adding index prefix lengths in creation instead of setting
This commit is contained in:
@@ -243,7 +243,7 @@ func toSchemaData(sch schema.Schema) (schemaData, error) {
|
||||
Comment: index.Comment(),
|
||||
Unique: index.IsUnique(),
|
||||
IsSystemDefined: !index.IsUserDefined(),
|
||||
PrefixLengths: index.GetPrefixLengths(),
|
||||
PrefixLengths: index.PrefixLengths(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ func (sd schemaData) addChecksIndexesAndPkOrderingToSchema(sch schema.Schema) er
|
||||
_, err := sch.Indexes().UnsafeAddIndexByColTags(
|
||||
encodedIndex.Name,
|
||||
encodedIndex.Tags,
|
||||
encodedIndex.PrefixLengths,
|
||||
schema.IndexProperties{
|
||||
IsUnique: encodedIndex.Unique,
|
||||
IsUserDefined: !encodedIndex.IsSystemDefined,
|
||||
@@ -311,10 +312,6 @@ func (sd schemaData) addChecksIndexesAndPkOrderingToSchema(sch schema.Schema) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = sch.Indexes().SetIndexPrefixLength(encodedIndex.Name, encodedIndex.PrefixLengths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, encodedCheck := range sd.CheckConstraints {
|
||||
|
||||
@@ -46,7 +46,7 @@ func createTestSchema() schema.Schema {
|
||||
|
||||
colColl := schema.NewColCollection(columns...)
|
||||
sch := schema.MustSchemaFromCols(colColl)
|
||||
_, _ = sch.Indexes().AddIndexByColTags("idx_age", []uint64{3}, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
_, _ = sch.Indexes().AddIndexByColTags("idx_age", []uint64{3}, nil, schema.IndexProperties{IsUnique: false, Comment: ""})
|
||||
return sch
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func (tsd testSchemaData) decodeSchema() (schema.Schema, error) {
|
||||
sch.SetCollation(tsd.Collation)
|
||||
|
||||
for _, encodedIndex := range tsd.IndexCollection {
|
||||
_, err = sch.Indexes().AddIndexByColTags(encodedIndex.Name, encodedIndex.Tags, schema.IndexProperties{IsUnique: encodedIndex.Unique, Comment: encodedIndex.Comment})
|
||||
_, err = sch.Indexes().AddIndexByColTags(encodedIndex.Name, encodedIndex.Tags, nil, schema.IndexProperties{IsUnique: encodedIndex.Unique, Comment: encodedIndex.Comment})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ func serializeSecondaryIndexes(b *fb.Builder, sch schema.Schema, indexes []schem
|
||||
ko := b.EndVector(len(tags))
|
||||
|
||||
// serialize prefix lengths
|
||||
prefixLengths := idx.GetPrefixLengths()
|
||||
prefixLengths := idx.PrefixLengths()
|
||||
serial.IndexStartPrefixLengthsVector(b, len(prefixLengths))
|
||||
for j := len(prefixLengths) - 1; j >= 0; j-- {
|
||||
b.PrependUint16(prefixLengths[j])
|
||||
@@ -381,17 +381,15 @@ func deserializeSecondaryIndexes(sch schema.Schema, s *serial.TableSchema) error
|
||||
tags[j] = col.Tag()
|
||||
}
|
||||
|
||||
_, err := sch.Indexes().AddIndexByColTags(name, tags, props)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prefixLengths := make([]uint16, idx.PrefixLengthsLength())
|
||||
for j := range prefixLengths {
|
||||
prefixLengths[j] = idx.PrefixLengths(j)
|
||||
}
|
||||
schIdx := sch.Indexes().GetByName(name)
|
||||
schIdx.SetPrefixLengths(prefixLengths)
|
||||
|
||||
_, err := sch.Indexes().AddIndexByColTags(name, tags, prefixLengths, props)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user