From 6fcbbbfa61584b90f54d3370938bc0e122a25cdf Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Fri, 1 May 2020 00:01:05 +0800 Subject: [PATCH 01/13] add action of exchange partition --- model/ddl.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/ddl.go b/model/ddl.go index 6f06e3d4e..216a33047 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -70,6 +70,7 @@ const ( ActionDropColumns ActionType = 38 ActionModifyTableAutoIdCache ActionType = 39 ActionRebaseAutoRandomBase ActionType = 40 + ActionExchangeTablePartition ActionType = 41 ) const ( @@ -119,6 +120,7 @@ var actionMap = map[ActionType]string{ ActionDropColumns: "drop multi-columns", ActionModifyTableAutoIdCache: "modify auto id cache", ActionRebaseAutoRandomBase: "rebase auto_random ID", + ActionExchangeTablePartition: "exchange partition", } // String return current ddl action in string From 66de447dbe4a89f59b30ebef25b4b113a3c9329a Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Wed, 13 May 2020 13:01:00 +0800 Subject: [PATCH 02/13] delete warn --- parser.y | 2 -- 1 file changed, 2 deletions(-) diff --git a/parser.y b/parser.y index 5af2eb6a0..4e38f6a42 100644 --- a/parser.y +++ b/parser.y @@ -1530,8 +1530,6 @@ AlterTableSpec: NewTable: $6.(*ast.TableName), WithValidation: $7.(bool), } - yylex.AppendError(yylex.Errorf("TiDB does not support EXCHANGE PARTITION now, it would be parsed but ignored.")) - parser.lastErrorAsWarn() } | "TRUNCATE" "PARTITION" AllOrPartitionNameList { From 4ef36290d57aa07519210cc89efa23cb8507b108 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Wed, 13 May 2020 13:21:32 +0800 Subject: [PATCH 03/13] recreat parser.go --- parser.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/parser.go b/parser.go index 21db77fe8..0931d72ab 100644 --- a/parser.go +++ b/parser.go @@ -10015,8 +10015,6 @@ yynewstate: NewTable: yyS[yypt-1].item.(*ast.TableName), WithValidation: yyS[yypt-0].item.(bool), } - yylex.AppendError(yylex.Errorf("TiDB does not support EXCHANGE PARTITION now, it would be parsed but ignored.")) - parser.lastErrorAsWarn() } case 24: { From be22f4d2ac380ab05ab56f2a60678a004a43b454 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Tue, 2 Jun 2020 02:35:34 +0800 Subject: [PATCH 04/13] add attribution --- model/ddl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/ddl.go b/model/ddl.go index f09bc05df..5f5670f40 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -429,4 +429,7 @@ type SchemaDiff struct { OldTableID int64 `json:"old_table_id"` // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` + + // PtTableID is the table ID of partition table when exchanging partition + PtTableID int64 `json:"pt_table_id"` } From acd1a1774f3b1fdc338c8f401c273b28765f4942 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Tue, 2 Jun 2020 02:41:00 +0800 Subject: [PATCH 05/13] add attribution --- model/ddl.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/ddl.go b/model/ddl.go index 5f5670f40..2cbd42770 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -432,4 +432,6 @@ type SchemaDiff struct { // PtTableID is the table ID of partition table when exchanging partition PtTableID int64 `json:"pt_table_id"` + // PtSchemaID is the schema ID of partition table when exchanging partition + PtSchemaID int64 `json:"pt_schema_id"` } From 5a16167b9d4bac5d8811c4efd9b355f5f4065406 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Tue, 2 Jun 2020 14:19:52 +0800 Subject: [PATCH 06/13] rename field --- model/ddl.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index 2cbd42770..9d5c2307f 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,8 +430,8 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - // PtTableID is the table ID of partition table when exchanging partition - PtTableID int64 `json:"pt_table_id"` - // PtSchemaID is the schema ID of partition table when exchanging partition - PtSchemaID int64 `json:"pt_schema_id"` + // AffectedTableID is the table ID of partition table when exchanging partition + AffectedTableID int64 `json:"affected_table_id"` + // AffectedSchemaID is the schema ID of partition table when exchanging partition + AffectedSchemaID int64 `json:"affected_schema_id"` } From fc9e460ed5177bf519390a22041ac8a0df2879a6 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Wed, 3 Jun 2020 23:09:01 +0800 Subject: [PATCH 07/13] fix comment --- model/ddl.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index 9d5c2307f..44748c7f7 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,8 +430,13 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - // AffectedTableID is the table ID of partition table when exchanging partition - AffectedTableID int64 `json:"affected_table_id"` - // AffectedSchemaID is the schema ID of partition table when exchanging partition - AffectedSchemaID int64 `json:"affected_schema_id"` + OtherAffectedSchema []*SchemaAffect `json:"other_affected_schema"` +} + +// SchemaAffect is uesed when a ddl affect multi table. +type SchemaAffect struct { + SchemaID int64 `json:"schema_id"` + TableID int64 `json:"table_id"` + OldTableID int64 `json:"old_table_id"` + OldSchemaID int64 `json:"old_schema_id"` } From 471d601bcb9aeb9ac273ec8542ab9220b9bd577f Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Wed, 3 Jun 2020 23:12:56 +0800 Subject: [PATCH 08/13] fix typo --- model/ddl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ddl.go b/model/ddl.go index 44748c7f7..5ecf55605 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -433,7 +433,7 @@ type SchemaDiff struct { OtherAffectedSchema []*SchemaAffect `json:"other_affected_schema"` } -// SchemaAffect is uesed when a ddl affect multi table. +// SchemaAffect is used when a ddl affects multi tables. type SchemaAffect struct { SchemaID int64 `json:"schema_id"` TableID int64 `json:"table_id"` From a36e5365faefe82533923ce8874bce2f92d01044 Mon Sep 17 00:00:00 2001 From: Zhao Xin Date: Thu, 4 Jun 2020 14:14:07 +0800 Subject: [PATCH 09/13] Update model/ddl.go Co-authored-by: Lynn --- model/ddl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ddl.go b/model/ddl.go index 5ecf55605..a5ff68da0 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,7 +430,7 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - OtherAffectedSchema []*SchemaAffect `json:"other_affected_schema"` + OtherAffectedSchemas []*SchemaAffect `json:"other_affected_schema"` } // SchemaAffect is used when a ddl affects multi tables. From 985e550751faa7ad1c7abe3a9dcc96aaf5816a58 Mon Sep 17 00:00:00 2001 From: Zhao Xin Date: Thu, 4 Jun 2020 14:48:46 +0800 Subject: [PATCH 10/13] Update model/ddl.go Co-authored-by: kennytm --- model/ddl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ddl.go b/model/ddl.go index a5ff68da0..77b22c5a1 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -434,7 +434,7 @@ type SchemaDiff struct { } // SchemaAffect is used when a ddl affects multi tables. -type SchemaAffect struct { +type AffectedSchema struct { SchemaID int64 `json:"schema_id"` TableID int64 `json:"table_id"` OldTableID int64 `json:"old_table_id"` From 3ff692163a88fed7ecaca134cb98dad4481c22b9 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Thu, 4 Jun 2020 17:50:33 +0800 Subject: [PATCH 11/13] rename --- model/ddl.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index 77b22c5a1..c620b8b8d 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,11 +430,11 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - OtherAffectedSchemas []*SchemaAffect `json:"other_affected_schema"` + OtherAffectedItems []*AffectedItem `json:"other_affected_items"` } -// SchemaAffect is used when a ddl affects multi tables. -type AffectedSchema struct { +// AffectItem is used when a ddl affects multi tables. +type AffectedItem struct { SchemaID int64 `json:"schema_id"` TableID int64 `json:"table_id"` OldTableID int64 `json:"old_table_id"` From 11a84598acea60656b7ca2cb9fdb55d134f1e7d8 Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Thu, 4 Jun 2020 20:03:27 +0800 Subject: [PATCH 12/13] rename --- model/ddl.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index c620b8b8d..26a4ca143 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,11 +430,11 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - OtherAffectedItems []*AffectedItem `json:"other_affected_items"` + AffectOpts []*AffectOption `json:"other_affect_options"` } -// AffectItem is used when a ddl affects multi tables. -type AffectedItem struct { +// AffectOption is used when a ddl affects multi tables. +type AffectOption struct { SchemaID int64 `json:"schema_id"` TableID int64 `json:"table_id"` OldTableID int64 `json:"old_table_id"` From ca6fb6810542902d6324d6d9e7f872cd45b841fb Mon Sep 17 00:00:00 2001 From: zhaox1n Date: Fri, 5 Jun 2020 11:10:11 +0800 Subject: [PATCH 13/13] rename --- model/ddl.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/ddl.go b/model/ddl.go index 26a4ca143..d1dd2cbb6 100644 --- a/model/ddl.go +++ b/model/ddl.go @@ -430,11 +430,11 @@ type SchemaDiff struct { // OldSchemaID is the schema ID before rename table, only used by rename table DDL. OldSchemaID int64 `json:"old_schema_id"` - AffectOpts []*AffectOption `json:"other_affect_options"` + AffectedOpts []*AffectedOption `json:"affected_options"` } -// AffectOption is used when a ddl affects multi tables. -type AffectOption struct { +// AffectedOption is used when a ddl affects multi tables. +type AffectedOption struct { SchemaID int64 `json:"schema_id"` TableID int64 `json:"table_id"` OldTableID int64 `json:"old_table_id"`