From 49ae9493e32041402173b0dc36d6ea9ec954f984 Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 28 Sep 2015 10:49:31 +0800 Subject: [PATCH] stmts: ShowStmt uses SetCondition to binds like or where --- stmt/stmts/show.go | 10 ++++++++++ stmt/stmts/show_test.go | 1 + 2 files changed, 11 insertions(+) diff --git a/stmt/stmts/show.go b/stmt/stmts/show.go index f0ec8d71a1001..62f9d8eedebb8 100644 --- a/stmt/stmts/show.go +++ b/stmt/stmts/show.go @@ -93,3 +93,13 @@ func (s *ShowStmt) getDBName(ctx context.Context) string { // if s.DBName is empty, we should use current db name if possible. return db.GetCurrentSchema(ctx) } + +// SetCondition binds like or where expression. +func (s *ShowStmt) SetCondition(expr interface{}) { + switch x := expr.(type) { + case *expression.PatternLike: + s.Pattern = x + case expression.Expression: + s.Where = x + } +} diff --git a/stmt/stmts/show_test.go b/stmt/stmts/show_test.go index 24ca40d37e865..d3feeb85e66d4 100644 --- a/stmt/stmts/show_test.go +++ b/stmt/stmts/show_test.go @@ -44,4 +44,5 @@ func (s *testStmtSuite) TestShow(c *C) { c.Assert(stmtList, HasLen, 1) testStmt, ok = stmtList[0].(*stmts.ShowStmt) c.Assert(ok, IsTrue) + c.Assert(testStmt.Pattern, NotNil) }