*: Address comments

This commit is contained in:
Shen Li
2015-09-20 22:59:43 +08:00
parent 1400803273
commit 113cbf2cdc
3 changed files with 6 additions and 5 deletions

View File

@ -222,7 +222,7 @@ func (tc *TableConstraint) String() string {
return strings.Join(tokens, " ")
}
// AuthOption is used for parsing create use statement
// AuthOption is used for parsing create use statement.
type AuthOption struct {
// AuthString/HashString can be empty, so we need to decide which one to use.
ByAuthString bool
@ -231,7 +231,7 @@ type AuthOption struct {
// TODO: support auth_plugin
}
// UserSpecification is used for parsing create use statement
// UserSpecification is used for parsing create use statement.
type UserSpecification struct {
User string
AuthOpt *AuthOption

View File

@ -18,6 +18,8 @@
package stmts
import (
"strings"
"github.com/juju/errors"
"github.com/pingcap/tidb/context"
"github.com/pingcap/tidb/expression"
@ -31,7 +33,6 @@ import (
"github.com/pingcap/tidb/stmt"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/util/format"
"strings"
)
/************************************************************************************
@ -93,6 +94,7 @@ func (s *CreateUserStmt) userExists(ctx context.Context, name string, host strin
r := composeUserTableRset()
p, err := r.Plan(ctx)
if err != nil {
p.Close()
return false, errors.Trace(err)
}
where := &rsets.WhereRset{
@ -100,6 +102,7 @@ func (s *CreateUserStmt) userExists(ctx context.Context, name string, host strin
Expr: composeUserTableFilter(name, host),
}
p, err = where.Plan(ctx)
defer p.Close()
if err != nil {
return false, errors.Trace(err)
}
@ -107,7 +110,6 @@ func (s *CreateUserStmt) userExists(ctx context.Context, name string, host strin
if err != nil {
return false, errors.Trace(err)
}
p.Close()
return row != nil, nil
}

View File

@ -22,7 +22,6 @@ func (s *testStmtSuite) TestCreateUserStmt(c *C) {
tx := mustBegin(c, s.testDB)
rows, err := tx.Query(`SELECT Password FROM mysql.User WHERE User="test" and Host="localhost"`)
c.Assert(err, IsNil)
rows.Next()
c.Assert(rows.Next(), IsFalse)
rows.Close()
mustCommit(c, tx)