Skip to content
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

Add SHOW INDEXES and EXTENDED #6006

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,10 +1165,10 @@ func (f *ForeignKeyDefinition) Format(buf *TrackedBuffer) {
// Format formats the node.
func (node *Show) Format(buf *TrackedBuffer) {
nodeType := strings.ToLower(node.Type)
if (nodeType == "tables" || nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys") && node.ShowTablesOpt != nil {
if (nodeType == "tables" || nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys" || nodeType == "indexes") && node.ShowTablesOpt != nil {
opt := node.ShowTablesOpt
buf.astPrintf(node, "show %s%s", opt.Full, nodeType)
if (nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys") && node.HasOnTable() {
if (nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys" || nodeType == "indexes") && node.HasOnTable() {
buf.astPrintf(node, " from %v", node.OnTable)
}
if opt.DbName != "" {
Expand Down
20 changes: 17 additions & 3 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,8 +1232,7 @@ var (
}, {
input: "show index from t",
}, {
input: "show indexes from table",
output: "show indexes",
input: "show indexes from t",
}, {
input: "show keys from t",
}, {
Expand Down Expand Up @@ -1564,8 +1563,23 @@ var (
input: "SHOW FULL TABLES FROM `jiradb` LIKE '%'",
output: "show full tables from jiradb like '%'",
}, {
input: "SHOW INDEX FROM `AO_E8B6CC_PROJECT_MAPPING` FROM `jiradb`",
input: "SHOW EXTENDED INDEX FROM `AO_E8B6CC_PROJECT_MAPPING` FROM `jiradb`",
output: "show index from AO_E8B6CC_PROJECT_MAPPING from jiradb",
}, {
input: "SHOW EXTENDED KEYS FROM `AO_E8B6CC_ISSUE_MAPPING` FROM `jiradb`",
output: "show keys from AO_E8B6CC_ISSUE_MAPPING from jiradb",
saifalharthi marked this conversation as resolved.
Show resolved Hide resolved
}, {
input: "SHOW CREATE TABLE `jiradb`.`AO_E8B6CC_ISSUE_MAPPING`",
output: "show create table jiradb.AO_E8B6CC_ISSUE_MAPPING",
}, {
input: "SHOW INDEXES FROM `AO_E8B6CC_ISSUE_MAPPING` FROM `jiradb`",
output: "show indexes from AO_E8B6CC_ISSUE_MAPPING from jiradb",
}, {
input: "SHOW FULL TABLES FROM `jiradb` LIKE '%'",
output: "show full tables from jiradb like '%'",
}, {
input: "SHOW EXTENDED INDEXES FROM `AO_E8B6CC_PROJECT_MAPPING` FROM `jiradb`",
output: "show indexes from AO_E8B6CC_PROJECT_MAPPING from jiradb",
}}
)

Expand Down
Loading