You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/30 07:53:13 UTC

[GitHub] [shardingsphere] happybyr opened a new pull request #6529: alter_antlr_7_30

happybyr opened a new pull request #6529:
URL: https://github.com/apache/shardingsphere/pull/6529


   Fixes #ISSUSE_ID.
   
   Changes proposed in this pull request:
   -
   -
   -
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on pull request #6529: alter_antlr_7_30

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on pull request #6529:
URL: https://github.com/apache/shardingsphere/pull/6529#issuecomment-666941463


   @happybyr Plz check keyword, such as `public` is not a keyword, and delete action code, and check alterTable grammar.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #6529: alter_antlr_7_30

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #6529:
URL: https://github.com/apache/shardingsphere/pull/6529#discussion_r463420733



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
##########
@@ -1351,3 +1404,170 @@ ignoredIdentifier_
 ignoredIdentifiers_
     : ignoredIdentifier_ (COMMA_ ignoredIdentifier_)*
     ;
+
+nonReservedWord
+    : unreservedWord
+    | colNameKeyword
+    | typeFuncNameKeyword
+    ;
+
+aggregateName
+    : name
+    ;
+
+databaseName
+    : colId
+    ;
+
+optBoolean
+    : TRUE | FALSE
+    ;
+
+varName
+    : colId
+    | varName DOT_ colId
+    ;
+
+varList
+    : varValue
+    | varList COMMA_ varValue
+    ;
+
+varValue
+    : identifier
+    ;
+
+roleSpec
+    : identifier
+    | nonReservedWord
+    | CURRENT_USER
+    | SESSION_USER
+    ;
+
+columnElem
+    : colId
+    ;
+
+columnList
+    : columnElem
+    | columnList COMMA_ columnElem
+    ;
+
+accessMethod
+    : colId
+    ;
+
+funcArgs
+    : LP_ funcArgList RP_
+    | LP_ RP_
+    ;
+
+numericOnly
+    : NUMBER_
+    | PLUS_ NUMBER_
+    | MINUS_ NUMBER_
+    ;
+
+zoneValue
+    : STRING_
+    | identifier
+    | INTERVAL STRING_ optInterval
+    | INTERVAL LP_ INT_ RP_ STRING_
+    | numericOnly
+    | DEFAULT
+    | LOCAL
+    ;
+
+funcArg
+    : argClass paramName funcType
+    | paramName argClass funcType
+    | paramName funcType
+    | argClass funcType
+    | funcType
+    ;
+
+argClass
+    : IN
+    | OUT
+    | INOUT
+    | IN OUT
+    | VARIADIC
+    ;
+
+funcArgsList
+    : funcArg
+    | funcArgsList COMMA_ funcArg
+    ;
+
+columnDef
+    : colId typeName create_generic_options colQualList
+    ;
+
+colQualList
+    : colConstraint*
+    ;
+
+colConstraint
+    : CONSTRAINT name colConstraintElem
+    | colConstraintElem
+    | constraintAttr
+    | COLLATE anyName
+    ;
+
+colConstraintElem
+    : NOT NULL
+    | NULL
+    | UNIQUE opt_definition OptConsTableSpace
+    | PRIMARY KEY opt_definition OptConsTableSpace
+    | CHECK LP_ aExpr RP_ opt_no_inherit
+    | DEFAULT bExpr
+    | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
+    | GENERATED generated_when AS LP_ aExpr RP_ STORED
+    | REFERENCES qualified_name opt_column_list key_match key_actions
+    ;
+
+opt_definition
+    : (WITH definition)?
+    ;
+
+definition
+    : LP_ def_list RP_
+    ;
+
+def_list
+    : def_elem
+    | def_list COMMA_ def_elem
+    ;
+
+def_elem
+    : colLabel  def_arg
+      				{
+      					$$ = makeDefElem($1, (Node *) $3, @1);
+      				}
+      			| ColLabel
+    ;
+
+colLabel
+    :
+    ;
+
+create_generic_options
+    : ( OPTIONS LP_ generic_option_list RP_ )?
+    ;
+
+generic_option_list
+    : generic_option_elem
+    | generic_option_list COMMA_ generic_option_elem
+    ;
+
+generic_option_elem
+    : generic_option_name generic_option_arg
+    ;
+
+generic_option_arg
+    : STRING_
+    ;
+
+generic_option_name
+    : colLable
+    ;

Review comment:
       There should be a blank line at the end of the file.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4
##########
@@ -305,3 +305,556 @@ indexExistClause_
 indexNames
     : indexName (COMMA_ indexName)*
     ;
+
+alterAggregate
+    : ALTER AGGREGATE aggregateName LP_ aggregateSignature RP_ alterAggregateDefinitionClause
+    ;
+
+aggregateSignature
+    : ASTERISK_
+    | aggregateArgsList
+    | (aggregateArgsList)? ORDER BY aggregateArgsList
+    ;
+
+alterAggregateDefinitionClause
+    : RENAME TO aggregateName
+    | OWNER TO  (owner | CURRENT_USER | SESSION_USER)
+    | SET SCHEMA schemaName
+    ;
+
+aggregateArgsList
+    : aggregateArgs (COMMA_ aggregateArgs)*
+    ;
+
+aggregateArgs
+    : argMode? argName? argType
+    ;
+
+argType
+    : dataTypeName
+    ;
+
+argName
+    : name
+    ;
+
+argMode
+    : IN
+    | VARIADIC
+    ;
+
+alterCollation
+    : ALTER COLLATION anyName alterCollationClause
+    ;
+
+alterCollationClause
+    : REFRESH VERSION
+    | RENAME TO anyName
+    | OWNER TO (ignoredIdentifier_ | CURRENT_USER | SESSION_USER)
+    | SET SCHEMA schemaName
+    ;
+
+alterConversion
+    : ALTER CONVERSION anyName alterConversionClause
+    ;
+
+alterConversionClause
+    : RENAME TO anyName
+    | OWNER TO (ignoredIdentifier_ | CURRENT_USER | SESSION_USER)
+    | SET SCHEMA schemaName
+    ;
+
+alterDatabase
+    : ALTER DATABASE databaseName alterDatabaseClause
+    ;
+
+alterDatabaseClause
+    : alterDatabaseConnectionOptions
+    | RENAME TO databaseName
+    | OWNER TO (ignoredIdentifier_ | CURRENT_USER | SESSION_USER)
+    | SET TABLESPACE name
+    | SET varName (TO | EQ_) (varList | DEFAULT)
+    | SET varName FROM CURRENT
+    | RESET varName
+    | RESET ALL
+    ;
+
+alterDatabaseConnectionOptions
+    : (WITH)? dbOptionList
+    ;
+
+dbOptionList
+    : dbOptionItem
+    | dbOptionList dbOptionItem
+    ;
+
+dbOptionItem
+    : ALLOW_CONNECTIONS allowConnections
+    | CONNECTION LIMIT connlimit
+    | IS_TEMPLATE istemplate
+    ;
+
+istemplate
+    : optBoolean
+    ;
+
+connlimit
+    : INT_
+    ;
+
+allowConnections
+    : optBoolean
+    ;
+
+alterDefaultPrivileges
+    : ALTER DEFAULT PRIVILEGES (defACLOptionList)? defACLAction
+    ;
+
+defACLAction
+    : GRANT privileges ON defaclPrivilegeTarget TO granteeList optGrantGrantOption?
+    | REVOKE privileges ON defaclPrivilegeTarget FROM granteeList optDropBehavior?
+    | REVOKE GRANT OPTION FOR privileges ON defaclPrivilegeTarget FROM granteeList optDropBehavior?
+    ;
+
+optDropBehavior
+    : CASCADE
+    | RESTRICT
+    ;
+
+optGrantGrantOption
+    : (WITH GRANT OPTION)?
+    ;
+
+granteeList
+    : grantee
+    | granteeList COMMA_ grantee
+    ;
+
+grantee
+    : GROUP? roleSpec
+    ;
+
+defaclPrivilegeTarget
+    :TABLES
+    | FUNCTIONS
+    | ROUTINES
+    | SEQUENCES
+    | TYPES_P
+    | SCHEMAS
+    ;
+
+privileges
+    : privilegeList
+    | ALL
+    | ALL PRIVILEGES
+    | ALL LP_ columnList RP_
+    | ALL PRIVILEGES LP_ columnList RP_
+    ;
+
+privilegeList
+    : privilege
+    | privilegeList COMMA_ privilege
+    ;
+
+privilege
+    : SELECT (optColumnList)?
+    | REFERENCES (optColumnList)?
+    | CREATE (optColumnList)?
+    | colId (optColumnList)?
+    ;
+
+optColumnList
+    : LP_ columnList RP_
+    ;
+
+defACLOptionList
+    : defACLOptionList defACLOption
+    | defACLOption
+    ;
+
+defACLOption
+    : IN SCHEMA schemaNameList
+    | FOR (ROLE | USER) roleList
+    ;
+
+roleList
+    : roleSpec
+    | roleList COMMA_ roleSpec
+    ;
+
+schemaNameList
+    : nameList
+    ;
+//TODO
+alterDomain
+    : ALTER DOMAIN anyName alterDomainClause
+    ;
+
+alterDomainClause
+    : (SET DEFAULT aExpr | DROP DEFAULT)
+    | (SET | DROP) NOT NULL
+    | ADD domainConstraint (NOT VALID)?
+    | DROP CONSTRAINT (IF EXISTS)? constraintName (RESTRICT | CASCADE)?
+    | RENAME CONSTRAINT constraintName TO constraintName
+    | VALIDATE CONSTRAINT constraintName
+    | OWNER TO (ignoredIdentifier_ | CURRENT_USER | SESSION_USER)
+    | RENAME TO anyName
+    | SET SCHEMA name
+    ;
+
+domainConstraint
+    : CONSTRAINT colId constraintElem
+    | constraintElem
+    ;
+
+constraintElem
+    : CHECK LP_ aExpr RP_ constraintAttributeSpec?
+    | UNIQUE LP_ columnList RP_ opt_c_include? opt_definition? optConsTableSpace? constraintAttributeSpec?
+    | UNIQUE existingIndex constraintAttributeSpec?
+    | PRIMARY KEY LP_ columnList RP_ opt_c_include? opt_definition? optConsTableSpace? constraintAttributeSpec?
+    | PRIMARY KEY existingIndex constraintAttributeSpec?
+//    | EXCLUDE access_method_clause? LP_ exclusionConstraintList RP_ opt_c_include? opt_definition? optConsTableSpace?  exclusionWhereClause constraintAttributeSpec?
+//    | FOREIGN KEY LP_ columnList RP_ REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
+    ;
+
+exclusionConstraintList
+    :
+    ;
+
+access_method_clause
+    : USING accessMethod
+    ;
+
+existingIndex
+    : USING INDEX indexName
+    ;
+
+optConsTableSpace
+    : USING INDEX TABLESPACE name
+    ;
+
+opt_definition
+    : WITH definition
+    ;
+
+definition
+    : LP_ def_list RP_
+    ;
+
+def_list
+    : def_elem
+    | def_list COMMA_ def_elem
+    ;
+
+def_elem
+    : colLable EQ_ defArg
+    | colLable
+    ;
+
+opt_c_include
+    : INCLUDE LP_ columnList RP_
+    ;
+
+constraintAttributeSpec
+    : constraintAttributeElem*
+    ;
+
+constraintAttributeElem
+    : NOT DEFERRABLE
+    | DEFERRABLE
+    | INITIALLY IMMEDIATE
+    | INITIALLY DEFERRED
+    | NOT VALID
+    | NO INHERIT
+    ;
+
+constraintName
+    : colId
+    ;
+
+alterEventTrigger
+    : ALTER EVENT TRIGGER tiggerName alterEventTriggerClause
+    ;
+
+alterEventTriggerClause
+    : DISABLE
+    | ENABLE (REPLICA | ALWAYS)
+    | OWNER TO (ignoredIdentifier_ | CURRENT_USER | SESSION_USER)
+    | RENAME TO tiggerName
+    ;
+
+tiggerName
+    : colId
+    ;
+
+//TODO
+alterExtension
+    : ALTER EXTENSION colId
+    ;
+
+alterForeignDataWrapper
+    : ALTER FOREIGN DATA WRAPPER colId alterForeignDataWrapperClauses
+    ;
+
+alterForeignDataWrapperClauses
+    : opt_fdw_options alter_generic_options
+    | fdw_options
+    ;
+
+alter_generic_options
+    : OPTIONS LP_ alter_generic_option_list RP_
+    ;
+
+alter_generic_option_list
+    : alter_generic_option_elem
+    | alter_generic_option_list COMMA_ alter_generic_option_elem
+    ;
+
+alter_generic_option_elem
+    : generic_option_elem
+    | SET generic_option_elem
+    | ADD generic_option_elem
+    | DROP generic_option_name
+    ;
+
+generic_option_name
+    : colLable
+    ;
+
+generic_option_elem
+    : generic_option_name generic_option_arg
+    ;
+
+generic_option_arg
+    : aexprConst
+    ;
+
+fdw_options
+    : fdw_option+
+    ;
+
+fdw_option
+    : HANDLER handler_name
+    | NO HANDLER
+    | VALIDATOR handler_name
+    | NO VALIDATOR
+    ;
+
+handler_name
+    : anyName
+    ;
+

Review comment:
       Use hump naming format

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
##########
@@ -316,6 +316,7 @@ unreservedWord
     | PROCEDURE
     | PROCEDURES
     | PROGRAM
+    | PUBLIC

Review comment:
       `public` is not a keyword.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
##########
@@ -1351,3 +1404,170 @@ ignoredIdentifier_
 ignoredIdentifiers_
     : ignoredIdentifier_ (COMMA_ ignoredIdentifier_)*
     ;
+
+nonReservedWord
+    : unreservedWord
+    | colNameKeyword
+    | typeFuncNameKeyword
+    ;
+
+aggregateName
+    : name
+    ;
+
+databaseName
+    : colId
+    ;
+
+optBoolean
+    : TRUE | FALSE
+    ;
+
+varName
+    : colId
+    | varName DOT_ colId
+    ;
+
+varList
+    : varValue
+    | varList COMMA_ varValue
+    ;
+
+varValue
+    : identifier
+    ;
+
+roleSpec
+    : identifier
+    | nonReservedWord
+    | CURRENT_USER
+    | SESSION_USER
+    ;
+
+columnElem
+    : colId
+    ;
+
+columnList
+    : columnElem
+    | columnList COMMA_ columnElem
+    ;
+
+accessMethod
+    : colId
+    ;
+
+funcArgs
+    : LP_ funcArgList RP_
+    | LP_ RP_
+    ;
+
+numericOnly
+    : NUMBER_
+    | PLUS_ NUMBER_
+    | MINUS_ NUMBER_
+    ;
+
+zoneValue
+    : STRING_
+    | identifier
+    | INTERVAL STRING_ optInterval
+    | INTERVAL LP_ INT_ RP_ STRING_
+    | numericOnly
+    | DEFAULT
+    | LOCAL
+    ;
+
+funcArg
+    : argClass paramName funcType
+    | paramName argClass funcType
+    | paramName funcType
+    | argClass funcType
+    | funcType
+    ;
+
+argClass
+    : IN
+    | OUT
+    | INOUT
+    | IN OUT
+    | VARIADIC
+    ;
+
+funcArgsList
+    : funcArg
+    | funcArgsList COMMA_ funcArg
+    ;
+
+columnDef
+    : colId typeName create_generic_options colQualList
+    ;
+
+colQualList
+    : colConstraint*
+    ;
+
+colConstraint
+    : CONSTRAINT name colConstraintElem
+    | colConstraintElem
+    | constraintAttr
+    | COLLATE anyName
+    ;
+
+colConstraintElem
+    : NOT NULL
+    | NULL
+    | UNIQUE opt_definition OptConsTableSpace
+    | PRIMARY KEY opt_definition OptConsTableSpace
+    | CHECK LP_ aExpr RP_ opt_no_inherit
+    | DEFAULT bExpr
+    | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
+    | GENERATED generated_when AS LP_ aExpr RP_ STORED
+    | REFERENCES qualified_name opt_column_list key_match key_actions
+    ;
+
+opt_definition
+    : (WITH definition)?
+    ;
+
+definition
+    : LP_ def_list RP_
+    ;
+
+def_list
+    : def_elem
+    | def_list COMMA_ def_elem
+    ;
+
+def_elem
+    : colLabel  def_arg
+      				{
+      					$$ = makeDefElem($1, (Node *) $3, @1);
+      				}
+      			| ColLabel

Review comment:
       delete action code.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu closed pull request #6529: alter_antlr_7_30

Posted by GitBox <gi...@apache.org>.
jingshanglu closed pull request #6529:
URL: https://github.com/apache/shardingsphere/pull/6529


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org