Skip to content

Commit

Permalink
executor: drop partition information in 'show create table' (#7388)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and coocood committed Aug 17, 2018
1 parent 71252f7 commit 1fb887f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
20 changes: 3 additions & 17 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,23 +589,9 @@ func (e *ShowExec) fetchShowCreateTable() error {
buf.WriteString(fmt.Sprintf(" DEFAULT CHARSET=%s COLLATE=%s", charsetName, collate))
}

// add partition info here.
partitionInfo := tb.Meta().Partition
if partitionInfo != nil {
buf.WriteString(fmt.Sprintf("\nPARTITION BY %s ( %s ) (\n", partitionInfo.Type.String(), partitionInfo.Expr))
for i, def := range partitionInfo.Definitions {
if i < len(partitionInfo.Definitions)-1 {
buf.WriteString(fmt.Sprintf(" PARTITION %s VALUES LESS THAN %s,\n", def.Name, def.LessThan[0]))
} else {
if def.MaxValue {
buf.WriteString(fmt.Sprintf(" PARTITION %s VALUES LESS THAN %s\n", def.Name, "MAXVALUE"))
} else {
buf.WriteString(fmt.Sprintf(" PARTITION %s VALUES LESS THAN %s\n", def.Name, def.LessThan[0]))
}
}
}
buf.WriteString(")")
}
// Partition info is truncated in release-2.0 branch.
// create table t (id int) partition by ... will become
// create table t (id int)

if hasAutoIncID {
autoIncID, err := tb.Allocator(e.ctx).NextGlobalAutoID(tb.Meta().ID)
Expand Down
3 changes: 1 addition & 2 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ func (s *testSuite) TestShow(c *C) {
tk.MustQuery("show create table t").Check(testutil.RowsWithSep("|",
"t CREATE TABLE `t` (\n"+
" `a` int(11) DEFAULT NULL\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin"+"\nPARTITION BY RANGE ( `a` ) (\n PARTITION p0 VALUES LESS THAN 10,\n PARTITION p1 VALUES LESS THAN 20,\n PARTITION p2 VALUES LESS THAN MAXVALUE\n)",
))
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin"))
}

func (s *testSuite) TestShowVisibility(c *C) {
Expand Down

0 comments on commit 1fb887f

Please sign in to comment.