Skip to content

Commit

Permalink
*: Support show procedure status syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
shenli committed Dec 21, 2015
1 parent e281b35 commit 2fe9938
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const (
ShowCreateTable
ShowGrants
ShowTriggers
ShowProcedureStatus
)

// ShowStmt is a statement to provide information about databases, tables, columns and so on.
Expand Down
2 changes: 2 additions & 0 deletions executor/converter/convert_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ func convertShow(converter *expressionConverter, v *ast.ShowStmt) (*stmts.ShowSt
oldShow.Target = stmt.ShowTableStatus
case ast.ShowTriggers:
oldShow.Target = stmt.ShowTriggers
case ast.ShowProcedureStatus:
oldShow.Target = stmt.ShowProcedureStatus
case ast.ShowNone:
oldShow.Target = stmt.ShowNone
}
Expand Down
7 changes: 7 additions & 0 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ import (
placeholder "PLACEHOLDER"
prepare "PREPARE"
primary "PRIMARY"
procedure "PROCEDURE"
quarter "QUARTER"
quick "QUICK"
rand "RAND"
Expand Down Expand Up @@ -3456,6 +3457,12 @@ ShowTargetFilterable:
DBName: $2.(string),
}
}
| "PROCEDURE" "STATUS"
{
$$ = &ast.ShowStmt {
Tp: ast.ShowProcedureStatus,
}
}

ShowLikeOrWhereOpt:
{
Expand Down
3 changes: 2 additions & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ func (s *testParserSuite) TestDMLStmt(c *C) {
{`SHOW COLUMNS FROM City;`, true},
{`SHOW FIELDS FROM City;`, true},
{`SHOW TRIGGERS LIKE 't'`, true},
{"SHOW DATABASES LIKE 'test2'", true},
{`SHOW DATABASES LIKE 'test2'`, true},
{`SHOW PROCEDURE STATUS WHERE Db='test'`, true},

// For default value
{"CREATE TABLE sbtest (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, k integer UNSIGNED DEFAULT '0' NOT NULL, c char(120) DEFAULT '' NOT NULL, pad char(60) DEFAULT '' NOT NULL, PRIMARY KEY (id) )", true},
Expand Down
2 changes: 2 additions & 0 deletions parser/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ outer {o}{u}{t}{e}{r}
password {p}{a}{s}{s}{w}{o}{r}{d}
prepare {p}{r}{e}{p}{a}{r}{e}
primary {p}{r}{i}{m}{a}{r}{y}
procedure {p}{r}{o}{c}{e}{d}{u}{r}{e}
quarter {q}{u}{a}{r}{t}{e}{r}
quick {q}{u}{i}{c}{k}
rand {r}{a}{n}{d}
Expand Down Expand Up @@ -859,6 +860,7 @@ year_month {y}{e}{a}{r}_{m}{o}{n}{t}{h}
{prepare} lval.item = string(l.val)
return prepare
{primary} return primary
{procedure} return procedure
{quarter} lval.item = string(l.val)
return quarter
{quick} lval.item = string(l.val)
Expand Down
10 changes: 10 additions & 0 deletions plan/plans/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (s *ShowPlan) GetFields() []*field.ResultField {
"sql_mode", "Definer", "character_set_client", "collation_connection", "Database Collation"}
types = []byte{mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar,
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar}
case stmt.ShowProcedureStatus:
names = []string{}
types = []byte{}
}
fields := make([]*field.ResultField, 0, len(names))
for i, name := range names {
Expand Down Expand Up @@ -193,6 +196,8 @@ func (s *ShowPlan) fetchAll(ctx context.Context) error {
return s.fetchShowGrants(ctx)
case stmt.ShowTriggers:
return s.fetchShowTriggers(ctx)
case stmt.ShowProcedureStatus:
return s.fetchShowProcedureStatus(ctx)
}
return nil
}
Expand Down Expand Up @@ -660,3 +665,8 @@ func (s *ShowPlan) fetchShowGrants(ctx context.Context) error {
func (s *ShowPlan) fetchShowTriggers(ctx context.Context) error {
return nil
}

// Do nothing.
func (s *ShowPlan) fetchShowProcedureStatus(ctx context.Context) error {
return nil
}
1 change: 1 addition & 0 deletions stmt/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
ShowCreateTable
ShowGrants
ShowTriggers
ShowProcedureStatus
)

const (
Expand Down

0 comments on commit 2fe9938

Please sign in to comment.