From 3b711c466388c9ffa8354c79b0be43ff4406b9d4 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 14 Aug 2018 15:19:14 +0800 Subject: [PATCH 1/2] executor: drop partition information in 'show create table' --- executor/show.go | 14 +------------- executor/show_test.go | 3 +-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/executor/show.go b/executor/show.go index 3f18500167e5c..542a1ba857164 100644 --- a/executor/show.go +++ b/executor/show.go @@ -592,19 +592,7 @@ func (e *ShowExec) fetchShowCreateTable() error { // 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. } if hasAutoIncID { diff --git a/executor/show_test.go b/executor/show_test.go index 65fb85d987a97..ef105db383c19 100644 --- a/executor/show_test.go +++ b/executor/show_test.go @@ -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) { From 4c53b5b01bb4d31073f1e68e073557bff0fc9720 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 14 Aug 2018 17:24:45 +0800 Subject: [PATCH 2/2] address comment --- executor/show.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/executor/show.go b/executor/show.go index 542a1ba857164..b00ac27d74957 100644 --- a/executor/show.go +++ b/executor/show.go @@ -589,11 +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 { - // Partition info is truncated in release-2.0 branch. - } + // 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)