You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by lu...@apache.org on 2021/05/25 06:00:44 UTC

[shardingsphere] branch master updated: proofread the syntax definition of CREATE TABLE (#10383)

This is an automated email from the ASF dual-hosted git repository.

lujingshang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a28aba6  proofread the syntax definition of CREATE TABLE (#10383)
a28aba6 is described below

commit a28aba6d5d873f191dd377241bea7b7aebb773f6
Author: Icesource <71...@qq.com>
AuthorDate: Tue May 25 14:00:00 2021 +0800

    proofread the syntax definition of CREATE TABLE (#10383)
    
    Co-authored-by: IceSource <ic...@outlook.com>
---
 .../src/main/antlr4/imports/sqlserver/BaseRule.g4  |  3 ++-
 .../main/antlr4/imports/sqlserver/DDLStatement.g4  | 26 ++++++++++++++++++----
 .../antlr4/imports/sqlserver/SQLServerKeyword.g4   | 16 +++++++++++++
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
index 01ba1ae..90af20d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
@@ -281,7 +281,7 @@ orderByItem
     ;
 
 dataType
-    : dataTypeName (dataTypeLength | LP_ MAX RP_ | LP_ (CONTENT | DOCUMENT)? ignoredIdentifier RP_)?
+    : (ignoredIdentifier DOT_)? dataTypeName (dataTypeLength | LP_ MAX RP_ | LP_ (CONTENT | DOCUMENT)? ignoredIdentifier RP_)?
     ;
 
 dataTypeName
@@ -376,6 +376,7 @@ eqKey
     | ALLOW_PAGE_LOCKS
     | COMPRESSION_DELAY
     | SORT_IN_TEMPDB
+    | OPTIMIZE_FOR_SEQUENTIAL_KEY
     ;
 
 eqOnOff
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
index f5c852d..fbab2b7 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
@@ -91,6 +91,18 @@ columnConstraint
     : (CONSTRAINT ignoredIdentifier)? (primaryKeyConstraint | columnForeignKeyConstraint | checkConstraint)
     ;
 
+computedColumnConstraint
+    : (CONSTRAINT ignoredIdentifier)? (primaryKeyConstraint | computedColumnForeignKeyConstraint | checkConstraint)
+    ;
+
+computedColumnForeignKeyConstraint
+    : (FOREIGN KEY)? tableName (LP_ columnName RP_)? computedColumnForeignKeyOnAction*
+    ;
+
+computedColumnForeignKeyOnAction
+    : ON DELETE (NO ACTION | CASCADE) | ON UPDATE NO ACTION | NOT FOR REPLICATION
+    ;
+
 primaryKeyConstraint
     : (primaryKey | UNIQUE) (diskTablePrimaryKeyConstraintOption | memoryTablePrimaryKeyConstraintOption)
     ;
@@ -124,7 +136,8 @@ onString
     ;
 
 memoryTablePrimaryKeyConstraintOption
-    : CLUSTERED withBucket?
+    : NONCLUSTERED
+    | NONCLUSTERED HASH withBucket?
     ;
 
 withBucket
@@ -132,7 +145,7 @@ withBucket
     ;
 
 columnForeignKeyConstraint
-    : (FOREIGN KEY)? REFERENCES tableName LP_ columnName RP_ foreignKeyOnAction*
+    : (FOREIGN KEY)? REFERENCES tableName (LP_ columnName RP_)? foreignKeyOnAction*
     ;
 
 foreignKeyOnAction
@@ -172,7 +185,7 @@ columnConstraints
     ;
 
 computedColumnDefinition
-    : columnName AS expr (PERSISTED(NOT NULL)?)? columnConstraint?
+    : columnName AS expr (PERSISTED(NOT NULL)?)? computedColumnConstraint?
     ;
 
 columnSetDefinition 
@@ -247,10 +260,15 @@ tableOption
     | tableOperationOption
     | distributionOption
     | dataWareHouseTableOption
+    | dataDelectionOption
+    ;
+
+dataDelectionOption
+    : DATA_DELETION = ON (LP_ FILTER_COLUMN EQ_ columnName COMMA_ RETENTION_PERIOD EQ_ historyRetentionPeriod)
     ;
 
 tableStretchOptions
-    : LP_ tableStretchOptions (COMMA_ tableStretchOptions)* RP_
+    : LP_ tableStretchOption (COMMA_ tableStretchOption)* RP_
     ;
 
 tableStretchOption
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
index a9fa7f6..1d13ec1 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
@@ -1054,3 +1054,19 @@ RECOMPILE
 ROBUST
     : R O B U S T
     ;
+
+OPTIMIZE_FOR_SEQUENTIAL_KEY
+    : O P T I M I Z E UL_ F O R UL_ S E Q U E N T I A L UL_ K E Y
+    ;
+
+DATA_DELETION
+    : D A T A UL_ D E L E T I O N
+    ;
+
+FILTER_COLUMN
+    : F I L T E R UL_ C O L U M N
+    ;
+
+RETENTION_PERIOD
+    : R E T E N T I O N UL_ P E R I O D
+    ;