From 80dc7ef802c50a2de26ec0e37af5afedd36d28fe Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 28 Sep 2015 21:31:11 +0800 Subject: [PATCH] plans: update show create table return --- plan/plans/show.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plan/plans/show.go b/plan/plans/show.go index 707cc47201..ea1b276e2d 100644 --- a/plan/plans/show.go +++ b/plan/plans/show.go @@ -405,11 +405,15 @@ func (s *ShowPlan) fetchShowCreateTable(ctx context.Context) error { var buf bytes.Buffer buf.WriteString(fmt.Sprintf("CREATE TABLE `%s` (\n", tb.TableName().O)) for i, col := range tb.Cols() { - buf.WriteString(fmt.Sprintf(" `%s` %s", col.Name.O, col.FieldType.String())) - if col.DefaultValue == nil { - buf.WriteString(" DEFAULT NULL") + buf.WriteString(fmt.Sprintf(" `%s` %s", col.Name.O, col.GetTypeDesc())) + if mysql.HasAutoIncrementFlag(col.Flag) { + buf.WriteString(" NOT NULL AUTO_INCREMENT") } else { - buf.WriteString(fmt.Sprintf(" DEFAULT %v", col.DefaultValue)) + if col.DefaultValue == nil { + buf.WriteString(" DEFAULT NULL") + } else { + buf.WriteString(fmt.Sprintf(" DEFAULT %v", col.DefaultValue)) + } } if i != len(tb.Cols())-1 { buf.WriteString(",\n")