Skip to content

Commit

Permalink
ddl: fix create partition table not suport bit and year column type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and ciscoxll committed Jul 23, 2018
1 parent a7ae09b commit 3d04c5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,9 @@ func (s *testDBSuite) TestCreateTableWithPartition(c *C) {
partition p1 values less than (6)
);`)
c.Assert(err, IsNil)

s.tk.MustExec(`create TABLE t20 (c1 int,c2 bit(10)) partition by range(c2) (partition p0 values less than (10));`)
s.tk.MustExec(`create TABLE t21 (c1 int,c2 year) partition by range( c2 ) (partition p0 values less than (2000));`)
}

func (s *testDBSuite) TestTableDDLWithFloatType(c *C) {
Expand Down
6 changes: 3 additions & 3 deletions ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/types"
)

const (
Expand Down Expand Up @@ -148,8 +148,8 @@ func checkCreatePartitionValue(pi *model.PartitionInfo) error {

// validRangePartitionType checks the type supported by the range partitioning key.
func validRangePartitionType(col *table.Column) bool {
switch col.Tp {
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong:
switch col.FieldType.EvalType() {
case types.ETInt:
return true
default:
return false
Expand Down

0 comments on commit 3d04c5e

Please sign in to comment.