Skip to content

Commit

Permalink
Merge pull request #285 from pingcap/siddontang/cleanup-show
Browse files Browse the repository at this point in the history
cleanup show
  • Loading branch information
siddontang committed Sep 28, 2015
2 parents 0dbdd9f + 358c9d0 commit 99dc1d9
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 211 deletions.
49 changes: 17 additions & 32 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ import (
SetStmt "Set variable statement"
ShowStmt "Show engines/databases/tables/columns/warnings statement"
ShowDatabaseNameOpt "Show tables/columns statement database name option"
ShowLikeOrWhereOpt "Show like or where condition option"
ShowTableIdentOpt "Show columns statement table name option"
SignedLiteral "Literal or NumLiteral with sign"
SimpleQualifiedIdent "Qualified identifier without *"
Expand Down Expand Up @@ -3172,51 +3173,35 @@ ShowStmt:
{
$$ = &stmts.ShowStmt{Target: stmt.ShowWarnings}
}
// See: https://dev.mysql.com/doc/refman/5.7/en/show-variables.html
// TODO: Support show variables with where clause.
| "SHOW" GlobalScope "VARIABLES"
| "SHOW" GlobalScope "VARIABLES" ShowLikeOrWhereOpt
{
$$ = &stmts.ShowStmt{
Target: stmt.ShowVariables,
GlobalScope: $2.(bool),
}

}
| "SHOW" GlobalScope "VARIABLES" "LIKE" PrimaryExpression
{
$$ = &stmts.ShowStmt{
stmt := &stmts.ShowStmt{
Target: stmt.ShowVariables,
GlobalScope: $2.(bool),
Pattern: &expression.PatternLike{Pattern: $5.(expression.Expression)},
}
stmt.SetCondition($4)
$$ = stmt
}
| "SHOW" GlobalScope "VARIABLES" "WHERE" Expression
| "SHOW" "COLLATION" ShowLikeOrWhereOpt
{
$$ = &stmts.ShowStmt{
Target: stmt.ShowVariables,
GlobalScope: $2.(bool),
Where: expression.Expr($5),
stmt := &stmts.ShowStmt{
Target: stmt.ShowCollation,
}
stmt.SetCondition($3)
$$ = stmt
}
| "SHOW" "COLLATION"

ShowLikeOrWhereOpt:
{
$$ = &stmts.ShowStmt{
Target: stmt.ShowCollation,
}
$$ = nil
}
| "SHOW" "COLLATION" "LIKE" PrimaryExpression
| "LIKE" PrimaryExpression
{
$$ = &stmts.ShowStmt{
Target: stmt.ShowCollation,
Pattern: &expression.PatternLike{Pattern: $4.(expression.Expression)},
}
$$ = &expression.PatternLike{Pattern: $2.(expression.Expression)}
}
| "SHOW" "COLLATION" "WHERE" Expression
| "WHERE" Expression
{
$$ = &stmts.ShowStmt{
Target: stmt.ShowCollation,
Where: expression.Expr($4),
}
$$ = expression.Expr($2)
}

GlobalScope:
Expand Down
Loading

0 comments on commit 99dc1d9

Please sign in to comment.