DBZ-7468 Support parsing MariaDB SYSTEM VERSIONING DDL

This commit is contained in:
Chris Cranford 2024-02-09 15:57:57 -05:00 committed by Chris Cranford
parent 237755331a
commit 8265e4e42e
4 changed files with 45 additions and 0 deletions

View File

@ -53,6 +53,7 @@ ARRAY: 'ARRAY';
AS: 'AS'; AS: 'AS';
ASC: 'ASC'; ASC: 'ASC';
ATTRIBUTE: 'ATTRIBUTE'; ATTRIBUTE: 'ATTRIBUTE';
AUTO: 'AUTO'; // MariaDB-specific
BEFORE: 'BEFORE'; BEFORE: 'BEFORE';
BETWEEN: 'BETWEEN'; BETWEEN: 'BETWEEN';
BOTH: 'BOTH'; BOTH: 'BOTH';
@ -211,6 +212,7 @@ STACKED: 'STACKED';
STARTING: 'STARTING'; STARTING: 'STARTING';
STATEMENT: 'STATEMENT'; STATEMENT: 'STATEMENT';
STRAIGHT_JOIN: 'STRAIGHT_JOIN'; STRAIGHT_JOIN: 'STRAIGHT_JOIN';
SYSTEM_TIME: 'SYSTEM_TIME'; // MariaDB-specific
TABLE: 'TABLE'; TABLE: 'TABLE';
TERMINATED: 'TERMINATED'; TERMINATED: 'TERMINATED';
THEN: 'THEN'; THEN: 'THEN';

View File

@ -548,6 +548,21 @@ partitionFunctionDefinition
'(' uidList? ')' #partitionFunctionKey // Optional uidList for MySQL only '(' uidList? ')' #partitionFunctionKey // Optional uidList for MySQL only
| RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange | RANGE ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionRange
| LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList | LIST ( '(' expression ')' | COLUMNS '(' uidList ')' ) #partitionFunctionList
| SYSTEM_TIME
( expression | LIMIT expression )
( STARTS ( TIMESTAMP timestampValue | timestampValue ) )?
AUTO?
partitionSystemVersionDefinitions? #partitionSystemVersion // MariaDB-specific
;
// MariaDB-specific
partitionSystemVersionDefinitions
: '(' partitionSystemVersionDefinition (',' partitionSystemVersionDefinition)* ')'
;
// MariaDB-specific
partitionSystemVersionDefinition
: PARTITION uid ( HISTORY | CURRENT )
; ;
subpartitionFunctionDefinition subpartitionFunctionDefinition

View File

@ -59,6 +59,9 @@ ALTER TABLE T1 ALTER I SET VISIBLE;
ALTER TABLE T1 ALTER I SET INVISIBLE; ALTER TABLE T1 ALTER I SET INVISIBLE;
ALTER TABLE IF EXISTS `add_test` ADD COLUMN IF NOT EXISTS `new_col` TEXT DEFAULT 'my_default'; ALTER TABLE IF EXISTS `add_test` ADD COLUMN IF NOT EXISTS `new_col` TEXT DEFAULT 'my_default';
alter table user_details add index if not exists `country_id_index` (country_id), algorithm=NOCOPY; alter table user_details add index if not exists `country_id_index` (country_id), algorithm=NOCOPY;
-- # MariaDB Specific
ALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR;
ALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;
#end #end
#begin #begin
-- Alter database -- Alter database

View File

@ -748,3 +748,28 @@ ORDER BY 1
; ;
END END
#end #end
#begin
CREATE TABLE `dailydata` (
`DATE` bigint(20) NOT NULL,
`ID` varchar(25) NOT NULL,
`OPEN` double DEFAULT NULL,
`HIGH` double DEFAULT NULL,
`LOW` double DEFAULT NULL,
`CLOSE` double DEFAULT NULL,
PRIMARY KEY (`ID`,`DATE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2024-02-05 00:00:00' AUTO
PARTITIONS 6
#end
#begin
CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 1000 AUTO;
#end
#begin
CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;
#endif
#begin
CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO
(PARTITION p0 HISTORY, PARTITION pn CURRENT);
#end