Skip to content

Commit

Permalink
properly parse 'show [replica|slave] status'
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Jan 27, 2025
1 parent 804feab commit b7b04ff
Show file tree
Hide file tree
Showing 7 changed files with 9,234 additions and 9,145 deletions.
4 changes: 4 additions & 0 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,10 @@ func (ty ShowCommandType) ToString() string {
return WarningsStr
case Keyspace:
return KeyspaceStr
case ReplicaStatus:
return ReplicaStatusStr
case SlaveStatus:
return SlaveStatusStr
default:
return "" +
"Unknown ShowCommandType"
Expand Down
4 changes: 4 additions & 0 deletions go/vt/sqlparser/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ const (
PrivilegeStr = " privileges"
ProcedureCStr = " procedure code"
ProcedureStr = " procedure status"
SlaveStatusStr = " slave status"
StatusGlobalStr = " global status"
StatusSessionStr = " status"
ReplicaStatusStr = " replica status"
TablesStr = " tables"
TableStatusStr = " table status"
TriggerStr = " triggers"
Expand Down Expand Up @@ -880,6 +882,8 @@ const (
VschemaVindexes
Warnings
Keyspace
ReplicaStatus
SlaveStatus
)

// DropKeyType constants
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ var keywords = []keyword{
{"repeat", UNUSED},
{"repeatable", REPEATABLE},
{"replace", REPLACE},
{"replica", REPLICA},
{"require", UNUSED},
{"resignal", UNUSED},
{"respect", RESPECT},
Expand Down Expand Up @@ -589,6 +590,7 @@ var keywords = []keyword{
{"simple", SIMPLE},
{"skip", SKIP},
{"slow", SLOW},
{"slave", SLAVE},
{"smallint", SMALLINT},
{"snapshot", SNAPSHOT},
{"some", SOME},
Expand Down
8 changes: 8 additions & 0 deletions go/vt/sqlparser/normalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ func TestNormalize(t *testing.T) {
"bv1": sqltypes.Int64BindVariable(1),
"bv2": sqltypes.Int64BindVariable(0),
},
}, {
in: "show slave status",
outstmt: "show slave status",
outbv: map[string]*querypb.BindVariable{},
}, {
in: "show replica status",
outstmt: "show replica status",
outbv: map[string]*querypb.BindVariable{},
}}
parser := NewTestParser()
for _, tc := range testcases {
Expand Down
5 changes: 4 additions & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,10 @@ var (
output: "show slave",
}, {
input: "show slave status",
output: "show slave",
output: "show slave status",
}, {
input: "show replica status",
output: "show replica status",
}, {
input: "show status",
output: "show status",
Expand Down
Loading

0 comments on commit b7b04ff

Please sign in to comment.