Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/vt/sqlparser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func ASTToStatementType(stmt Statement) StatementType {
return StmtSRollback
case *Release:
return StmtRelease
case *ShowTableStatus:
return StmtShow
default:
return StmtUnknown
}
Expand Down
17 changes: 17 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ type (
ShowCollationFilterOpt Expr
}

// ShowTableStatus is a struct for SHOW TABLE STATUS queries.
ShowTableStatus struct {
DatabaseName string
Filter *ShowFilter
}

// Use represents a use statement.
Use struct {
DBName TableIdent
Expand Down Expand Up @@ -333,6 +339,7 @@ func (*OtherAdmin) iStatement() {}
func (*Select) iSelectStatement() {}
func (*Union) iSelectStatement() {}
func (*ParenSelect) iSelectStatement() {}
func (*ShowTableStatus) iStatement() {}

// ParenSelect can actually not be a top level statement,
// but we have to allow it because it's a requirement
Expand Down Expand Up @@ -2056,3 +2063,13 @@ func (node AccessMode) Format(buf *TrackedBuffer) {
buf.WriteString(TxReadWrite)
}
}

// Format formats the node.
func (node *ShowTableStatus) Format(buf *TrackedBuffer) {
buf.WriteString("show table status")
if node.DatabaseName != "" {
buf.WriteString(" from ")
buf.WriteString(node.DatabaseName)
}
buf.astPrintf(node, "%v", node.Filter)
}
7 changes: 7 additions & 0 deletions go/vt/sqlparser/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,10 @@ func TestDefaultStatus(t *testing.T) {
String(&Default{ColName: "status"}),
"default(`status`)")
}

func TestShowTableStatus(t *testing.T) {
query := "Show Table Status FROM customer"
tree, err := Parse(query)
require.NoError(t, err)
require.NotNil(t, tree)
}
14 changes: 12 additions & 2 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,8 +1330,18 @@ var (
input: "show session status",
output: "show session status",
}, {
input: "show table status",
output: "show table",
input: "show table status",
}, {
input: "show table status from dbname",
}, {
input: "show table status in dbname",
output: "show table status from dbname",
}, {
input: "show table status in dbname LIKE '%' ",
output: "show table status from dbname like '%'",
}, {
input: "show table status from dbname Where col=42 ",
output: "show table status from dbname where col = 42",
}, {
input: "show tables",
}, {
Expand Down
7 changes: 7 additions & 0 deletions go/vt/sqlparser/rewriter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading