From d4464cdde59f0c3979c0b77c504e251e59470a3b Mon Sep 17 00:00:00 2001 From: winkyao Date: Mon, 5 Nov 2018 17:40:01 +0800 Subject: [PATCH 1/3] *: add ActionModifyTableCharsetAndCollate to support alter table charset and collate --- ast/ddl.go | 2 ++ model/ddl.go | 43 ++++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ast/ddl.go b/ast/ddl.go index aefa2eed2..7282801af 100644 --- a/ast/ddl.go +++ b/ast/ddl.go @@ -682,6 +682,8 @@ type TableOption struct { Tp TableOptionType StrValue string UintValue uint64 + // Skipped indicate the TableOption can be skipped. + Skipped bool } // ColumnPositionType is the type for ColumnPosition. diff --git a/model/ddl.go b/model/ddl.go index fa7e9887e..4f6fd98d7 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -29,27 +29,28 @@ type ActionType byte // List DDL actions. const ( - ActionNone ActionType = 0 - ActionCreateSchema ActionType = 1 - ActionDropSchema ActionType = 2 - ActionCreateTable ActionType = 3 - ActionDropTable ActionType = 4 - ActionAddColumn ActionType = 5 - ActionDropColumn ActionType = 6 - ActionAddIndex ActionType = 7 - ActionDropIndex ActionType = 8 - ActionAddForeignKey ActionType = 9 - ActionDropForeignKey ActionType = 10 - ActionTruncateTable ActionType = 11 - ActionModifyColumn ActionType = 12 - ActionRebaseAutoID ActionType = 13 - ActionRenameTable ActionType = 14 - ActionSetDefaultValue ActionType = 15 - ActionShardRowID ActionType = 16 - ActionModifyTableComment ActionType = 17 - ActionRenameIndex ActionType = 18 - ActionAddTablePartition ActionType = 19 - ActionDropTablePartition ActionType = 20 + ActionNone ActionType = 0 + ActionCreateSchema ActionType = 1 + ActionDropSchema ActionType = 2 + ActionCreateTable ActionType = 3 + ActionDropTable ActionType = 4 + ActionAddColumn ActionType = 5 + ActionDropColumn ActionType = 6 + ActionAddIndex ActionType = 7 + ActionDropIndex ActionType = 8 + ActionAddForeignKey ActionType = 9 + ActionDropForeignKey ActionType = 10 + ActionTruncateTable ActionType = 11 + ActionModifyColumn ActionType = 12 + ActionRebaseAutoID ActionType = 13 + ActionRenameTable ActionType = 14 + ActionSetDefaultValue ActionType = 15 + ActionShardRowID ActionType = 16 + ActionModifyTableComment ActionType = 17 + ActionRenameIndex ActionType = 18 + ActionAddTablePartition ActionType = 19 + ActionDropTablePartition ActionType = 20 + ActionModifyTableCharsetAndCollate ActionType = 21 ) // AddIndexStr is a string related to the operation of "add index". From 921d258011cd4386d8e01ef8639acde9a7473937 Mon Sep 17 00:00:00 2001 From: winkyao Date: Thu, 6 Dec 2018 21:27:59 +0800 Subject: [PATCH 2/3] address comment --- ast/ddl.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/ast/ddl.go b/ast/ddl.go index b91e8ceb9..cb9076049 100644 --- a/ast/ddl.go +++ b/ast/ddl.go @@ -821,8 +821,6 @@ type TableOption struct { Tp TableOptionType StrValue string UintValue uint64 - // Skipped indicate the TableOption can be skipped. - Skipped bool } // ColumnPositionType is the type for ColumnPosition. From 836e4f9bf01e0b0ccc16fef12905ffa822bd1134 Mon Sep 17 00:00:00 2001 From: winkyao Date: Mon, 10 Dec 2018 14:07:55 +0800 Subject: [PATCH 3/3] addresss comment --- model/ddl.go | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index 07eb2e953..2488f7c69 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -58,27 +58,28 @@ const ( const AddIndexStr = "add index" var actionMap = map[ActionType]string{ - ActionCreateSchema: "create schema", - ActionDropSchema: "drop schema", - ActionCreateTable: "create table", - ActionDropTable: "drop table", - ActionAddColumn: "add column", - ActionDropColumn: "drop column", - ActionAddIndex: AddIndexStr, - ActionDropIndex: "drop index", - ActionAddForeignKey: "add foreign key", - ActionDropForeignKey: "drop foreign key", - ActionTruncateTable: "truncate table", - ActionModifyColumn: "modify column", - ActionRebaseAutoID: "rebase auto_increment ID", - ActionRenameTable: "rename table", - ActionSetDefaultValue: "set default value", - ActionShardRowID: "shard row ID", - ActionModifyTableComment: "modify table comment", - ActionRenameIndex: "rename index", - ActionAddTablePartition: "add partition", - ActionDropTablePartition: "drop table partition", - ActionCreateView: "create view", + ActionCreateSchema: "create schema", + ActionDropSchema: "drop schema", + ActionCreateTable: "create table", + ActionDropTable: "drop table", + ActionAddColumn: "add column", + ActionDropColumn: "drop column", + ActionAddIndex: AddIndexStr, + ActionDropIndex: "drop index", + ActionAddForeignKey: "add foreign key", + ActionDropForeignKey: "drop foreign key", + ActionTruncateTable: "truncate table", + ActionModifyColumn: "modify column", + ActionRebaseAutoID: "rebase auto_increment ID", + ActionRenameTable: "rename table", + ActionSetDefaultValue: "set default value", + ActionShardRowID: "shard row ID", + ActionModifyTableComment: "modify table comment", + ActionRenameIndex: "rename index", + ActionAddTablePartition: "add partition", + ActionDropTablePartition: "drop table partition", + ActionCreateView: "create view", + ActionModifyTableCharsetAndCollate: "modify table charset and collate", } // String return current ddl action in string