Merge pull request #274 from pingcap/shenli/fix-issue-263

tidb-server: Fix issue 263
This commit is contained in:
goroutine
2015-09-25 13:33:16 +08:00
3 changed files with 20 additions and 1 deletions

View File

@ -107,7 +107,10 @@ func (cc *clientConn) Close() error {
delete(cc.server.clients, cc.connectionID)
cc.server.rwlock.Unlock()
cc.conn.Close()
return cc.ctx.Close()
if cc.ctx != nil {
return cc.ctx.Close()
}
return nil
}
func (cc *clientConn) writeInitialHandshake() error {

View File

@ -236,3 +236,15 @@ func runTestAuth(c *C) {
c.Assert(err, NotNil, Commentf("Wrong password should be failed"))
db.Close()
}
func runTestIssues(c *C) {
// For issue #263
unExistsSchemaDsn := "root@tcp(localhost:4001)/unexists_schema?strict=true"
db, err := sql.Open("mysql", unExistsSchemaDsn)
c.Assert(db, NotNil)
c.Assert(err, IsNil)
// Open may just validate its arguments without creating a connection to the database. To verify that the data source name is valid, call Ping.
err = db.Ping()
c.Assert(err, NotNil, Commentf("Connecting to an unexists schema should be error"))
db.Close()
}

View File

@ -71,3 +71,7 @@ func (ts *TidbTestSuite) TestConcurrentUpdate(c *C) {
func (ts *TidbTestSuite) TestAuth(c *C) {
runTestAuth(c)
}
func (ts *TidbTestSuite) TestIssues(c *C) {
runTestIssues(c)
}