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

Table with range columns can't add partition #12320

Closed
fatpa opened this issue Sep 23, 2019 · 5 comments
Closed

Table with range columns can't add partition #12320

fatpa opened this issue Sep 23, 2019 · 5 comments
Assignees
Labels
type/bug The issue is confirmed as a bug.

Comments

@fatpa
Copy link

fatpa commented Sep 23, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

Table Schema is

CREATE TABLE `test4` (
  `stime` datetime DEFAULT NULL,
  KEY `stime` (`stime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin 
PARTITION BY RANGE columns (stime) (
  PARTITION p20190901 VALUES LESS THAN ('2019-09-02 00:00:00'),
  PARTITION p20190902 VALUES LESS THAN ('2019-09-03 00:00:00')
);

and run the sql

ALTER TABLE test4 add partition (PARTITION p20190903 VALUES LESS THAN ('2019-09-04 00:00:00'));
  1. What did you expect to see?
    Query OK, 0 rows affected

  2. What did you see instead?
    ERROR 1659 (HY000): Field '"2019-09-02 00:00:00"' is of a not allowed type for this type of partitioning

  3. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
    V3.0.2

@fatpa fatpa added the type/bug The issue is confirmed as a bug. label Sep 23, 2019
@fatpa
Copy link
Author

fatpa commented Sep 23, 2019

It seems that can't work with varchar or datetime type.

@tiancaiamao tiancaiamao self-assigned this Sep 23, 2019
@tiancaiamao
Copy link
Contributor

Well, partition by range and partition by range columns shares some code, and partition by range has the constraint that only int value is allowed in the partition expression, this constraint is mistakenly imposed on partition by range columns and cause this bug.

@fatpa
Copy link
Author

fatpa commented Sep 23, 2019

The TODO onddl/partition.go

// TODO: Remove the test 's.Partition.Expr == nil' when we support 'PARTITION BY RANGE COLUMNS'
if len(constraints) == 0 || s.Partition.Expr == nil {
	return nil
}

It looks like that the condition s.Partition.Expr == nil needs to be removed.

@tiancaiamao
Copy link
Contributor

@crazycs520 is working on it.

@fatpa
Copy link
Author

fatpa commented Nov 2, 2019

Duplicate of #12792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants