Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
c1caa149
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c1caa149
编写于
8月 31, 2018
作者:
C
codefairy08
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add create table statement
add alter table statement
上级
151814ed
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
293 addition
and
27 deletion
+293
-27
sharding-jdbc-ddl-parser/src/main/antlr4/imports/MySQLDQL.g4
sharding-jdbc-ddl-parser/src/main/antlr4/imports/MySQLDQL.g4
+11
-2
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/postgre/PostgreDDL.g4
...tlr4/io/shardingsphere/parser/antlr/postgre/PostgreDDL.g4
+282
-25
未找到文件。
sharding-jdbc-ddl-parser/src/main/antlr4/imports/MySQLDQL.g4
浏览文件 @
c1caa149
...
...
@@ -163,6 +163,11 @@ simpleExpr:
//| match_expr
//| case_expr
// | interval_expr
|privateExprOfDb
;
privateExprOfDb:
'Default does not match anything'
;
liter:
...
...
@@ -214,3 +219,7 @@ collateClauseWithEqual:
selectExpr:
bitExpr AS? alias?
;
exprs:
expr (COMMA expr)*
;
\ No newline at end of file
sharding-jdbc-ddl-parser/src/main/antlr4/io/shardingsphere/parser/antlr/postgre/PostgreDDL.g4
浏览文件 @
c1caa149
...
...
@@ -22,7 +22,7 @@ createTableHeader:
;
createDefinitions:
LEFT_PAREN
createDefinition (COMMA createDefinition)*
RIGHT_PAREN
LEFT_PAREN
(createDefinition (COMMA createDefinition)*)?
RIGHT_PAREN
;
createDefinition:
...
...
@@ -36,7 +36,11 @@ inheritClause:
;
partitionClause:
PARTITION BY (RANGE | LIST) LEFT_PAREN (columnName | exprWithParen) collateClause? (opclass (COMMA opclass)*)? RIGHT_PAREN
PARTITION BY (RANGE | LIST) LEFT_PAREN partitionClauseParam (COMMA partitionClauseParam)* RIGHT_PAREN
;
partitionClauseParam:
(columnName | expr) collateClause? opclass?
;
tableWithClause:
...
...
@@ -56,7 +60,7 @@ tableSpaceClause:
createTypeTable:
createTableHeader
typeNameClause
createDefinition1s
createDefinition1s
?
partitionClause?
tableWithClause?
commitClause?
...
...
@@ -72,14 +76,15 @@ createDefinition1s:
;
createDefinition1:
columnName (WITH OPTIONS )? columnConstraint*
(columnName (WITH OPTIONS )? columnConstraint*)
| tableConstraint
;
createTableForPartition:
createTableHeader
partitionOfParent
createDefinition1s
createDefinition1s?
forValuesParition
partitionClause?
tableWithClause?
commitClause?
...
...
@@ -90,13 +95,13 @@ partitionOfParent:
PARTITION OF tableName
;
valuesClause
:
forValuesParition
:
FOR VALUES partitionBoundSpec
;
partitionBoundSpec:
(IN inValueOption)
|
FROM fromValueOption TO fromValueOption
|
(FROM fromValueOption TO fromValueOption)
;
inValueOption:
...
...
@@ -122,9 +127,13 @@ fromValueOption:
;
createTableOptions:
NONE
;
;
dataType:
basicDataType (LEFT_BRACKET RIGHT_BRACKET)*
;
basicDataType:
BIGINT
|INT8
|BIGSERIAL
...
...
@@ -164,7 +173,7 @@ dataType:
|SERIAL4
|FLOAT numericPrecision?
|TEXT
|(TIME | TIMESTAMP) numericPrecision?((WITHOUT TIME ZONE)? | (WITH
OUT
TIME ZONE))
|(TIME | TIMESTAMP) numericPrecision?((WITHOUT TIME ZONE)? | (WITH TIME ZONE))
|TSQUERY
|TSVECTOR
|TXID_SNAPSHOT
...
...
@@ -172,19 +181,33 @@ dataType:
|XML
;
/** loose match
* ID = Y M W D H M S
* */
intervalType:
INTERVAL ID? numericPrecision?
INTERVAL intervalFields? numericPrecision?
;
intervalFields:
intervalField (TO intervalField)?
;
intervalField:
YEAR
|MONTH
|DAY
|HOUR
|MINUTE
|SECOND
;
numericPrecision:
LEFT_PAREN NUMBER (COMMA NUMBER)? RIGHT_PAREN
;
defaultExpr:
CURRENT_TIMESTAMP
|expr;
defaultExpr: expr;
exprsWithParen:
LEFT_PAREN exprs RIGHT_PAREN
;
exprWithParen:
LEFT_PAREN expr RIGHT_PAREN
...
...
@@ -197,8 +220,7 @@ collateClause:
columnConstraint:
constraintClause?
columnConstraintOption
(DEFERRABLE | NOT DEFERRABLE)?
(INITIALLY DEFERRED | INITIALLY IMMEDIATE)?
constraintOptionalParam
;
columnConstraintOption:
...
...
@@ -225,14 +247,18 @@ action:
;
sequenceOptions:
(INCREMENT BY? NUMBER)?
(MINVALUE NUMBER | NO MINVALUE)?
(MAXVALUE NUMBER | NO MAXVALUE)?
sequenceOption
(START WITH? NUMBER)?
(CACHE NUMBER)?
(NO? CYCLE)?
;
sequenceOption:
(INCREMENT BY? NUMBER)?
(MINVALUE NUMBER | NO MINVALUE)?
(MAXVALUE NUMBER | NO MAXVALUE)?
;
likeOption:
(INCLUDING | EXCLUDING )
(COMMENTS | CONSTRAINTS | DEFAULTS | IDENTITY | INDEXES | STATISTICS | STORAGE | ALL)
...
...
@@ -241,8 +267,7 @@ likeOption:
tableConstraint:
constraintClause?
tableConstraintOption
(DEFERRABLE | NOT DEFERRABLE )?
(INITIALLY DEFERRED | INITIALLY IMMEDIATE )?
constraintOptionalParam
;
tableConstraintOption:
...
...
@@ -279,6 +304,9 @@ operator:
|GTE
|LT
|LTE
|AND_SYM
|OR_SYM
|NOT_SYM
;
typeName:ID;
...
...
@@ -288,7 +316,7 @@ constraintClause:
;
withStorageParameters:
WITH LEFT_PAREN storageParameters
LEF
T_PAREN
WITH LEFT_PAREN storageParameters
RIGH
T_PAREN
;
storageParameters:
...
...
@@ -306,3 +334,232 @@ storageParameter:
opclass:
ID
;
alterTable:
(alterTableNameWithAsterisk(alterTableActions| renameColumn | renameConstraint))
|(alterTableNameExists(renameTable | setSchema |attachTableSpace |detachTableSpace))
|alterTableSetTableSpace
;
alterTableOp:
ALTER TABLE
;
alterTableActions:
alterTableAction (COMMA alterTableAction)*
;
renameColumn:
RENAME COLUMN? columnName TO columnName
;
renameConstraint:
RENAME CONSTRAINT constraintName TO constraintName
;
renameTable:
RENAME TO tableName
;
setSchema:
SET SCHEMA schemaName
;
alterTableSetTableSpace:
alterTableOp ALL IN TABLESPACE tablespaceName (OWNED BY roleName (COMMA roleName)* )?
SET TABLESPACE tablespaceName NOWAIT?
;
attachTableSpace:
ATTACH PARTITION partitionName forValuesParition
;
detachTableSpace:
DETACH PARTITION partitionName
;
alterTableNameWithAsterisk:
alterTableOp (IF EXISTS)? ONLY? tableName ASTERISK?
;
alterTableNameExists:
alterTableOp (IF EXISTS)? tableName
;
roleName:
ID
;
partitionName:
ID
;
triggerName:
ID
;
rewriteRuleName:
ID
;
ownerName:
ID
;
alterTableAction:
(ADD COLUMN? (IF NOT EXISTS )? columnName dataType collateClause? (columnConstraint columnConstraint*)?)
|(DROP COLUMN? (IF EXISTS)? columnName (RESTRICT | CASCADE)?)
|(alterColumnOp columnName (SET DATA)? TYPE dataType collateClause? (USING expr)?)
|(alterColumnOp columnName SET DEFAULT expr)
|(alterColumnOp columnName DROP DEFAULT)
|(alterColumnOp columnName (SET | DROP) NOT NULL)
|(alterColumnOp columnName ADD GENERATED (ALWAYS | (BY DEFAULT)) AS IDENTITY (LEFT_PAREN sequenceOptions RIGHT_PAREN)?)
|(alterColumnOp columnName alterColumnSetOption alterColumnSetOption*)
|(alterColumnOp columnName DROP IDENTITY (IF EXISTS)?)
|(alterColumnOp columnName SET STATISTICS NUMBER)
|(alterColumnOp columnName SET LEFT_PAREN attributeOptions RIGHT_PAREN)
|(alterColumnOp columnName RESET LEFT_PAREN attributeOptions RIGHT_PAREN)
|(alterColumnOp columnName SET STORAGE (PLAIN | EXTERNAL | EXTENDED | MAIN))
|(ADD tableConstraint (NOT VALID)?)
|(ADD tableConstraintUsingIndex)
|(ALTER CONSTRAINT constraintName constraintOptionalParam)
|(VALIDATE CONSTRAINT constraintName)
|(DROP CONSTRAINT (IF EXISTS)? constraintName (RESTRICT | CASCADE)?)
|((DISABLE |ENABLE) TRIGGER (triggerName | ALL | USER )?)
|(ENABLE (REPLICA | ALWAYS) TRIGGER triggerName)
|((DISABLE | ENABLE) RULE rewriteRuleName)
|(ENABLE (REPLICA | ALWAYS) RULE rewriteRuleName)
|((DISABLE | ENABLE | (NO? FORCE)) ROW LEVEL SECURITY)
|(CLUSTER ON indexName)
|(SET WITHOUT CLUSTER)
|(SET (WITH | WITHOUT) OIDS)
|(SET TABLESPACE tablespaceName)
|(SET (LOGGED | UNLOGGED))
|(SET LEFT_PAREN storageParameterWithValue (COMMA storageParameterWithValue)* RIGHT_PAREN)
|(RESET LEFT_PAREN storageParameter (COMMA storageParameter)* RIGHT_PAREN)
|(INHERIT tableName)
|(NO INHERIT tableName)
|(OF typeName)
|(NOT OF)
|(OWNER TO (ownerName | CURRENT_USER | SESSION_USER))
|(REPLICA IDENTITY (DEFAULT | (USING INDEX indexName) | FULL | NOTHING))
;
alterColumnOp:
ALTER COLUMN?
;
alterColumnSetOption:
(SET GENERATED (ALWAYS | BY DEFAULT))
|SET sequenceOption
|(RESTART (WITH? NUMBER)?)
;
attributeOptions:
attributeOption (COMMA attributeOption)*
;
//options:n_distinct and n_distinct_inherited, loosen match
attributeOption:
ID EQ_OR_ASSIGN simpleExpr
;
tableConstraintUsingIndex:
(CONSTRAINT constraintName)?
(UNIQUE | PRIMARY KEY) USING INDEX indexName
constraintOptionalParam
;
constraintOptionalParam:
(NOT? DEFERRABLE)? (INITIALLY (DEFERRED |IMMEDIATE))?
;
privateExprOfDb:
aggregateExpression
|windowFunction
|arrayConstructorWithCast
|(TIMESTAMP (WITH TIME ZONE)? STRING)
;
pgExpr:
|castExpr
|collateExpr
|expr
;
aggregateExpression:
ID (
(LEFT_PAREN (ALL | DISTINCT)? exprs orderByClause? RIGHT_PAREN)
|asteriskWithParen
| (LEFT_PAREN exprs RIGHT_PAREN WITHIN GROUP LEFT_PAREN orderByClause RIGHT_PAREN)
)
filterClause ?
;
filterClause:
FILTER LEFT_PAREN WHERE booleanPrimary RIGHT_PAREN
;
asteriskWithParen:
LEFT_PAREN ASTERISK RIGHT_PAREN
;
windowFunction:
ID (exprsWithParen | asteriskWithParen)
filterClause? windowFunctionWithClause
;
windowFunctionWithClause:
OVER (ID | LEFT_PAREN windowDefinition RIGHT_PAREN )
;
windowDefinition:
ID? (PARTITION BY exprs)?
(orderByExpr (COMMA orderByExpr)*)?
frameClause?
;
orderByExpr:
ORDER BY expr (ASC | DESC | USING operator)? (NULLS (FIRST | LAST ))?
;
frameClause:
((RANGE | ROWS) frameStart)
|(RANGE | ROWS ) BETWEEN frameStart AND frameEnd
;
frameStart:
(UNBOUNDED PRECEDING)
|(NUMBER PRECEDING)
|(CURRENT ROW)
|(NUMBER FOLLOWING)
|(UNBOUNDED FOLLOWING)
;
frameEnd:
frameStart
;
castExpr:
(CAST LEFT_PAREN expr AS dataType RIGHT_PAREN)
|(expr COLON COLON dataType)
;
castExprWithColon:
COLON COLON dataType(LEFT_BRACKET RIGHT_BRACKET)*
;
collateExpr:
expr COLLATE expr
;
arrayConstructorWithCast:
arrayConstructor castExprWithColon?
|(ARRAY LEFT_BRACKET RIGHT_BRACKET castExprWithColon)
;
arrayConstructor:
| ARRAY LEFT_BRACKET exprs RIGHT_BRACKET
| ARRAY LEFT_BRACKET arrayConstructor (COMMA arrayConstructor)* RIGHT_BRACKET
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录