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

PARTITION BY RANGE COLUMNS allows multiple MAXVALUE partitions #36329

Closed
mjonss opened this issue Jul 19, 2022 · 3 comments · Fixed by #36345
Closed

PARTITION BY RANGE COLUMNS allows multiple MAXVALUE partitions #36329

mjonss opened this issue Jul 19, 2022 · 3 comments · Fixed by #36345
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Jul 19, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (d datetime) partition by range columns (d) (partition p1 values less than ('2022-01-01'), partition p2 values less than (maxvalue), partition p3 values less than (MAXVALUE));

2. What did you expect to see? (Required)

mysql>  create table t (d datetime) partition by range columns (d) (partition p1 values less than ('2022-01-01'), partition p2 values less than (maxvalue), partition p3 values less than (MAXVALUE));
ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition

3. What did you see instead (Required)

tidb> create table t (d datetime) partition by range columns (d) (partition p1 values less than ('2022-01-01'), partition p2 values less than (maxvalue), partition p3 values less than (MAXVALUE));
Query OK, 0 rows affected (0,00 sec)

tidb> show create table t\G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `d` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE COLUMNS(`d`)
(PARTITION `p1` VALUES LESS THAN ('2022-01-01'),
 PARTITION `p2` VALUES LESS THAN (MAXVALUE),
 PARTITION `p3` VALUES LESS THAN (MAXVALUE))
1 row in set (0,00 sec)

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v6.2.0-alpha-378-g987bdd3014
Edition: Community
Git Commit Hash: 987bdd3014d8c90302caac3e99092d8014c47109
Git Branch: master
UTC Build Time: 2022-07-19 09:33:05
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Store: unistore
@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Jul 19, 2022
@mjonss
Copy link
Contributor Author

mjonss commented Jul 19, 2022

Issue is in checkTwoRangeColumns, where it only checks if the current partition (and current col) has MAXVALUE, not skipping if both has MAXVALUE.

@mjonss mjonss added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Jul 19, 2022
@u5surf
Copy link
Contributor

u5surf commented Jul 19, 2022

@mjonss Hi, I’d like to work on this issue.
Is this patch like that you expected?


diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go
index dd2a63215..ec3b0953c 100644
--- a/ddl/ddl_api.go
+++ b/ddl/ddl_api.go
@@ -2762,6 +2762,10 @@ func checkTwoRangeColumns(ctx sessionctx.Context, curr, prev *model.PartitionDef
        for i := 0; i < len(pi.Columns); i++ {
                // Special handling for MAXVALUE.
                if strings.EqualFold(curr.LessThan[i], partitionMaxValue) {
+                       if strings.EqualFold(prev.LessThan[i], partitionMaxValue) {
+                               // Current and previous are both maxvalue.
+                               return false, nil
+                       }
                        // If current is maxvalue, it certainly >= previous.
                        return true, nil
                }

@wjhuang2016 wjhuang2016 added the sig/sql-infra SIG: SQL Infra label Jul 20, 2022
@ChenPeng2013 ChenPeng2013 added severity/major affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. labels Jul 20, 2022
u5surf added a commit to u5surf/tidb that referenced this issue Jul 21, 2022
morgo added a commit to morgo/tidb that referenced this issue Jul 22, 2022
…ip-init

* upstream/master: (125 commits)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  log-backup: remove the timezone from log-date (pingcap#36369)
  ...
morgo added a commit to morgo/tidb that referenced this issue Jul 22, 2022
* upstream/master: (280 commits)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  log-backup: remove the timezone from log-date (pingcap#36369)
  ...
joycse06 added a commit to joycse06/tidb that referenced this issue Jul 23, 2022
…rimary-key

* upstream/master: (104 commits)
  br: fix compatibility issue with concurrent ddl (pingcap#36474)
  infoschema: fix PromQL for `tidb_distsql_copr_cache` (pingcap#36450)
  test: stabilize TestTopSQLCPUProfile (pingcap#36468)
  parser: add support of 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' transferring to AST (pingcap#36285)
  *: enable flaky test for all test (pingcap#36385)
  expression: fix return type of agg func `bit_or` when handling varbinary column (pingcap#36415)
  executor: fix aggregating enum zero value gets different results from mysql  (pingcap#36208)
  server: skip check tiflash version (pingcap#36451)
  *: Minor update to SECURITY.md to improved clarity (pingcap#36346)
  table partition: add telemetry for partition table (pingcap#36204)
  ddl: invalid multiple MAXVALUE partitions (pingcap#36329) (pingcap#36345)
  planner: Fixed `Merge` hint in nested CTE (pingcap#36432)
  metric: impove concurrency ddl metrics (pingcap#36405)
  planner: add more test cases for leading outer join (pingcap#36409)
  ddl: only set concurrent variable if no error (pingcap#36437)
  ddl: fix update panic in the middle of multi-schema change (pingcap#36421)
  session: Mising OptimizeWithPlanAndThenWarmUp in prepare-execute path (pingcap#36347)
  executor,metrics: add a metric for observing execution phases (pingcap#35906)
  br: unified docker image align with tidb (pingcap#36016)
  ddl: skip to close nil sessPool  (pingcap#36425)
  ...
@MimeLyc
Copy link

MimeLyc commented Jul 25, 2022

/remove-label affects-6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants