diff --git a/ddl/db_partition_test.go b/ddl/db_partition_test.go index 31b1f03d14a64..2b34a481c78b4 100644 --- a/ddl/db_partition_test.go +++ b/ddl/db_partition_test.go @@ -31,6 +31,7 @@ import ( "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/ddl/testutil" "github.com/pingcap/tidb/domain" + "github.com/pingcap/tidb/errno" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/meta" "github.com/pingcap/tidb/session" @@ -1668,6 +1669,16 @@ func (s *testIntegrationSuite3) TestPartitionErrorCode(c *C) { );`) _, err = tk.Exec("alter table t_part coalesce partition 4;") c.Assert(ddl.ErrCoalesceOnlyOnHashPartition.Equal(err), IsTrue) + + tk.MustGetErrCode(`alter table t_part reorganize partition p0, p1 into ( + partition p0 values less than (1980));`, errno.ErrUnsupportedDDLOperation) + + tk.MustGetErrCode("alter table t_part check partition p0, p1;", errno.ErrUnsupportedDDLOperation) + tk.MustGetErrCode("alter table t_part optimize partition p0,p1;", errno.ErrUnsupportedDDLOperation) + tk.MustGetErrCode("alter table t_part rebuild partition p0,p1;", errno.ErrUnsupportedDDLOperation) + tk.MustGetErrCode("alter table t_part remove partitioning;", errno.ErrUnsupportedDDLOperation) + tk.MustExec("create table t_part2 like t_part") + tk.MustGetErrCode("alter table t_part exchange partition p0 with table t_part2", errno.ErrUnsupportedDDLOperation) } func (s *testIntegrationSuite5) TestConstAndTimezoneDepent(c *C) { diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index 0499441451947..89b7fdf47a9c2 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -2084,6 +2084,18 @@ func (d *ddl) AlterTable(ctx sessionctx.Context, ident ast.Ident, specs []*ast.A err = d.AddTablePartitions(ctx, ident, spec) case ast.AlterTableCoalescePartitions: err = d.CoalescePartitions(ctx, ident, spec) + case ast.AlterTableReorganizePartition: + err = errors.Trace(errUnsupportedReorganizePartition) + case ast.AlterTableCheckPartitions: + err = errors.Trace(errUnsupportedCheckPartition) + case ast.AlterTableRebuildPartition: + err = errors.Trace(errUnsupportedRebuildPartition) + case ast.AlterTableOptimizePartition: + err = errors.Trace(errUnsupportedOptimizePartition) + case ast.AlterTableRemovePartitioning: + err = errors.Trace(errUnsupportedRemovePartition) + case ast.AlterTableExchangePartition: + err = errors.Trace(errUnsupportedExchangePartition) case ast.AlterTableDropColumn: err = d.DropColumn(ctx, ident, spec) case ast.AlterTableDropIndex: diff --git a/ddl/error.go b/ddl/error.go index 71c5ca735fe0a..d55eae1711c6b 100644 --- a/ddl/error.go +++ b/ddl/error.go @@ -82,7 +82,13 @@ var ( // ErrUnsupportedAddPartition returns for does not support add partitions. ErrUnsupportedAddPartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "add partitions")) // ErrUnsupportedCoalescePartition returns for does not support coalesce partitions. - ErrUnsupportedCoalescePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "coalesce partitions")) + ErrUnsupportedCoalescePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "coalesce partitions")) + errUnsupportedReorganizePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "reorganize partition")) + errUnsupportedCheckPartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "check partition")) + errUnsupportedOptimizePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "optimize partition")) + errUnsupportedRebuildPartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "rebuild partition")) + errUnsupportedRemovePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "remove partitioning")) + errUnsupportedExchangePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "exchange partition")) // ErrGeneratedColumnFunctionIsNotAllowed returns for unsupported functions for generated columns. ErrGeneratedColumnFunctionIsNotAllowed = terror.ClassDDL.New(mysql.ErrGeneratedColumnFunctionIsNotAllowed, mysql.MySQLErrName[mysql.ErrGeneratedColumnFunctionIsNotAllowed]) // ErrUnsupportedPartitionByRangeColumns returns for does unsupported partition by range columns.