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

executor: fix show table status for the database with upper-cased name #23896

Merged
merged 15 commits into from
Apr 12, 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
2 changes: 1 addition & 1 deletion executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (e *ShowExec) fetchShowTableStatus() error {
data_free, auto_increment, create_time, update_time, check_time,
table_collation, IFNULL(checksum,''), create_options, table_comment
FROM information_schema.tables
WHERE table_schema=%? ORDER BY table_name`, e.DBName.L)
WHERE lower(table_schema)=%? ORDER BY table_name`, e.DBName.L)
if err != nil {
return errors.Trace(err)
}
Expand Down
36 changes: 30 additions & 6 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"strings"

. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/model"
Expand Down Expand Up @@ -492,12 +491,13 @@ func (s *testSuite5) TestShowTableStatus(c *C) {
// It's not easy to test the result contents because every time the test runs, "Create_time" changed.
tk.MustExec("show table status;")
rs, err := tk.Exec("show table status;")
c.Assert(errors.ErrorStack(err), Equals, "")
c.Assert(err, IsNil)
c.Assert(rs, NotNil)
rows, err := session.GetRows4Test(context.Background(), tk.Se, rs)
c.Assert(errors.ErrorStack(err), Equals, "")
c.Assert(err, IsNil)
err = rs.Close()
c.Assert(errors.ErrorStack(err), Equals, "")
c.Assert(err, IsNil)
c.Assert(len(rows), Equals, 1)

for i := range rows {
row := rows[i]
Expand All @@ -514,10 +514,34 @@ func (s *testSuite5) TestShowTableStatus(c *C) {
partition p2 values less than (maxvalue)
);`)
rs, err = tk.Exec("show table status from test like 'tp';")
c.Assert(errors.ErrorStack(err), Equals, "")
c.Assert(err, IsNil)
rows, err = session.GetRows4Test(context.Background(), tk.Se, rs)
c.Assert(errors.ErrorStack(err), Equals, "")
c.Assert(err, IsNil)
c.Assert(rows[0].GetString(16), Equals, "partitioned")

tk.MustExec("create database UPPER_CASE")
tk.MustExec("use UPPER_CASE")
tk.MustExec("create table t (i int)")
rs, err = tk.Exec("show table status")
c.Assert(err, IsNil)
c.Assert(rs, NotNil)
rows, err = session.GetRows4Test(context.Background(), tk.Se, rs)
c.Assert(err, IsNil)
err = rs.Close()
c.Assert(err, IsNil)
c.Assert(len(rows), Equals, 1)

tk.MustExec("use upper_case")
rs, err = tk.Exec("show table status")
c.Assert(err, IsNil)
c.Assert(rs, NotNil)
rows, err = session.GetRows4Test(context.Background(), tk.Se, rs)
c.Assert(err, IsNil)
err = rs.Close()
c.Assert(err, IsNil)
c.Assert(len(rows), Equals, 1)

tk.MustExec("drop database UPPER_CASE")
}

func (s *testSuite5) TestShowSlow(c *C) {
Expand Down