Skip to content

Commit

Permalink
cherry pick #23896 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
jackysp authored and ti-srebot committed Apr 12, 2021
1 parent 11a9254 commit 38ac074
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,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 @@ -491,12 +490,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 @@ -513,10 +513,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

0 comments on commit 38ac074

Please sign in to comment.