MDEV-15621 Auto add RANGE COLUMNS partitions by interval#5152
MDEV-15621 Auto add RANGE COLUMNS partitions by interval#5152mariadb-YuchenPei wants to merge 3 commits into
Conversation
|
|
There was a problem hiding this comment.
Code Review
This pull request introduces range interval partitioning support for DATE, DATETIME, and TIMESTAMP columns, allowing automatic partition creation during DML operations. The changes include parser updates to support interval syntax (including Oracle-style interval functions) and core partitioning logic modifications. The review feedback highlights several critical issues: a missing copy of the interval struct during partition creation that would cause duplicate range values, potential out-of-bounds reads in the parser due to passing non-null-terminated strings to atoi, and multiple potential null-pointer dereferences or crashes in the partitioning and memory allocation paths.
c2470f1 to
4ab6759
Compare
4ab6759 to
8c05cb9
Compare
| /* | ||
| TODO(MDEV-15621): need to save reprepare observer and | ||
| reset_n_backup_query_tables_list like in vers_create_partitions? | ||
| */ |
There was a problem hiding this comment.
(for the record: I don't have a clear idea why the above would be needed...)
| case SQLCOM_REPLACE: | ||
| case SQLCOM_REPLACE_SELECT: | ||
| case SQLCOM_UPDATE_MULTI: | ||
| break; |
There was a problem hiding this comment.
Also handle SQLCOM_DELETE_MULTI ?
There was a problem hiding this comment.
Another question: do we have coverage for this scenario:
Row-based replication slave.
We execute CREATE TABLE t1 which creates a table with no partition for today.
Then we read an RBR event inserting a row with today's date.
Will we be able to catch the "opening table with no partition for today" and create the partition?
There was a problem hiding this comment.
Also handle SQLCOM_DELETE_MULTI ?
@spetrunia Why would a DELETE statement require new partitions?
There was a problem hiding this comment.
Re RBR: yes this could be a problem like https://jira.mariadb.org/browse/MDEV-39808
a13772d to
33f529b
Compare
change p_column_list_val::fixed to a bool remove redundant end label in partition_info::fix_column_value_functions
Allow auto partitioning by interval in PARTITION BY RANGE COLUMNS PARTITION BY RANGE COLUMNS (col_name) INTERVAL interval [AUTO] ( PARTITION partition_name VALUES LESS THAN (value) [, PARTITION partition_name VALUES LESS THAN (value) ... ] ) where - col_name is the name of one column of type DATE or DATETIME or TIMESTAMP - at least one partition is supplied, and the highest partition cannot have MAXVALUE range - INTERVAL interval is a positive time interval. it can be mariadb format or oracle NUMTODSINTERVAL/NUMTOYMINTERVAL format. Like versioning, the smallest unit is second, i.e. no subsecond like microsecond. - DATE column cannot have interval with values less than a day When performing DML on such a table, it will first add partitions by the specified interval until the partition covers the current time. Partition addition will not cause an implicit commit like DDL normally does. The partitions are named pN. Otherwise the table behaves exactly the same as a normal RANGE COLUMNS partitioned table. Note that TIMESTAMP is not allowed as a type for PARTITION BY RANGE COLUMNS otherwise.
33f529b to
e1a4793
Compare
Reviving #5111