forked from pingcap/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support update pump or drainer status #1
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -721,6 +721,74 @@ func (n *SetPwdStmt) Accept(v Visitor) (Node, bool) { | |||||
return v.Leave(n) | ||||||
} | ||||||
|
||||||
type ChangePumpStmt struct { | ||||||
stmtNode | ||||||
|
||||||
StateName string | ||||||
State string | ||||||
IpAndPort string | ||||||
} | ||||||
|
||||||
// Restore implements Node interface. | ||||||
func (n *ChangePumpStmt) Restore(ctx *RestoreCtx) error { | ||||||
ctx.WriteKeyWord("CHANGE PUMP TO") | ||||||
ctx.WriteString("PUMP_STATE") | ||||||
ctx.WritePlain("=") | ||||||
ctx.WriteString(n.State) | ||||||
ctx.WriteKeyWord("FOR NodeID") | ||||||
ctx.WriteKeyWord(n.IpAndPort) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return nil | ||||||
} | ||||||
|
||||||
// SecureText implements SensitiveStatement interface. | ||||||
func (n *ChangePumpStmt) SecureText() string { | ||||||
return fmt.Sprintf("change pump to pump_state='paused' for NodeID '%s'", n.IpAndPort) | ||||||
} | ||||||
|
||||||
// Accept implements Node Accept interface. | ||||||
func (n *ChangePumpStmt) Accept(v Visitor) (Node, bool) { | ||||||
newNode, skipChildren := v.Enter(n) | ||||||
if skipChildren { | ||||||
return v.Leave(newNode) | ||||||
} | ||||||
n = newNode.(*ChangePumpStmt) | ||||||
return v.Leave(n) | ||||||
} | ||||||
|
||||||
type ChangeDrainerStmt struct { | ||||||
stmtNode | ||||||
|
||||||
StateName string | ||||||
State string | ||||||
IpAndPort string | ||||||
} | ||||||
|
||||||
// Restore implements Node interface. | ||||||
func (n *ChangeDrainerStmt) Restore(ctx *RestoreCtx) error { | ||||||
ctx.WriteKeyWord("CHANGE DRAINER TO") | ||||||
ctx.WriteString("PUMP_STATE") | ||||||
ctx.WritePlain("=") | ||||||
ctx.WriteString(n.State) | ||||||
ctx.WriteKeyWord("FOR NodeID") | ||||||
ctx.WriteKeyWord(n.IpAndPort) | ||||||
return nil | ||||||
} | ||||||
|
||||||
// SecureText implements SensitiveStatement interface. | ||||||
func (n *ChangeDrainerStmt) SecureText() string { | ||||||
return fmt.Sprintf("change drainer to drainer_state='paused' for NodeID '%s'", n.IpAndPort) | ||||||
} | ||||||
|
||||||
// Accept implements Node Accept interface. | ||||||
func (n *ChangeDrainerStmt) Accept(v Visitor) (Node, bool) { | ||||||
newNode, skipChildren := v.Enter(n) | ||||||
if skipChildren { | ||||||
return v.Leave(newNode) | ||||||
} | ||||||
n = newNode.(*ChangeDrainerStmt) | ||||||
return v.Leave(n) | ||||||
} | ||||||
|
||||||
// UserSpec is used for parsing create user statement. | ||||||
type UserSpec struct { | ||||||
User *auth.UserIdentity | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -112,6 +112,7 @@ import ( | |||||
distinctRow "DISTINCTROW" | ||||||
div "DIV" | ||||||
doubleType "DOUBLE" | ||||||
drainer_state "DRAINER_STATE" | ||||||
drop "DROP" | ||||||
dual "DUAL" | ||||||
elseKwd "ELSE" | ||||||
|
@@ -180,6 +181,7 @@ import ( | |||||
minuteMicrosecond "MINUTE_MICROSECOND" | ||||||
minuteSecond "MINUTE_SECOND" | ||||||
mod "MOD" | ||||||
NodeID "NODEID" | ||||||
not "NOT" | ||||||
noWriteToBinLog "NO_WRITE_TO_BINLOG" | ||||||
nthValue "NTH_VALUE" | ||||||
|
@@ -200,6 +202,7 @@ import ( | |||||
precisionType "PRECISION" | ||||||
primary "PRIMARY" | ||||||
procedure "PROCEDURE" | ||||||
PUMP_STATE "PUMP_STATE" | ||||||
shardRowIDBits "SHARD_ROW_ID_BITS" | ||||||
rangeKwd "RANGE" | ||||||
rank "RANK" | ||||||
|
@@ -621,7 +624,8 @@ import ( | |||||
RevokeStmt "Revoke statement" | ||||||
RevokeRoleStmt "Revoke role statement" | ||||||
RollbackStmt "ROLLBACK statement" | ||||||
SetStmt "Set variable statement" | ||||||
SetStmt "Update Pump or Drainer's status" | ||||||
ChangeStmt "Change statement" | ||||||
SetRoleStmt "Set active role statement" | ||||||
SetDefaultRoleStmt "Set default statement for some user" | ||||||
ShowStmt "Show engines/databases/tables/user/columns/warnings/status statement" | ||||||
|
@@ -5513,6 +5517,22 @@ UnionSelect: | |||||
UnionOpt: | ||||||
DefaultTrueDistinctOpt | ||||||
|
||||||
/********************Change Statement*******************************/ | ||||||
ChangeStmt: | ||||||
| "CHANGE" "PUMP" to "PUMP_STATE" eq stringLit forKwd "NODEID" stringLit | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
$$ = &ast.ChangePumpStmt{ | ||||||
State: $6.(string), | ||||||
IpAndPort: $9.(string), | ||||||
} | ||||||
} | ||||||
| "CHANGE" "DRAINER" to "DRAINER_STATE" eq stringLit forKwd "NODEID" stringLit | ||||||
{ | ||||||
$$ = &ast.ChangeDrainerStmt{ | ||||||
State: $6.(string), | ||||||
IpAndPort: $9.(string), | ||||||
} | ||||||
} | ||||||
|
||||||
/********************Set Statement*******************************/ | ||||||
SetStmt: | ||||||
|
@@ -6472,6 +6492,7 @@ Statement: | |||||
| DeleteFromStmt | ||||||
| ExecuteStmt | ||||||
| ExplainStmt | ||||||
| ChangeStmt | ||||||
| CreateDatabaseStmt | ||||||
| CreateIndexStmt | ||||||
| CreateTableStmt | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the
WriteKeyWord
above unless you want the syntax to beCHANGE PUMP TO 'PUMP_STATE' = 'stuff' ...