@@ -155,7 +155,7 @@ func (e *ShowExec) fetchShowPlacementForDB(ctx context.Context) (err error) {
155
155
}
156
156
157
157
if placement != nil {
158
- state , err := fetchDBScheduleState (ctx , nil , dbInfo )
158
+ state , err := e . fetchDBScheduleState (ctx , nil , dbInfo )
159
159
if err != nil {
160
160
return err
161
161
}
@@ -332,7 +332,7 @@ func (e *ShowExec) fetchAllDBPlacements(ctx context.Context, scheduleState map[i
332
332
}
333
333
334
334
if placement != nil {
335
- state , err := fetchDBScheduleState (ctx , scheduleState , dbInfo )
335
+ state , err := e . fetchDBScheduleState (ctx , scheduleState , dbInfo )
336
336
if err != nil {
337
337
return err
338
338
}
@@ -343,6 +343,22 @@ func (e *ShowExec) fetchAllDBPlacements(ctx context.Context, scheduleState map[i
343
343
return nil
344
344
}
345
345
346
+ func (e * ShowExec ) fetchDBScheduleState (ctx context.Context , scheduleState map [int64 ]infosync.PlacementScheduleState , db * model.DBInfo ) (infosync.PlacementScheduleState , error ) {
347
+ state := infosync .PlacementScheduleStateScheduled
348
+ for _ , table := range e .is .SchemaTables (db .Name ) {
349
+ tbl := table .Meta ()
350
+ schedule , err := fetchTableScheduleState (ctx , scheduleState , tbl )
351
+ if err != nil {
352
+ return state , err
353
+ }
354
+ state = accumulateState (state , schedule )
355
+ if state != infosync .PlacementScheduleStateScheduled {
356
+ break
357
+ }
358
+ }
359
+ return state , nil
360
+ }
361
+
346
362
type tableRowSet struct {
347
363
name string
348
364
rows [][]any
@@ -501,21 +517,6 @@ func fetchTableScheduleState(ctx context.Context, scheduleState map[int64]infosy
501
517
return schedule , nil
502
518
}
503
519
504
- func fetchDBScheduleState (ctx context.Context , scheduleState map [int64 ]infosync.PlacementScheduleState , db * model.DBInfo ) (infosync.PlacementScheduleState , error ) {
505
- state := infosync .PlacementScheduleStateScheduled
506
- for _ , table := range db .Tables {
507
- schedule , err := fetchTableScheduleState (ctx , scheduleState , table )
508
- if err != nil {
509
- return state , err
510
- }
511
- state = accumulateState (state , schedule )
512
- if state != infosync .PlacementScheduleStateScheduled {
513
- break
514
- }
515
- }
516
- return state , nil
517
- }
518
-
519
520
func accumulateState (curr , news infosync.PlacementScheduleState ) infosync.PlacementScheduleState {
520
521
a , b := int (curr ), int (news )
521
522
if a > b {
0 commit comments