diff --git a/pkg/ccl/schemachangerccl/testdata/decomp/multiregion b/pkg/ccl/schemachangerccl/testdata/decomp/multiregion index 38541b7044cf..6ab291dcbc4a 100644 --- a/pkg/ccl/schemachangerccl/testdata/decomp/multiregion +++ b/pkg/ccl/schemachangerccl/testdata/decomp/multiregion @@ -1373,7 +1373,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east1 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - IndexZoneConfig: @@ -1406,7 +1409,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east2 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - IndexZoneConfig: @@ -1439,7 +1445,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east3 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - Namespace: @@ -1483,7 +1492,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east1 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - PartitionZoneConfig: @@ -1517,7 +1529,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east2 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - PartitionZoneConfig: @@ -1551,7 +1566,10 @@ ElementState: numReplicas: 2 indexId: 1 partitionName: us-east3 - subzoneSpans: [] + subzoneSpan: + endKey: null + key: null + subzoneIndex: 0 tableId: 108 Status: PUBLIC - PrimaryIndex: diff --git a/pkg/config/zonepb/zone.go b/pkg/config/zonepb/zone.go index 6dfbccc69e42..a780fa797c1e 100644 --- a/pkg/config/zonepb/zone.go +++ b/pkg/config/zonepb/zone.go @@ -10,6 +10,7 @@ import ( "context" "encoding/json" "fmt" + "slices" "strconv" "strings" @@ -1153,6 +1154,23 @@ func (z *ZoneConfig) DeleteSubzone(indexID uint32, partition string) bool { return false } +// SetSubzoneSpan installs subzoneSpan into the ZoneConfig, overwriting any +// existing subzone span with the same SubzoneIndex. If we end up adding a new +// span to the list, we sort the list in the end. +func (z *ZoneConfig) SetSubzoneSpan(subzoneSpan SubzoneSpan) { + for i, s := range z.SubzoneSpans { + if s.SubzoneIndex == subzoneSpan.SubzoneIndex { + z.SubzoneSpans[i] = subzoneSpan + return + } + } + + z.SubzoneSpans = append(z.SubzoneSpans, subzoneSpan) + slices.SortFunc(z.SubzoneSpans, func(a, b SubzoneSpan) int { + return a.Key.Compare(b.Key) + }) +} + // DeleteIndexSubzones deletes all subzones that refer to the index with the // specified ID. This includes subzones for partitions of the index as well as // the index subzone itself. diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/index_zone_config.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/index_zone_config.go index 57ea7ed5a92a..c4b1e6eed103 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/index_zone_config.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/index_zone_config.go @@ -50,11 +50,26 @@ func (izo *indexZoneConfigObj) getZoneConfigElem(b BuildCtx) scpb.Element { panic(err) } + // Find the index of our subzone in our subzones list, along with the + // corresponding span. + var subzoneIdx int + for i, sub := range subzones { + if sub.IndexID == uint32(izo.indexID) && sub.PartitionName == "" { + subzoneIdx = i + } + } + var subzoneSpans []zonepb.SubzoneSpan + for _, s := range ss { + if s.SubzoneIndex == int32(subzoneIdx) { + subzoneSpans = append(subzoneSpans, s) + } + } + elem := &scpb.IndexZoneConfig{ TableID: izo.tableID, IndexID: izo.indexID, Subzone: *izo.indexSubzone, - SubzoneSpans: ss, + SubzoneSpans: subzoneSpans, SeqNum: izo.seqNum, } return elem diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go index 1e8bd8434acf..891e61bdc09a 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go @@ -54,12 +54,27 @@ func (pzo *partitionZoneConfigObj) getZoneConfigElem(b BuildCtx) scpb.Element { panic(err) } + // Find the index of our subzone in our subzones list, along with the + // corresponding span. + var subzoneIdx int + for i, sub := range subzones { + if sub.IndexID == uint32(pzo.indexID) && sub.PartitionName == pzo.partitionName { + subzoneIdx = i + } + } + var subzoneSpans []zonepb.SubzoneSpan + for _, s := range ss { + if s.SubzoneIndex == int32(subzoneIdx) { + subzoneSpans = append(subzoneSpans, s) + } + } + elem := &scpb.PartitionZoneConfig{ TableID: pzo.tableID, IndexID: pzo.indexID, PartitionName: pzo.partitionName, Subzone: *pzo.partitionSubzone, - SubzoneSpans: ss, + SubzoneSpans: subzoneSpans, SeqNum: pzo.seqNum, } return elem @@ -101,10 +116,6 @@ func (pzo *partitionZoneConfigObj) retrieveCompleteZoneConfig( if getInheritedDefault { zc, err = pzo.getInheritedDefaultZoneConfig(b) } else { - //zc, err = pzo.tableZoneConfigObj.getZoneConfig(b, false /* inheritDefaultRange */) - //if err != nil { - // return nil, nil, err - //} placeholder, err = pzo.getZoneConfig(b, false /* inheritDefaultRange */) } if err != nil { diff --git a/pkg/sql/schemachanger/scdeps/exec_deps.go b/pkg/sql/schemachanger/scdeps/exec_deps.go index 78eef6773c61..24dd015a5731 100644 --- a/pkg/sql/schemachanger/scdeps/exec_deps.go +++ b/pkg/sql/schemachanger/scdeps/exec_deps.go @@ -239,11 +239,12 @@ func (d *txnDeps) UpdateZoneConfig(ctx context.Context, id descpb.ID, zc *zonepb } // UpdateSubzoneConfig implements the scexec.Catalog interface. +// +// N.B. UpdateSubzoneConfig assumes that a subzone at index i in the subzones +// list has the corresponding subzone span in the subzone span list at the same +// index. func (d *txnDeps) UpdateSubzoneConfig( - ctx context.Context, - tableID descpb.ID, - subzones []zonepb.Subzone, - subzoneSpans []zonepb.SubzoneSpan, + ctx context.Context, tableID descpb.ID, subzone zonepb.Subzone, subzoneSpans []zonepb.SubzoneSpan, ) error { var newZc catalog.ZoneConfig oldZc, err := d.descsCollection.GetZoneConfig(ctx, d.txn.KV(), tableID) @@ -260,16 +261,25 @@ func (d *txnDeps) UpdateSubzoneConfig( rawBytes = oldZc.GetRawBytesInStorage() zc = oldZc.ZoneConfigProto() } else { - // If no zone config exists, create a new one that is a subzone placeholder. + // If no zone config exists, create a new one that is a s placeholder. zc = zonepb.NewZoneConfig() zc.DeleteTableConfig() } - // Update the subzones in the zone config. - for _, s := range subzones { - zc.SetSubzone(s) + // Update the subzone in the zone config. + zc.SetSubzone(subzone) + // Update the subzone spans. + subzoneSpansToWrite := subzoneSpans + // If there are subzone spans that currently exist, merge those with the new + // spans we are updating. Otherwise, the zone config's set of subzone spans + // will be our input subzoneSpans. + if len(zc.SubzoneSpans) != 0 { + for _, s := range subzoneSpansToWrite { + zc.SetSubzoneSpan(s) + } + subzoneSpansToWrite = zc.SubzoneSpans } - zc.SubzoneSpans = subzoneSpans + zc.SubzoneSpans = subzoneSpansToWrite newZc = zone.NewZoneConfigWithRawBytes(zc, rawBytes) return d.descsCollection.WriteZoneConfigToBatch(ctx, d.kvTrace, d.getOrCreateBatch(), diff --git a/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go b/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go index ba772137d4e5..b0ab0a1462db 100644 --- a/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go +++ b/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go @@ -820,24 +820,21 @@ func (s *TestState) UpdateZoneConfig( // UpdateSubzoneConfig implements the scexec.Catalog interface. func (s *TestState) UpdateSubzoneConfig( - ctx context.Context, - tableID descpb.ID, - subzones []zonepb.Subzone, - subzoneSpans []zonepb.SubzoneSpan, + ctx context.Context, tableID descpb.ID, subzone zonepb.Subzone, subzoneSpans []zonepb.SubzoneSpan, ) error { if s.catalogChanges.zoneConfigsToUpdate == nil { s.catalogChanges.zoneConfigsToUpdate = make(map[descpb.ID]*zonepb.ZoneConfig) } var zc *zonepb.ZoneConfig if czc, ok := s.catalogChanges.zoneConfigsToUpdate[tableID]; ok { - czc.Subzones = subzones - czc.SubzoneSpans = subzoneSpans zc = czc } else { zc = zonepb.NewZoneConfig() zc.DeleteTableConfig() - zc.Subzones = subzones - zc.SubzoneSpans = subzoneSpans + } + zc.SetSubzone(subzone) + for _, ss := range subzoneSpans { + zc.SetSubzoneSpan(ss) } s.catalogChanges.zoneConfigsToUpdate[tableID] = zc return nil diff --git a/pkg/sql/schemachanger/scexec/dependencies.go b/pkg/sql/schemachanger/scexec/dependencies.go index 25d0ca03285e..3026830cb499 100644 --- a/pkg/sql/schemachanger/scexec/dependencies.go +++ b/pkg/sql/schemachanger/scexec/dependencies.go @@ -75,7 +75,7 @@ type Catalog interface { UpdateSubzoneConfig( ctx context.Context, tableID descpb.ID, - subzones []zonepb.Subzone, + subzone zonepb.Subzone, subzoneSpans []zonepb.SubzoneSpan, ) error diff --git a/pkg/sql/schemachanger/scexec/exec_immediate_mutation.go b/pkg/sql/schemachanger/scexec/exec_immediate_mutation.go index 49bcf33f06a4..72670644735a 100644 --- a/pkg/sql/schemachanger/scexec/exec_immediate_mutation.go +++ b/pkg/sql/schemachanger/scexec/exec_immediate_mutation.go @@ -236,7 +236,9 @@ func (s *immediateState) exec(ctx context.Context, c Catalog) error { for _, zcToUpdate := range s.modifiedZoneConfigs { if zcToUpdate.isSubzoneConfig { - if err := c.UpdateSubzoneConfig(ctx, zcToUpdate.id, zcToUpdate.zc.Subzones, + // TODO(before merge): unsatisfied with this; would it be better to + // separate subzone configs from the modifiedZoneConfigs list? + if err := c.UpdateSubzoneConfig(ctx, zcToUpdate.id, zcToUpdate.zc.Subzones[0], zcToUpdate.zc.SubzoneSpans); err != nil { return err } diff --git a/pkg/sql/schemachanger/scexec/mocks_generated_test.go b/pkg/sql/schemachanger/scexec/mocks_generated_test.go index c264c45a5e86..ee5cb7535c0d 100644 --- a/pkg/sql/schemachanger/scexec/mocks_generated_test.go +++ b/pkg/sql/schemachanger/scexec/mocks_generated_test.go @@ -59,7 +59,9 @@ func (mr *MockCatalogMockRecorder) AddName(arg0, arg1, arg2 interface{}) *gomock } // CreateOrUpdateDescriptor mocks base method. -func (m *MockCatalog) CreateOrUpdateDescriptor(arg0 context.Context, arg1 catalog.MutableDescriptor) error { +func (m *MockCatalog) CreateOrUpdateDescriptor( + arg0 context.Context, arg1 catalog.MutableDescriptor, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateOrUpdateDescriptor", arg0, arg1) ret0, _ := ret[0].(error) @@ -101,7 +103,9 @@ func (mr *MockCatalogMockRecorder) DeleteDescriptor(arg0, arg1 interface{}) *gom } // DeleteName mocks base method. -func (m *MockCatalog) DeleteName(arg0 context.Context, arg1 descpb.NameInfo, arg2 catid.DescID) error { +func (m *MockCatalog) DeleteName( + arg0 context.Context, arg1 descpb.NameInfo, arg2 catid.DescID, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteName", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -129,7 +133,9 @@ func (mr *MockCatalogMockRecorder) DeleteZoneConfig(arg0, arg1 interface{}) *gom } // GetFullyQualifiedName mocks base method. -func (m *MockCatalog) GetFullyQualifiedName(arg0 context.Context, arg1 catid.DescID) (string, error) { +func (m *MockCatalog) GetFullyQualifiedName( + arg0 context.Context, arg1 catid.DescID, +) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetFullyQualifiedName", arg0, arg1) ret0, _ := ret[0].(string) @@ -162,13 +168,17 @@ func (m *MockCatalog) InsertTemporarySchema(arg0 string, arg1, arg2 catid.DescID } // InsertTemporarySchema indicates an expected call of InsertTemporarySchema. -func (mr *MockCatalogMockRecorder) InsertTemporarySchema(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockCatalogMockRecorder) InsertTemporarySchema( + arg0, arg1, arg2 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertTemporarySchema", reflect.TypeOf((*MockCatalog)(nil).InsertTemporarySchema), arg0, arg1, arg2) } // MustReadImmutableDescriptors mocks base method. -func (m *MockCatalog) MustReadImmutableDescriptors(arg0 context.Context, arg1 ...catid.DescID) ([]catalog.Descriptor, error) { +func (m *MockCatalog) MustReadImmutableDescriptors( + arg0 context.Context, arg1 ...catid.DescID, +) ([]catalog.Descriptor, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { @@ -181,14 +191,18 @@ func (m *MockCatalog) MustReadImmutableDescriptors(arg0 context.Context, arg1 .. } // MustReadImmutableDescriptors indicates an expected call of MustReadImmutableDescriptors. -func (mr *MockCatalogMockRecorder) MustReadImmutableDescriptors(arg0 interface{}, arg1 ...interface{}) *gomock.Call { +func (mr *MockCatalogMockRecorder) MustReadImmutableDescriptors( + arg0 interface{}, arg1 ...interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{arg0}, arg1...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MustReadImmutableDescriptors", reflect.TypeOf((*MockCatalog)(nil).MustReadImmutableDescriptors), varargs...) } // MustReadMutableDescriptor mocks base method. -func (m *MockCatalog) MustReadMutableDescriptor(arg0 context.Context, arg1 catid.DescID) (catalog.MutableDescriptor, error) { +func (m *MockCatalog) MustReadMutableDescriptor( + arg0 context.Context, arg1 catid.DescID, +) (catalog.MutableDescriptor, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MustReadMutableDescriptor", arg0, arg1) ret0, _ := ret[0].(catalog.MutableDescriptor) @@ -231,7 +245,9 @@ func (mr *MockCatalogMockRecorder) Run(arg0 interface{}) *gomock.Call { } // UpdateComment mocks base method. -func (m *MockCatalog) UpdateComment(arg0 context.Context, arg1 catalogkeys.CommentKey, arg2 string) error { +func (m *MockCatalog) UpdateComment( + arg0 context.Context, arg1 catalogkeys.CommentKey, arg2 string, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateComment", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -245,21 +261,27 @@ func (mr *MockCatalogMockRecorder) UpdateComment(arg0, arg1, arg2 interface{}) * } // UpdateSubzoneConfig mocks base method. -func (m *MockCatalog) UpdateSubzoneConfig(arg0 context.Context, arg1 catid.DescID, arg2 []zonepb.Subzone, arg3 []zonepb.SubzoneSpan) error { +func (m *MockCatalog) UpdateSubzoneConfig( + ctx context.Context, tableID descpb.ID, subzone zonepb.Subzone, subzoneSpans []zonepb.SubzoneSpan, +) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateSubzoneConfig", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "UpdateSubzoneConfig", arg0, arg1, subzone, arg3) ret0, _ := ret[0].(error) return ret0 } // UpdateSubzoneConfig indicates an expected call of UpdateSubzoneConfig. -func (mr *MockCatalogMockRecorder) UpdateSubzoneConfig(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockCatalogMockRecorder) UpdateSubzoneConfig( + arg0, arg1, arg2, arg3 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSubzoneConfig", reflect.TypeOf((*MockCatalog)(nil).UpdateSubzoneConfig), arg0, arg1, arg2, arg3) } // UpdateZoneConfig mocks base method. -func (m *MockCatalog) UpdateZoneConfig(arg0 context.Context, arg1 catid.DescID, arg2 *zonepb.ZoneConfig) error { +func (m *MockCatalog) UpdateZoneConfig( + arg0 context.Context, arg1 catid.DescID, arg2 *zonepb.ZoneConfig, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateZoneConfig", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -366,7 +388,9 @@ func (mr *MockDependenciesMockRecorder) ClusterSettings() *gomock.Call { } // DescriptorMetadataUpdater mocks base method. -func (m *MockDependencies) DescriptorMetadataUpdater(arg0 context.Context) scexec.DescriptorMetadataUpdater { +func (m *MockDependencies) DescriptorMetadataUpdater( + arg0 context.Context, +) scexec.DescriptorMetadataUpdater { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DescriptorMetadataUpdater", arg0) ret0, _ := ret[0].(scexec.DescriptorMetadataUpdater) @@ -557,7 +581,13 @@ func (m *MockBackfiller) EXPECT() *MockBackfillerMockRecorder { } // BackfillIndexes mocks base method. -func (m *MockBackfiller) BackfillIndexes(arg0 context.Context, arg1 scexec.BackfillProgress, arg2 scexec.BackfillerProgressWriter, arg3 *jobs.Job, arg4 catalog.TableDescriptor) error { +func (m *MockBackfiller) BackfillIndexes( + arg0 context.Context, + arg1 scexec.BackfillProgress, + arg2 scexec.BackfillerProgressWriter, + arg3 *jobs.Job, + arg4 catalog.TableDescriptor, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BackfillIndexes", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(error) @@ -565,13 +595,17 @@ func (m *MockBackfiller) BackfillIndexes(arg0 context.Context, arg1 scexec.Backf } // BackfillIndexes indicates an expected call of BackfillIndexes. -func (mr *MockBackfillerMockRecorder) BackfillIndexes(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockBackfillerMockRecorder) BackfillIndexes( + arg0, arg1, arg2, arg3, arg4 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BackfillIndexes", reflect.TypeOf((*MockBackfiller)(nil).BackfillIndexes), arg0, arg1, arg2, arg3, arg4) } // MaybePrepareDestIndexesForBackfill mocks base method. -func (m *MockBackfiller) MaybePrepareDestIndexesForBackfill(arg0 context.Context, arg1 scexec.BackfillProgress, arg2 catalog.TableDescriptor) (scexec.BackfillProgress, error) { +func (m *MockBackfiller) MaybePrepareDestIndexesForBackfill( + arg0 context.Context, arg1 scexec.BackfillProgress, arg2 catalog.TableDescriptor, +) (scexec.BackfillProgress, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MaybePrepareDestIndexesForBackfill", arg0, arg1, arg2) ret0, _ := ret[0].(scexec.BackfillProgress) @@ -580,7 +614,9 @@ func (m *MockBackfiller) MaybePrepareDestIndexesForBackfill(arg0 context.Context } // MaybePrepareDestIndexesForBackfill indicates an expected call of MaybePrepareDestIndexesForBackfill. -func (mr *MockBackfillerMockRecorder) MaybePrepareDestIndexesForBackfill(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockBackfillerMockRecorder) MaybePrepareDestIndexesForBackfill( + arg0, arg1, arg2 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePrepareDestIndexesForBackfill", reflect.TypeOf((*MockBackfiller)(nil).MaybePrepareDestIndexesForBackfill), arg0, arg1, arg2) } @@ -609,7 +645,13 @@ func (m *MockMerger) EXPECT() *MockMergerMockRecorder { } // MergeIndexes mocks base method. -func (m *MockMerger) MergeIndexes(arg0 context.Context, arg1 *jobs.Job, arg2 scexec.MergeProgress, arg3 scexec.BackfillerProgressWriter, arg4 catalog.TableDescriptor) error { +func (m *MockMerger) MergeIndexes( + arg0 context.Context, + arg1 *jobs.Job, + arg2 scexec.MergeProgress, + arg3 scexec.BackfillerProgressWriter, + arg4 catalog.TableDescriptor, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MergeIndexes", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(error) @@ -617,7 +659,9 @@ func (m *MockMerger) MergeIndexes(arg0 context.Context, arg1 *jobs.Job, arg2 sce } // MergeIndexes indicates an expected call of MergeIndexes. -func (mr *MockMergerMockRecorder) MergeIndexes(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockMergerMockRecorder) MergeIndexes( + arg0, arg1, arg2, arg3, arg4 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MergeIndexes", reflect.TypeOf((*MockMerger)(nil).MergeIndexes), arg0, arg1, arg2, arg3, arg4) } @@ -674,7 +718,9 @@ func (mr *MockBackfillerTrackerMockRecorder) FlushFractionCompleted(arg0 interfa } // GetBackfillProgress mocks base method. -func (m *MockBackfillerTracker) GetBackfillProgress(arg0 context.Context, arg1 scexec.Backfill) (scexec.BackfillProgress, error) { +func (m *MockBackfillerTracker) GetBackfillProgress( + arg0 context.Context, arg1 scexec.Backfill, +) (scexec.BackfillProgress, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBackfillProgress", arg0, arg1) ret0, _ := ret[0].(scexec.BackfillProgress) @@ -683,13 +729,17 @@ func (m *MockBackfillerTracker) GetBackfillProgress(arg0 context.Context, arg1 s } // GetBackfillProgress indicates an expected call of GetBackfillProgress. -func (mr *MockBackfillerTrackerMockRecorder) GetBackfillProgress(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBackfillerTrackerMockRecorder) GetBackfillProgress( + arg0, arg1 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBackfillProgress", reflect.TypeOf((*MockBackfillerTracker)(nil).GetBackfillProgress), arg0, arg1) } // GetMergeProgress mocks base method. -func (m *MockBackfillerTracker) GetMergeProgress(arg0 context.Context, arg1 scexec.Merge) (scexec.MergeProgress, error) { +func (m *MockBackfillerTracker) GetMergeProgress( + arg0 context.Context, arg1 scexec.Merge, +) (scexec.MergeProgress, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMergeProgress", arg0, arg1) ret0, _ := ret[0].(scexec.MergeProgress) @@ -704,7 +754,9 @@ func (mr *MockBackfillerTrackerMockRecorder) GetMergeProgress(arg0, arg1 interfa } // SetBackfillProgress mocks base method. -func (m *MockBackfillerTracker) SetBackfillProgress(arg0 context.Context, arg1 scexec.BackfillProgress) error { +func (m *MockBackfillerTracker) SetBackfillProgress( + arg0 context.Context, arg1 scexec.BackfillProgress, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetBackfillProgress", arg0, arg1) ret0, _ := ret[0].(error) @@ -712,13 +764,17 @@ func (m *MockBackfillerTracker) SetBackfillProgress(arg0 context.Context, arg1 s } // SetBackfillProgress indicates an expected call of SetBackfillProgress. -func (mr *MockBackfillerTrackerMockRecorder) SetBackfillProgress(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBackfillerTrackerMockRecorder) SetBackfillProgress( + arg0, arg1 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBackfillProgress", reflect.TypeOf((*MockBackfillerTracker)(nil).SetBackfillProgress), arg0, arg1) } // SetMergeProgress mocks base method. -func (m *MockBackfillerTracker) SetMergeProgress(arg0 context.Context, arg1 scexec.MergeProgress) error { +func (m *MockBackfillerTracker) SetMergeProgress( + arg0 context.Context, arg1 scexec.MergeProgress, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetMergeProgress", arg0, arg1) ret0, _ := ret[0].(error) @@ -755,7 +811,9 @@ func (m *MockIndexSpanSplitter) EXPECT() *MockIndexSpanSplitterMockRecorder { } // MaybeSplitIndexSpans mocks base method. -func (m *MockIndexSpanSplitter) MaybeSplitIndexSpans(arg0 context.Context, arg1 catalog.TableDescriptor, arg2 catalog.Index) error { +func (m *MockIndexSpanSplitter) MaybeSplitIndexSpans( + arg0 context.Context, arg1 catalog.TableDescriptor, arg2 catalog.Index, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MaybeSplitIndexSpans", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -763,13 +821,17 @@ func (m *MockIndexSpanSplitter) MaybeSplitIndexSpans(arg0 context.Context, arg1 } // MaybeSplitIndexSpans indicates an expected call of MaybeSplitIndexSpans. -func (mr *MockIndexSpanSplitterMockRecorder) MaybeSplitIndexSpans(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockIndexSpanSplitterMockRecorder) MaybeSplitIndexSpans( + arg0, arg1, arg2 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybeSplitIndexSpans", reflect.TypeOf((*MockIndexSpanSplitter)(nil).MaybeSplitIndexSpans), arg0, arg1, arg2) } // MaybeSplitIndexSpansForPartitioning mocks base method. -func (m *MockIndexSpanSplitter) MaybeSplitIndexSpansForPartitioning(arg0 context.Context, arg1 catalog.TableDescriptor, arg2 catalog.Index) error { +func (m *MockIndexSpanSplitter) MaybeSplitIndexSpansForPartitioning( + arg0 context.Context, arg1 catalog.TableDescriptor, arg2 catalog.Index, +) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MaybeSplitIndexSpansForPartitioning", arg0, arg1, arg2) ret0, _ := ret[0].(error) @@ -777,7 +839,9 @@ func (m *MockIndexSpanSplitter) MaybeSplitIndexSpansForPartitioning(arg0 context } // MaybeSplitIndexSpansForPartitioning indicates an expected call of MaybeSplitIndexSpansForPartitioning. -func (mr *MockIndexSpanSplitterMockRecorder) MaybeSplitIndexSpansForPartitioning(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockIndexSpanSplitterMockRecorder) MaybeSplitIndexSpansForPartitioning( + arg0, arg1, arg2 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybeSplitIndexSpansForPartitioning", reflect.TypeOf((*MockIndexSpanSplitter)(nil).MaybeSplitIndexSpansForPartitioning), arg0, arg1, arg2) } @@ -806,7 +870,9 @@ func (m *MockPeriodicProgressFlusher) EXPECT() *MockPeriodicProgressFlusherMockR } // StartPeriodicUpdates mocks base method. -func (m *MockPeriodicProgressFlusher) StartPeriodicUpdates(arg0 context.Context, arg1 scexec.BackfillerProgressFlusher) func() error { +func (m *MockPeriodicProgressFlusher) StartPeriodicUpdates( + arg0 context.Context, arg1 scexec.BackfillerProgressFlusher, +) func() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StartPeriodicUpdates", arg0, arg1) ret0, _ := ret[0].(func() error) @@ -814,7 +880,9 @@ func (m *MockPeriodicProgressFlusher) StartPeriodicUpdates(arg0 context.Context, } // StartPeriodicUpdates indicates an expected call of StartPeriodicUpdates. -func (mr *MockPeriodicProgressFlusherMockRecorder) StartPeriodicUpdates(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockPeriodicProgressFlusherMockRecorder) StartPeriodicUpdates( + arg0, arg1 interface{}, +) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartPeriodicUpdates", reflect.TypeOf((*MockPeriodicProgressFlusher)(nil).StartPeriodicUpdates), arg0, arg1) } diff --git a/pkg/sql/schemachanger/scexec/scmutationexec/dependencies.go b/pkg/sql/schemachanger/scexec/scmutationexec/dependencies.go index 45958ab58c55..739774ebef69 100644 --- a/pkg/sql/schemachanger/scexec/scmutationexec/dependencies.go +++ b/pkg/sql/schemachanger/scexec/scmutationexec/dependencies.go @@ -83,7 +83,9 @@ type ImmediateMutationStateUpdater interface { // UpdateSubzoneConfig upserts a subzone config. UpdateSubzoneConfig( - tableid descpb.ID, subzone zonepb.Subzone, subzoneSpans []zonepb.SubzoneSpan, + tableid descpb.ID, + subzone zonepb.Subzone, + subzoneSpans []zonepb.SubzoneSpan, ) // DeleteZoneConfig deletes the zone config for the given ID. diff --git a/pkg/sql/schemachanger/scpb/elements.proto b/pkg/sql/schemachanger/scpb/elements.proto index 8d30ddcb1856..aa78970232ba 100644 --- a/pkg/sql/schemachanger/scpb/elements.proto +++ b/pkg/sql/schemachanger/scpb/elements.proto @@ -758,8 +758,6 @@ message IndexZoneConfig { uint32 table_id = 1 [(gogoproto.customname) = "TableID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.DescID"]; uint32 index_id = 2 [(gogoproto.customname) = "IndexID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.IndexID"]; cockroach.config.zonepb.Subzone subzone = 3 [(gogoproto.nullable) = false]; - // `subzone_spans` is used solely for zone config writes. These spans are - // recreated for the table zone config during each configuration change. repeated cockroach.config.zonepb.SubzoneSpan subzone_spans = 4 [(gogoproto.nullable) = false]; // `seq_num` is used to differentiate different subzone config elements tied // to the same index. E.g. If we attempt to update an index subzone config, @@ -773,8 +771,6 @@ message PartitionZoneConfig { uint32 index_id = 2 [(gogoproto.customname) = "IndexID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.IndexID"]; string partition_name = 3; cockroach.config.zonepb.Subzone subzone = 4 [(gogoproto.nullable) = false]; - // `subzone_spans` is used solely for zone config writes. These spans are - // recreated for the table zone config during each configuration change. repeated cockroach.config.zonepb.SubzoneSpan subzone_spans = 5 [(gogoproto.nullable) = false]; // `seq_num` is used to differentiate different subzone config elements tied // to the same partition. E.g. If we attempt to update a partition's subzone diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_zone_config.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_zone_config.go index 3ff821265e01..3db2a4cb017a 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_zone_config.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_zone_config.go @@ -16,7 +16,6 @@ func init() { scpb.Status_ABSENT, to(scpb.Status_PUBLIC, emit(func(this *scpb.IndexZoneConfig) *scop.AddIndexZoneConfig { - return &scop.AddIndexZoneConfig{ TableID: this.TableID, Subzone: this.Subzone,