Skip to content

Commit

Permalink
[MariaDB] Add mariadb specific extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ani-sha committed Jan 16, 2025
1 parent 22ea260 commit 9d09cd9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions sql/mariadb/MariaDBLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ STACKED : 'STACKED';
STARTING : 'STARTING';
STATEMENT : 'STATEMENT';
STRAIGHT_JOIN : 'STRAIGHT_JOIN';
SYSTEM : 'SYSTEM';
SYSTEM_TIME : 'SYSTEM_TIME';
TABLE : 'TABLE';
TERMINATED : 'TERMINATED';
THEN : 'THEN';
Expand All @@ -232,6 +234,7 @@ USAGE : 'USAGE';
USE : 'USE';
USING : 'USING';
VALUES : 'VALUES';
VERSIONING : 'VERSIONING';
WHEN : 'WHEN';
WHERE : 'WHERE';
WHILE : 'WHILE';
Expand Down Expand Up @@ -403,6 +406,7 @@ AT : 'AT';
AUTHORS : 'AUTHORS';
AUTOCOMMIT : 'AUTOCOMMIT';
AUTOEXTEND_SIZE : 'AUTOEXTEND_SIZE';
AUTO : 'AUTO';
AUTO_INCREMENT : 'AUTO_INCREMENT';
AVG_ROW_LENGTH : 'AVG_ROW_LENGTH';
BEGIN : 'BEGIN';
Expand Down
27 changes: 24 additions & 3 deletions sql/mariadb/MariaDBParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ tableOption
| tablespaceStorage # tableOptionTablespace
| TRANSACTIONAL '='? ('0' | '1') # tableOptionTransactional
| UNION '='? '(' tables ')' # tableOptionUnion
| WITH SYSTEM VERSIONING # tableOptionWithSystemVersioning // MariaDB-specific only
;

tableType
Expand All @@ -595,6 +596,19 @@ partitionFunctionDefinition
| LINEAR? KEY (ALGORITHM '=' algType = ('1' | '2'))? '(' uidList ')' # partitionFunctionKey
| RANGE ('(' expression ')' | COLUMNS '(' uidList ')') # partitionFunctionRange
| 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
Expand Down Expand Up @@ -709,7 +723,8 @@ alterSpecification
| ADD indexFormat = (INDEX | KEY) ifNotExists? uid? indexType? // here ifNotExists is MariaDB-specific only
indexColumnNames indexOption* # alterByAddIndex
| ADD (CONSTRAINT name = uid?)? PRIMARY KEY index = uid? indexType? indexColumnNames indexOption* # alterByAddPrimaryKey
| ADD (CONSTRAINT name = uid?)? UNIQUE indexFormat = (INDEX | KEY)? ifNotExists? indexName = uid? indexType? indexColumnNames indexOption* #alterByAddUniqueKey
| ADD (CONSTRAINT name = uid?)? UNIQUE indexFormat = (INDEX | KEY)? ifNotExists? indexName = uid? indexType? indexColumnNames indexOption* #
alterByAddUniqueKey
| ADD keyType = (FULLTEXT | SPATIAL) indexFormat = (INDEX | KEY)? uid? indexColumnNames indexOption* # alterByAddSpecialIndex
| ADD (CONSTRAINT name = uid?)? FOREIGN KEY ifNotExists? // here ifNotExists is MariaDB-specific only
indexName = uid? indexColumnNames referenceDefinition # alterByAddForeignKey
Expand Down Expand Up @@ -1662,7 +1677,7 @@ privilege
: ALL PRIVILEGES?
| ALTER ROUTINE?
| CREATE (TEMPORARY TABLES | ROUTINE | VIEW | USER | TABLESPACE | ROLE)?
| DELETE
| DELETE (HISTORY)? // HISTORY is MariaDB-specific
| DROP (ROLE)?
| EVENT
| EXECUTE
Expand Down Expand Up @@ -2304,10 +2319,15 @@ dataType
) # spatialDataType
| typeName = LONG VARCHAR? BINARY? (charSet charsetName)? (COLLATE collationName)? # longVarcharDataType // LONG VARCHAR is the same as LONG
| LONG VARBINARY # longVarbinaryDataType
| UUID # uuidDataType // MariaDB-specific only
;

collectionOptions
: '(' STRING_LITERAL (',' STRING_LITERAL)* ')'
: '(' collectionOption (',' collectionOption)* ')'
;

collectionOption
: STRING_LITERAL
;

convertedDataType
Expand Down Expand Up @@ -3227,6 +3247,7 @@ keywordsCanBeId
| SETVAL
| SKIP_
| STATEMENT
| UUID
| VIA
| MONITOR
| READ_ONLY
Expand Down

0 comments on commit 9d09cd9

Please sign in to comment.