Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: make 'alter table reorganize partition' report error (#17020) #17178

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion ddl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down