Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: return OK when there is no stmt #22738

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,10 @@ func (cc *clientConn) handleQuery(ctx context.Context, sql string) (err error) {
return err
}

if len(stmts) == 0 {
return cc.writeOK(ctx)
}

var appendMultiStmtWarning bool

if len(stmts) > 1 {
Expand Down
16 changes: 16 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,22 @@ func (cli *testServerClient) runTestIssue3680(c *C) {
c.Assert(err.Error(), Equals, "Error 1045: Access denied for user 'non_existing_user'@'127.0.0.1' (using password: NO)")
}

func (cli *testServerClient) runTestIssue22646(c *C) {
cli.runTests(c, nil, func(dbt *DBTest) {
c1 := make(chan string, 1)
go func() {
dbt.mustExec(``) // empty query.
c1 <- "success"
}()
select {
case res := <-c1:
fmt.Println(res)
case <-time.After(30 * time.Second):
panic("read empty query statement timed out.")
}
})
}

func (cli *testServerClient) runTestIssue3682(c *C) {
cli.runTests(c, nil, func(dbt *DBTest) {
dbt.mustExec(`CREATE USER 'issue3682'@'%' IDENTIFIED BY '123';`)
Expand Down
1 change: 1 addition & 0 deletions server/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func (ts *tidbTestSuite) TestIssues(c *C) {
c.Parallel()
ts.runTestIssue3662(c)
ts.runTestIssue3680(c)
ts.runTestIssue22646(c)
}

func (ts *tidbTestSuite) TestDBNameEscape(c *C) {
Expand Down