@@ -44,8 +44,6 @@ type setZoneConfigNode struct {
4444 yamlConfig tree.TypedExpr
4545 options map [tree.Name ]zone.OptionValue
4646 setDefault bool
47-
48- run setZoneConfigRun
4947}
5048
5149func (p * planner ) getUpdatedZoneConfigYamlConfig (
@@ -230,11 +228,6 @@ func checkPrivilegeForSetZoneConfig(ctx context.Context, p *planner, zs tree.Zon
230228 []privilege.Kind {privilege .ZONECONFIG , privilege .CREATE }, string (tableDesc .DescriptorType ()), tableDesc .GetName ())
231229}
232230
233- // setZoneConfigRun contains the run-time state of setZoneConfigNode during local execution.
234- type setZoneConfigRun struct {
235- numAffected int
236- }
237-
238231// ReadingOwnWrites implements the planNodeReadingOwnWrites interface.
239232// This is because CONFIGURE ZONE performs multiple KV operations on descriptors
240233// and expects to see its own writes.
@@ -747,7 +740,7 @@ func (n *setZoneConfigNode) startExec(params runParams) error {
747740 zoneToWrite := partialZone
748741 // TODO(ajwerner): This is extremely fragile because we accept a nil table
749742 // all the way down here.
750- n . run . numAffected , err = writeZoneConfig (
743+ err = writeZoneConfig (
751744 params .ctx ,
752745 params .p .InternalSQLTxn (),
753746 targetID ,
@@ -796,8 +789,6 @@ func (n *setZoneConfigNode) Next(runParams) (bool, error) { return false, nil }
796789func (n * setZoneConfigNode ) Values () tree.Datums { return nil }
797790func (* setZoneConfigNode ) Close (context.Context ) {}
798791
799- func (n * setZoneConfigNode ) FastPathResults () (int , bool ) { return n .run .numAffected , true }
800-
801792type nodeGetter func (context.Context , * serverpb.NodesRequest ) (* serverpb.NodesResponse , error )
802793type regionsGetter func (context.Context ) (* serverpb.RegionsResponse , error )
803794
@@ -1058,41 +1049,38 @@ func writeZoneConfig(
10581049 execCfg * ExecutorConfig ,
10591050 hasNewSubzones bool ,
10601051 kvTrace bool ,
1061- ) ( numAffected int , err error ) {
1052+ ) error {
10621053 update , err := prepareZoneConfigWrites (ctx , execCfg , targetID , table , zone , expectedExistingRawBytes , hasNewSubzones )
10631054 if err != nil {
1064- return 0 , err
1055+ return err
10651056 }
10661057 return writeZoneConfigUpdate (ctx , txn , kvTrace , update )
10671058}
10681059
10691060func writeZoneConfigUpdate (
10701061 ctx context.Context , txn descs.Txn , kvTrace bool , update * zoneConfigUpdate ,
1071- ) ( numAffected int , err error ) {
1062+ ) error {
10721063 b := txn .KV ().NewBatch ()
10731064 if update .zoneConfig == nil {
1074- err = txn .Descriptors ().DeleteZoneConfigInBatch (ctx , kvTrace , b , update .id )
1065+ err := txn .Descriptors ().DeleteZoneConfigInBatch (ctx , kvTrace , b , update .id )
1066+ if err != nil {
1067+ return err
1068+ }
10751069 } else {
1076- numAffected = 1
1077- err = txn .Descriptors ().WriteZoneConfigToBatch (ctx , kvTrace , b , update .id , update .zoneConfig )
1078- }
1079- if err != nil {
1080- return 0 , err
1070+ err := txn .Descriptors ().WriteZoneConfigToBatch (ctx , kvTrace , b , update .id , update .zoneConfig )
1071+ if err != nil {
1072+ return err
1073+ }
10811074 }
10821075
10831076 if err := txn .KV ().Run (ctx , b ); err != nil {
1084- return 0 , err
1077+ return err
10851078 }
10861079 r := b .Results [0 ]
10871080 if r .Err != nil {
10881081 panic ("run succeeded even through the result has an error" )
10891082 }
1090- // We don't really care how many keys are affected since this function always
1091- // write one single zone config.
1092- if len (r .Keys ) > 0 {
1093- numAffected = 1
1094- }
1095- return numAffected , err
1083+ return nil
10961084}
10971085
10981086// RemoveIndexZoneConfigs removes the zone configurations for some
@@ -1139,7 +1127,7 @@ func RemoveIndexZoneConfigs(
11391127
11401128 if zcRewriteNecessary {
11411129 // Ignore CCL required error to allow schema change to progress.
1142- _ , err = writeZoneConfig (
1130+ err = writeZoneConfig (
11431131 ctx , txn , tableDesc .GetID (), tableDesc , zone ,
11441132 zoneWithRaw .GetRawBytesInStorage (), execCfg ,
11451133 false /* hasNewSubzones */ , kvTrace ,
0 commit comments