Skip to content

Commit

Permalink
Merge branch 'master' into derive_not_null
Browse files Browse the repository at this point in the history
  • Loading branch information
eurekaka authored Dec 28, 2018
2 parents d61a4ef + e730186 commit fe56bb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,24 @@ func (e *ShowExec) fetchShowTables() error {
}
// sort for tables
var tableNames []string
var tableTypes = make(map[string]string)
for _, v := range e.is.SchemaTables(e.DBName) {
// Test with mysql.AllPrivMask means any privilege would be OK.
// TODO: Should consider column privileges, which also make a table visible.
if checker != nil && !checker.RequestVerification(e.DBName.O, v.Meta().Name.O, "", mysql.AllPrivMask) {
continue
}
tableNames = append(tableNames, v.Meta().Name.O)
if v.Meta().IsView() {
tableTypes[v.Meta().Name.O] = "VIEW"
} else {
tableTypes[v.Meta().Name.O] = "BASE TABLE"
}
}
sort.Strings(tableNames)
for _, v := range tableNames {
if e.Full {
// TODO: support "VIEW" later if we have supported view feature.
// now, just use "BASE TABLE".
e.appendRow([]interface{}{v, "BASE TABLE"})
e.appendRow([]interface{}{v, tableTypes[v]})
} else {
e.appendRow([]interface{}{v})
}
Expand Down
5 changes: 3 additions & 2 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ func (s *testSuite2) TestShow2(c *C) {

tk.MustExec("drop table if exists t")
tk.MustExec(`create table if not exists t (c int) comment '注释'`)
tk.MustExec("create or replace view v as select * from t")
tk.MustQuery(`show columns from t`).Check(testutil.RowsWithSep(",", "c,int(11),YES,,<nil>,"))
tk.MustQuery("show collation where Charset = 'utf8' and Collation = 'utf8_bin'").Check(testutil.RowsWithSep(",", "utf8_bin,utf8,83,,Yes,1"))

tk.MustQuery("show tables").Check(testkit.Rows("t"))
tk.MustQuery("show full tables").Check(testkit.Rows("t BASE TABLE"))
tk.MustQuery("show tables").Check(testkit.Rows("t", "v"))
tk.MustQuery("show full tables").Check(testkit.Rows("t BASE TABLE", "v VIEW"))
ctx := tk.Se.(sessionctx.Context)
is := domain.GetDomain(ctx).InfoSchema()
tblInfo, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t"))
Expand Down

0 comments on commit fe56bb4

Please sign in to comment.