@@ -2469,6 +2469,7 @@ const (
2469
2469
AdminSetBDRRole
2470
2470
AdminShowBDRRole
2471
2471
AdminUnsetBDRRole
2472
+ AdminAlterDDLJob
2472
2473
)
2473
2474
2474
2475
// HandleRange represents a range where handle value >= Begin and < End.
@@ -2557,6 +2558,25 @@ type LimitSimple struct {
2557
2558
Offset uint64
2558
2559
}
2559
2560
2561
+ type AlterJobOption struct {
2562
+ // Name is the name of the option, will be converted to lower case during parse.
2563
+ Name string
2564
+ // only literal is allowed, we use ExprNode to support negative number
2565
+ Value ExprNode
2566
+ }
2567
+
2568
+ func (l * AlterJobOption ) Restore (ctx * format.RestoreCtx ) error {
2569
+ if l .Value == nil {
2570
+ ctx .WritePlain (l .Name )
2571
+ } else {
2572
+ ctx .WritePlain (l .Name + " = " )
2573
+ if err := l .Value .Restore (ctx ); err != nil {
2574
+ return errors .Annotatef (err , "An error occurred while restore AlterJobOption" )
2575
+ }
2576
+ }
2577
+ return nil
2578
+ }
2579
+
2560
2580
// AdminStmt is the struct for Admin statement.
2561
2581
type AdminStmt struct {
2562
2582
stmtNode
@@ -2567,13 +2587,14 @@ type AdminStmt struct {
2567
2587
JobIDs []int64
2568
2588
JobNumber int64
2569
2589
2570
- HandleRanges []HandleRange
2571
- ShowSlow * ShowSlow
2572
- Plugins []string
2573
- Where ExprNode
2574
- StatementScope StatementScope
2575
- LimitSimple LimitSimple
2576
- BDRRole BDRRole
2590
+ HandleRanges []HandleRange
2591
+ ShowSlow * ShowSlow
2592
+ Plugins []string
2593
+ Where ExprNode
2594
+ StatementScope StatementScope
2595
+ LimitSimple LimitSimple
2596
+ BDRRole BDRRole
2597
+ AlterJobOptions []* AlterJobOption
2577
2598
}
2578
2599
2579
2600
// Restore implements Node interface.
@@ -2737,6 +2758,18 @@ func (n *AdminStmt) Restore(ctx *format.RestoreCtx) error {
2737
2758
ctx .WriteKeyWord ("SHOW BDR ROLE" )
2738
2759
case AdminUnsetBDRRole :
2739
2760
ctx .WriteKeyWord ("UNSET BDR ROLE" )
2761
+ case AdminAlterDDLJob :
2762
+ ctx .WriteKeyWord ("ALTER DDL JOBS " )
2763
+ ctx .WritePlainf ("%d" , n .JobNumber )
2764
+ for i , option := range n .AlterJobOptions {
2765
+ if i != 0 {
2766
+ ctx .WritePlain ("," )
2767
+ }
2768
+ ctx .WritePlain (" " )
2769
+ if err := option .Restore (ctx ); err != nil {
2770
+ return errors .Annotatef (err , "An error occurred while restore AdminStmt.AlterJobOptions[%d]" , i )
2771
+ }
2772
+ }
2740
2773
default :
2741
2774
return errors .New ("Unsupported AdminStmt type" )
2742
2775
}
0 commit comments