pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.27k stars 5.85k forks source link

tidb 支持 oracle INTERVAL 分区功能 #39678

Open pingcapweixiaobing opened 1 year ago

pingcapweixiaobing commented 1 year ago

Feature Request

新增简化 Range 分区定义的语法糖 (syntactic sugar) Range INTERVAL 分区特性(实验特性)#35683 @mjonss

提供了新的定义 Range 分区的方式 Range INTERVAL 分区,不需要枚举所有分区,可大幅度缩短现有 Range 分区表定义语句冗长的书写方式。语义与原有 Range 分区等价。

目前的功能 mysql> CREATE TABLE monthly_report_status ( -> report_id int NOT NULL, -> report_status varchar(20) NOT NULL, -> report_date date NOT NULL -> ) -> PARTITION BY RANGE COLUMNS (report_date) -> INTERVAL (1 MONTH) FIRST PARTITION LESS THAN ('2000-01-01') LAST PARTITION LESS THAN ('2025-01-01'); Query OK, 0 rows affected (0.14 sec)

实际创建了所有的分区,客户希望的是能根据表的实际数据来创建分区,不是提前创建所有分区 mysql> show create table monthly_report_status\G; 1. row Table: monthly_report_status Create Table: CREATE TABLE monthly_report_status ( report_id int(11) NOT NULL, report_status varchar(20) NOT NULL, report_date date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin PARTITION BY RANGE COLUMNS(report_date) (PARTITION P_LT_2000-01-01 VALUES LESS THAN ('2000-01-01'), PARTITION P_LT_2000-02-01 VALUES LESS THAN ('2000-02-01'), PARTITION P_LT_2000-03-01 VALUES LESS THAN ('2000-03-01'), PARTITION P_LT_2000-04-01 VALUES LESS THAN ('2000-04-01'), PARTITION P_LT_2000-05-01 VALUES LESS THAN ('2000-05-01'), PARTITION P_LT_2000-06-01 VALUES LESS THAN ('2000-06-01'), PARTITION P_LT_2000-07-01 VALUES LESS THAN ('2000-07-01'), PARTITION P_LT_2000-08-01 VALUES LESS THAN ('2000-08-01'), PARTITION P_LT_2000-09-01 VALUES LESS THAN ('2000-09-01'), PARTITION P_LT_2000-10-01 VALUES LESS THAN ('2000-10-01'), PARTITION P_LT_2000-11-01 VALUES LESS THAN ('2000-11-01'), PARTITION P_LT_2000-12-01 VALUES LESS THAN ('2000-12-01'), PARTITION P_LT_2001-01-01 VALUES LESS THAN ('2001-01-01'), PARTITION P_LT_2001-02-01 VALUES LESS THAN ('2001-02-01'), PARTITION P_LT_2001-03-01 VALUES LESS THAN ('2001-03-01'), PARTITION P_LT_2001-04-01 VALUES LESS THAN ('2001-04-01'), PARTITION P_LT_2001-05-01 VALUES LESS THAN ('2001-05-01'), PARTITION P_LT_2001-06-01 VALUES LESS THAN ('2001-06-01'), PARTITION P_LT_2001-07-01 VALUES LESS THAN ('2001-07-01'), PARTITION P_LT_2001-08-01 VALUES LESS THAN ('2001-08-01'), PARTITION P_LT_2001-09-01 VALUES LESS THAN ('2001-09-01'), PARTITION P_LT_2001-10-01 VALUES LESS THAN ('2001-10-01'), PARTITION P_LT_2001-11-01 VALUES LESS THAN ('2001-11-01'), PARTITION P_LT_2001-12-01 VALUES LESS THAN ('2001-12-01'), PARTITION P_LT_2002-01-01 VALUES LESS THAN ('2002-01-01'), PARTITION P_LT_2002-02-01 VALUES LESS THAN ('2002-02-01'), PARTITION P_LT_2002-03-01 VALUES LESS THAN ('2002-03-01'), PARTITION P_LT_2002-04-01 VALUES LESS THAN ('2002-04-01'), PARTITION P_LT_2002-05-01 VALUES LESS THAN ('2002-05-01'), PARTITION P_LT_2002-06-01 VALUES LESS THAN ('2002-06-01'), PARTITION P_LT_2002-07-01 VALUES LESS THAN ('2002-07-01'), PARTITION P_LT_2002-08-01 VALUES LESS THAN ('2002-08-01'), PARTITION P_LT_2002-09-01 VALUES LESS THAN ('2002-09-01'), PARTITION P_LT_2002-10-01 VALUES LESS THAN ('2002-10-01'), PARTITION P_LT_2002-11-01 VALUES LESS THAN ('2002-11-01'), PARTITION P_LT_2002-12-01 VALUES LESS THAN ('2002-12-01'), PARTITION P_LT_2003-01-01 VALUES LESS THAN ('2003-01-01'), PARTITION P_LT_2003-02-01 VALUES LESS THAN ('2003-02-01'), PARTITION P_LT_2003-03-01 VALUES LESS THAN ('2003-03-01'), PARTITION P_LT_2003-04-01 VALUES LESS THAN ('2003-04-01'), PARTITION P_LT_2003-05-01 VALUES LESS THAN ('2003-05-01'), PARTITION P_LT_2003-06-01 VALUES LESS THAN ('2003-06-01'), PARTITION P_LT_2003-07-01 VALUES LESS THAN ('2003-07-01'), PARTITION P_LT_2003-08-01 VALUES LESS THAN ('2003-08-01'), PARTITION P_LT_2003-09-01 VALUES LESS THAN ('2003-09-01'), PARTITION P_LT_2003-10-01 VALUES LESS THAN ('2003-10-01'), PARTITION P_LT_2003-11-01 VALUES LESS THAN ('2003-11-01'), PARTITION P_LT_2003-12-01 VALUES LESS THAN ('2003-12-01'), PARTITION P_LT_2004-01-01 VALUES LESS THAN ('2004-01-01'), PARTITION P_LT_2004-02-01 VALUES LESS THAN ('2004-02-01'), PARTITION P_LT_2004-03-01 VALUES LESS THAN ('2004-03-01'), PARTITION P_LT_2004-04-01 VALUES LESS THAN ('2004-04-01'), PARTITION P_LT_2004-05-01 VALUES LESS THAN ('2004-05-01'), PARTITION P_LT_2004-06-01 VALUES LESS THAN ('2004-06-01'), PARTITION P_LT_2004-07-01 VALUES LESS THAN ('2004-07-01'), PARTITION P_LT_2004-08-01 VALUES LESS THAN ('2004-08-01'), PARTITION P_LT_2004-09-01 VALUES LESS THAN ('2004-09-01'), PARTITION P_LT_2004-10-01 VALUES LESS THAN ('2004-10-01'), PARTITION P_LT_2004-11-01 VALUES LESS THAN ('2004-11-01'), PARTITION P_LT_2004-12-01 VALUES LESS THAN ('2004-12-01'), PARTITION P_LT_2005-01-01 VALUES LESS THAN ('2005-01-01'), PARTITION P_LT_2005-02-01 VALUES LESS THAN ('2005-02-01'), PARTITION P_LT_2005-03-01 VALUES LESS THAN ('2005-03-01'), PARTITION P_LT_2005-04-01 VALUES LESS THAN ('2005-04-01'), PARTITION P_LT_2005-05-01 VALUES LESS THAN ('2005-05-01'), PARTITION P_LT_2005-06-01 VALUES LESS THAN ('2005-06-01'), PARTITION P_LT_2005-07-01 VALUES LESS THAN ('2005-07-01'), PARTITION P_LT_2005-08-01 VALUES LESS THAN ('2005-08-01'), PARTITION P_LT_2005-09-01 VALUES LESS THAN ('2005-09-01'), PARTITION P_LT_2005-10-01 VALUES LESS THAN ('2005-10-01'), PARTITION P_LT_2005-11-01 VALUES LESS THAN ('2005-11-01'), PARTITION P_LT_2005-12-01 VALUES LESS THAN ('2005-12-01'), PARTITION P_LT_2006-01-01 VALUES LESS THAN ('2006-01-01'), PARTITION P_LT_2006-02-01 VALUES LESS THAN ('2006-02-01'), PARTITION P_LT_2006-03-01 VALUES LESS THAN ('2006-03-01'), PARTITION P_LT_2006-04-01 VALUES LESS THAN ('2006-04-01'), PARTITION P_LT_2006-05-01 VALUES LESS THAN ('2006-05-01'), PARTITION P_LT_2006-06-01 VALUES LESS THAN ('2006-06-01'), PARTITION P_LT_2006-07-01 VALUES LESS THAN ('2006-07-01'), PARTITION P_LT_2006-08-01 VALUES LESS THAN ('2006-08-01'), PARTITION P_LT_2006-09-01 VALUES LESS THAN ('2006-09-01'), PARTITION P_LT_2006-10-01 VALUES LESS THAN ('2006-10-01'), PARTITION P_LT_2006-11-01 VALUES LESS THAN ('2006-11-01'), PARTITION P_LT_2006-12-01 VALUES LESS THAN ('2006-12-01'), PARTITION P_LT_2007-01-01 VALUES LESS THAN ('2007-01-01'), PARTITION P_LT_2007-02-01 VALUES LESS THAN ('2007-02-01'), PARTITION P_LT_2007-03-01 VALUES LESS THAN ('2007-03-01'), PARTITION P_LT_2007-04-01 VALUES LESS THAN ('2007-04-01'), PARTITION P_LT_2007-05-01 VALUES LESS THAN ('2007-05-01'), PARTITION P_LT_2007-06-01 VALUES LESS THAN ('2007-06-01'), PARTITION P_LT_2007-07-01 VALUES LESS THAN ('2007-07-01'), PARTITION P_LT_2007-08-01 VALUES LESS THAN ('2007-08-01'), PARTITION P_LT_2007-09-01 VALUES LESS THAN ('2007-09-01'), PARTITION P_LT_2007-10-01 VALUES LESS THAN ('2007-10-01'), PARTITION P_LT_2007-11-01 VALUES LESS THAN ('2007-11-01'), PARTITION P_LT_2007-12-01 VALUES LESS THAN ('2007-12-01'), PARTITION P_LT_2008-01-01 VALUES LESS THAN ('2008-01-01'), PARTITION P_LT_2008-02-01 VALUES LESS THAN ('2008-02-01'), PARTITION P_LT_2008-03-01 VALUES LESS THAN ('2008-03-01'), PARTITION P_LT_2008-04-01 VALUES LESS THAN ('2008-04-01'), PARTITION P_LT_2008-05-01 VALUES LESS THAN ('2008-05-01'), PARTITION P_LT_2008-06-01 VALUES LESS THAN ('2008-06-01'), PARTITION P_LT_2008-07-01 VALUES LESS THAN ('2008-07-01'), PARTITION P_LT_2008-08-01 VALUES LESS THAN ('2008-08-01'), PARTITION P_LT_2008-09-01 VALUES LESS THAN ('2008-09-01'), PARTITION P_LT_2008-10-01 VALUES LESS THAN ('2008-10-01'), PARTITION P_LT_2008-11-01 VALUES LESS THAN ('2008-11-01'), PARTITION P_LT_2008-12-01 VALUES LESS THAN ('2008-12-01'), PARTITION P_LT_2009-01-01 VALUES LESS THAN ('2009-01-01'), PARTITION P_LT_2009-02-01 VALUES LESS THAN ('2009-02-01'), PARTITION P_LT_2009-03-01 VALUES LESS THAN ('2009-03-01'), PARTITION P_LT_2009-04-01 VALUES LESS THAN ('2009-04-01'), PARTITION P_LT_2009-05-01 VALUES LESS THAN ('2009-05-01'), PARTITION P_LT_2009-06-01 VALUES LESS THAN ('2009-06-01'), PARTITION P_LT_2009-07-01 VALUES LESS THAN ('2009-07-01'), PARTITION P_LT_2009-08-01 VALUES LESS THAN ('2009-08-01'), PARTITION P_LT_2009-09-01 VALUES LESS THAN ('2009-09-01'), PARTITION P_LT_2009-10-01 VALUES LESS THAN ('2009-10-01'), PARTITION P_LT_2009-11-01 VALUES LESS THAN ('2009-11-01'), PARTITION P_LT_2009-12-01 VALUES LESS THAN ('2009-12-01'), PARTITION P_LT_2010-01-01 VALUES LESS THAN ('2010-01-01'), PARTITION P_LT_2010-02-01 VALUES LESS THAN ('2010-02-01'), PARTITION P_LT_2010-03-01 VALUES LESS THAN ('2010-03-01'), PARTITION P_LT_2010-04-01 VALUES LESS THAN ('2010-04-01'), PARTITION P_LT_2010-05-01 VALUES LESS THAN ('2010-05-01'), PARTITION P_LT_2010-06-01 VALUES LESS THAN ('2010-06-01'), PARTITION P_LT_2010-07-01 VALUES LESS THAN ('2010-07-01'), PARTITION P_LT_2010-08-01 VALUES LESS THAN ('2010-08-01'), PARTITION P_LT_2010-09-01 VALUES LESS THAN ('2010-09-01'), PARTITION P_LT_2010-10-01 VALUES LESS THAN ('2010-10-01'), PARTITION P_LT_2010-11-01 VALUES LESS THAN ('2010-11-01'), PARTITION P_LT_2010-12-01 VALUES LESS THAN ('2010-12-01'), PARTITION P_LT_2011-01-01 VALUES LESS THAN ('2011-01-01'), PARTITION P_LT_2011-02-01 VALUES LESS THAN ('2011-02-01'), PARTITION P_LT_2011-03-01 VALUES LESS THAN ('2011-03-01'), PARTITION P_LT_2011-04-01 VALUES LESS THAN ('2011-04-01'), PARTITION P_LT_2011-05-01 VALUES LESS THAN ('2011-05-01'), PARTITION P_LT_2011-06-01 VALUES LESS THAN ('2011-06-01'), PARTITION P_LT_2011-07-01 VALUES LESS THAN ('2011-07-01'), PARTITION P_LT_2011-08-01 VALUES LESS THAN ('2011-08-01'), PARTITION P_LT_2011-09-01 VALUES LESS THAN ('2011-09-01'), PARTITION P_LT_2011-10-01 VALUES LESS THAN ('2011-10-01'), PARTITION P_LT_2011-11-01 VALUES LESS THAN ('2011-11-01'), PARTITION P_LT_2011-12-01 VALUES LESS THAN ('2011-12-01'), PARTITION P_LT_2012-01-01 VALUES LESS THAN ('2012-01-01'), PARTITION P_LT_2012-02-01 VALUES LESS THAN ('2012-02-01'), PARTITION P_LT_2012-03-01 VALUES LESS THAN ('2012-03-01'), PARTITION P_LT_2012-04-01 VALUES LESS THAN ('2012-04-01'), PARTITION P_LT_2012-05-01 VALUES LESS THAN ('2012-05-01'), PARTITION P_LT_2012-06-01 VALUES LESS THAN ('2012-06-01'), PARTITION P_LT_2012-07-01 VALUES LESS THAN ('2012-07-01'), PARTITION P_LT_2012-08-01 VALUES LESS THAN ('2012-08-01'), PARTITION P_LT_2012-09-01 VALUES LESS THAN ('2012-09-01'), PARTITION P_LT_2012-10-01 VALUES LESS THAN ('2012-10-01'), PARTITION P_LT_2012-11-01 VALUES LESS THAN ('2012-11-01'), PARTITION P_LT_2012-12-01 VALUES LESS THAN ('2012-12-01'), PARTITION P_LT_2013-01-01 VALUES LESS THAN ('2013-01-01'), PARTITION P_LT_2013-02-01 VALUES LESS THAN ('2013-02-01'), PARTITION P_LT_2013-03-01 VALUES LESS THAN ('2013-03-01'), PARTITION P_LT_2013-04-01 VALUES LESS THAN ('2013-04-01'), PARTITION P_LT_2013-05-01 VALUES LESS THAN ('2013-05-01'), PARTITION P_LT_2013-06-01 VALUES LESS THAN ('2013-06-01'), PARTITION P_LT_2013-07-01 VALUES LESS THAN ('2013-07-01'), PARTITION P_LT_2013-08-01 VALUES LESS THAN ('2013-08-01'), PARTITION P_LT_2013-09-01 VALUES LESS THAN ('2013-09-01'), PARTITION P_LT_2013-10-01 VALUES LESS THAN ('2013-10-01'), PARTITION P_LT_2013-11-01 VALUES LESS THAN ('2013-11-01'), PARTITION P_LT_2013-12-01 VALUES LESS THAN ('2013-12-01'), PARTITION P_LT_2014-01-01 VALUES LESS THAN ('2014-01-01'), PARTITION P_LT_2014-02-01 VALUES LESS THAN ('2014-02-01'), PARTITION P_LT_2014-03-01 VALUES LESS THAN ('2014-03-01'), PARTITION P_LT_2014-04-01 VALUES LESS THAN ('2014-04-01'), PARTITION P_LT_2014-05-01 VALUES LESS THAN ('2014-05-01'), PARTITION P_LT_2014-06-01 VALUES LESS THAN ('2014-06-01'), PARTITION P_LT_2014-07-01 VALUES LESS THAN ('2014-07-01'), PARTITION P_LT_2014-08-01 VALUES LESS THAN ('2014-08-01'), PARTITION P_LT_2014-09-01 VALUES LESS THAN ('2014-09-01'), PARTITION P_LT_2014-10-01 VALUES LESS THAN ('2014-10-01'), PARTITION P_LT_2014-11-01 VALUES LESS THAN ('2014-11-01'), PARTITION P_LT_2014-12-01 VALUES LESS THAN ('2014-12-01'), PARTITION P_LT_2015-01-01 VALUES LESS THAN ('2015-01-01'), PARTITION P_LT_2015-02-01 VALUES LESS THAN ('2015-02-01'), PARTITION P_LT_2015-03-01 VALUES LESS THAN ('2015-03-01'), PARTITION P_LT_2015-04-01 VALUES LESS THAN ('2015-04-01'), PARTITION P_LT_2015-05-01 VALUES LESS THAN ('2015-05-01'), PARTITION P_LT_2015-06-01 VALUES LESS THAN ('2015-06-01'), PARTITION P_LT_2015-07-01 VALUES LESS THAN ('2015-07-01'), PARTITION P_LT_2015-08-01 VALUES LESS THAN ('2015-08-01'), PARTITION P_LT_2015-09-01 VALUES LESS THAN ('2015-09-01'), PARTITION P_LT_2015-10-01 VALUES LESS THAN ('2015-10-01'), PARTITION P_LT_2015-11-01 VALUES LESS THAN ('2015-11-01'), PARTITION P_LT_2015-12-01 VALUES LESS THAN ('2015-12-01'), PARTITION P_LT_2016-01-01 VALUES LESS THAN ('2016-01-01'), PARTITION P_LT_2016-02-01 VALUES LESS THAN ('2016-02-01'), PARTITION P_LT_2016-03-01 VALUES LESS THAN ('2016-03-01'), PARTITION P_LT_2016-04-01 VALUES LESS THAN ('2016-04-01'), PARTITION P_LT_2016-05-01 VALUES LESS THAN ('2016-05-01'), PARTITION P_LT_2016-06-01 VALUES LESS THAN ('2016-06-01'), PARTITION P_LT_2016-07-01 VALUES LESS THAN ('2016-07-01'), PARTITION P_LT_2016-08-01 VALUES LESS THAN ('2016-08-01'), PARTITION P_LT_2016-09-01 VALUES LESS THAN ('2016-09-01'), PARTITION P_LT_2016-10-01 VALUES LESS THAN ('2016-10-01'), PARTITION P_LT_2016-11-01 VALUES LESS THAN ('2016-11-01'), PARTITION P_LT_2016-12-01 VALUES LESS THAN ('2016-12-01'), PARTITION P_LT_2017-01-01 VALUES LESS THAN ('2017-01-01'), PARTITION P_LT_2017-02-01 VALUES LESS THAN ('2017-02-01'), PARTITION P_LT_2017-03-01 VALUES LESS THAN ('2017-03-01'), PARTITION P_LT_2017-04-01 VALUES LESS THAN ('2017-04-01'), PARTITION P_LT_2017-05-01 VALUES LESS THAN ('2017-05-01'), PARTITION P_LT_2017-06-01 VALUES LESS THAN ('2017-06-01'), PARTITION P_LT_2017-07-01 VALUES LESS THAN ('2017-07-01'), PARTITION P_LT_2017-08-01 VALUES LESS THAN ('2017-08-01'), PARTITION P_LT_2017-09-01 VALUES LESS THAN ('2017-09-01'), PARTITION P_LT_2017-10-01 VALUES LESS THAN ('2017-10-01'), PARTITION P_LT_2017-11-01 VALUES LESS THAN ('2017-11-01'), PARTITION P_LT_2017-12-01 VALUES LESS THAN ('2017-12-01'), PARTITION P_LT_2018-01-01 VALUES LESS THAN ('2018-01-01'), PARTITION P_LT_2018-02-01 VALUES LESS THAN ('2018-02-01'), PARTITION P_LT_2018-03-01 VALUES LESS THAN ('2018-03-01'), PARTITION P_LT_2018-04-01 VALUES LESS THAN ('2018-04-01'), PARTITION P_LT_2018-05-01 VALUES LESS THAN ('2018-05-01'), PARTITION P_LT_2018-06-01 VALUES LESS THAN ('2018-06-01'), PARTITION P_LT_2018-07-01 VALUES LESS THAN ('2018-07-01'), PARTITION P_LT_2018-08-01 VALUES LESS THAN ('2018-08-01'), PARTITION P_LT_2018-09-01 VALUES LESS THAN ('2018-09-01'), PARTITION P_LT_2018-10-01 VALUES LESS THAN ('2018-10-01'), PARTITION P_LT_2018-11-01 VALUES LESS THAN ('2018-11-01'), PARTITION P_LT_2018-12-01 VALUES LESS THAN ('2018-12-01'), PARTITION P_LT_2019-01-01 VALUES LESS THAN ('2019-01-01'), PARTITION P_LT_2019-02-01 VALUES LESS THAN ('2019-02-01'), PARTITION P_LT_2019-03-01 VALUES LESS THAN ('2019-03-01'), PARTITION P_LT_2019-04-01 VALUES LESS THAN ('2019-04-01'), PARTITION P_LT_2019-05-01 VALUES LESS THAN ('2019-05-01'), PARTITION P_LT_2019-06-01 VALUES LESS THAN ('2019-06-01'), PARTITION P_LT_2019-07-01 VALUES LESS THAN ('2019-07-01'), PARTITION P_LT_2019-08-01 VALUES LESS THAN ('2019-08-01'), PARTITION P_LT_2019-09-01 VALUES LESS THAN ('2019-09-01'), PARTITION P_LT_2019-10-01 VALUES LESS THAN ('2019-10-01'), PARTITION P_LT_2019-11-01 VALUES LESS THAN ('2019-11-01'), PARTITION P_LT_2019-12-01 VALUES LESS THAN ('2019-12-01'), PARTITION P_LT_2020-01-01 VALUES LESS THAN ('2020-01-01'), PARTITION P_LT_2020-02-01 VALUES LESS THAN ('2020-02-01'), PARTITION P_LT_2020-03-01 VALUES LESS THAN ('2020-03-01'), PARTITION P_LT_2020-04-01 VALUES LESS THAN ('2020-04-01'), PARTITION P_LT_2020-05-01 VALUES LESS THAN ('2020-05-01'), PARTITION P_LT_2020-06-01 VALUES LESS THAN ('2020-06-01'), PARTITION P_LT_2020-07-01 VALUES LESS THAN ('2020-07-01'), PARTITION P_LT_2020-08-01 VALUES LESS THAN ('2020-08-01'), PARTITION P_LT_2020-09-01 VALUES LESS THAN ('2020-09-01'), PARTITION P_LT_2020-10-01 VALUES LESS THAN ('2020-10-01'), PARTITION P_LT_2020-11-01 VALUES LESS THAN ('2020-11-01'), PARTITION P_LT_2020-12-01 VALUES LESS THAN ('2020-12-01'), PARTITION P_LT_2021-01-01 VALUES LESS THAN ('2021-01-01'), PARTITION P_LT_2021-02-01 VALUES LESS THAN ('2021-02-01'), PARTITION P_LT_2021-03-01 VALUES LESS THAN ('2021-03-01'), PARTITION P_LT_2021-04-01 VALUES LESS THAN ('2021-04-01'), PARTITION P_LT_2021-05-01 VALUES LESS THAN ('2021-05-01'), PARTITION P_LT_2021-06-01 VALUES LESS THAN ('2021-06-01'), PARTITION P_LT_2021-07-01 VALUES LESS THAN ('2021-07-01'), PARTITION P_LT_2021-08-01 VALUES LESS THAN ('2021-08-01'), PARTITION P_LT_2021-09-01 VALUES LESS THAN ('2021-09-01'), PARTITION P_LT_2021-10-01 VALUES LESS THAN ('2021-10-01'), PARTITION P_LT_2021-11-01 VALUES LESS THAN ('2021-11-01'), PARTITION P_LT_2021-12-01 VALUES LESS THAN ('2021-12-01'), PARTITION P_LT_2022-01-01 VALUES LESS THAN ('2022-01-01'), PARTITION P_LT_2022-02-01 VALUES LESS THAN ('2022-02-01'), PARTITION P_LT_2022-03-01 VALUES LESS THAN ('2022-03-01'), PARTITION P_LT_2022-04-01 VALUES LESS THAN ('2022-04-01'), PARTITION P_LT_2022-05-01 VALUES LESS THAN ('2022-05-01'), PARTITION P_LT_2022-06-01 VALUES LESS THAN ('2022-06-01'), PARTITION P_LT_2022-07-01 VALUES LESS THAN ('2022-07-01'), PARTITION P_LT_2022-08-01 VALUES LESS THAN ('2022-08-01'), PARTITION P_LT_2022-09-01 VALUES LESS THAN ('2022-09-01'), PARTITION P_LT_2022-10-01 VALUES LESS THAN ('2022-10-01'), PARTITION P_LT_2022-11-01 VALUES LESS THAN ('2022-11-01'), PARTITION P_LT_2022-12-01 VALUES LESS THAN ('2022-12-01'), PARTITION P_LT_2023-01-01 VALUES LESS THAN ('2023-01-01'), PARTITION P_LT_2023-02-01 VALUES LESS THAN ('2023-02-01'), PARTITION P_LT_2023-03-01 VALUES LESS THAN ('2023-03-01'), PARTITION P_LT_2023-04-01 VALUES LESS THAN ('2023-04-01'), PARTITION P_LT_2023-05-01 VALUES LESS THAN ('2023-05-01'), PARTITION P_LT_2023-06-01 VALUES LESS THAN ('2023-06-01'), PARTITION P_LT_2023-07-01 VALUES LESS THAN ('2023-07-01'), PARTITION P_LT_2023-08-01 VALUES LESS THAN ('2023-08-01'), PARTITION P_LT_2023-09-01 VALUES LESS THAN ('2023-09-01'), PARTITION P_LT_2023-10-01 VALUES LESS THAN ('2023-10-01'), PARTITION P_LT_2023-11-01 VALUES LESS THAN ('2023-11-01'), PARTITION P_LT_2023-12-01 VALUES LESS THAN ('2023-12-01'), PARTITION P_LT_2024-01-01 VALUES LESS THAN ('2024-01-01'), PARTITION P_LT_2024-02-01 VALUES LESS THAN ('2024-02-01'), PARTITION P_LT_2024-03-01 VALUES LESS THAN ('2024-03-01'), PARTITION P_LT_2024-04-01 VALUES LESS THAN ('2024-04-01'), PARTITION P_LT_2024-05-01 VALUES LESS THAN ('2024-05-01'), PARTITION P_LT_2024-06-01 VALUES LESS THAN ('2024-06-01'), PARTITION P_LT_2024-07-01 VALUES LESS THAN ('2024-07-01'), PARTITION P_LT_2024-08-01 VALUES LESS THAN ('2024-08-01'), PARTITION P_LT_2024-09-01 VALUES LESS THAN ('2024-09-01'), PARTITION P_LT_2024-10-01 VALUES LESS THAN ('2024-10-01'), PARTITION P_LT_2024-11-01 VALUES LESS THAN ('2024-11-01'), PARTITION P_LT_2024-12-01 VALUES LESS THAN ('2024-12-01'), PARTITION P_LT_2025-01-01 VALUES LESS THAN ('2025-01-01')) 1 row in set (0.00 sec)

mjonss commented 1 year ago

As I understand the request is to only create the partitions when needed in an INTERVAL partitioned table. I think that is a good idea, but it needs changes to internals in TiDB, like triggering creation of new physical table IDs, assigning them to new partitions etc. It will also break the MySQL compatibility, since if one exports such table it will either not be parsed by MySQL (no support for INTERVAL) OR define empty partitions (as above) OR define partitions which has greater range than in TiDB (if we only would output the actual used partitions and leave the non-filled partitions in between).