diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DCLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DCLStatement.g4 index 9bec7c75a0637..9452bd3b719b8 100644 --- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DCLStatement.g4 +++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DCLStatement.g4 @@ -27,73 +27,10 @@ revoke : REVOKE optionForClause? (privilegeClause | roleClause) (CASCADE | RESTRICT)? ; -privilegeClause - : privilegeTypes ON onObjectClause (FROM | TO) granteeList (WITH GRANT OPTION)? - ; - -roleClause - : privilegeList (FROM | TO) roleList (WITH ADMIN OPTION)? (GRANTED BY roleSpec)? - ; - optionForClause : (GRANT | ADMIN) OPTION FOR ; -privilegeTypes - : privilegeType columnNames? (COMMA_ privilegeType columnNames?)* - ; - -privilegeType - : SELECT - | INSERT - | UPDATE - | DELETE - | TRUNCATE - | REFERENCES - | TRIGGER - | CREATE - | CONNECT - | TEMPORARY - | TEMP - | EXECUTE - | USAGE - | ALL PRIVILEGES? - ; - -onObjectClause - : DATABASE nameList - | SCHEMA nameList - | DOMAIN anyNameList - | FUNCTION functionWithArgtypesList - | PROCEDURE functionWithArgtypesList - | ROUTINE functionWithArgtypesList - | LANGUAGE nameList - | LARGE OBJECT numericOnlyList - | TABLESPACE nameList - | TYPE anyNameList - | SEQUENCE qualifiedNameList - | TABLE? privilegeLevel - | FOREIGN DATA WRAPPER nameList - | FOREIGN SERVER nameList - | ALL TABLES IN SCHEMA nameList - | ALL SEQUENCES IN SCHEMA nameList - | ALL FUNCTIONS IN SCHEMA nameList - | ALL PROCEDURES IN SCHEMA nameList - | ALL ROUTINES IN SCHEMA nameList - ; - -privilegeLevel - : ASTERISK_ | ASTERISK_ DOT_ASTERISK_ | identifier DOT_ASTERISK_ | tableNames | schemaName DOT_ routineName - ; - -routineName - : identifier - ; - -numericOnlyList - : numericOnly (COMMA_ numericOnly)* - ; - createUser : CREATE USER roleSpec WITH? createOptRoleElem* ; @@ -161,4 +98,3 @@ dropDroup reassignOwned : REASSIGN OWNED BY roleList TO roleSpec ; - diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 index 9068981d9afda..40f7d1905ccb6 100644 --- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 +++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 @@ -1869,7 +1869,74 @@ schemaEltList schemaStmt : createTable | createIndex | createSequence | createTrigger | grant | createView - ; + ; + +grant + : GRANT (privilegeClause | roleClause) + ; + +privilegeClause + : privilegeTypes ON onObjectClause (FROM | TO) granteeList (WITH GRANT OPTION)? + ; + +roleClause + : privilegeList (FROM | TO) roleList (WITH ADMIN OPTION)? (GRANTED BY roleSpec)? + ; + +privilegeTypes + : privilegeType columnNames? (COMMA_ privilegeType columnNames?)* + ; + +onObjectClause + : DATABASE nameList + | SCHEMA nameList + | DOMAIN anyNameList + | FUNCTION functionWithArgtypesList + | PROCEDURE functionWithArgtypesList + | ROUTINE functionWithArgtypesList + | LANGUAGE nameList + | LARGE OBJECT numericOnlyList + | TABLESPACE nameList + | TYPE anyNameList + | SEQUENCE qualifiedNameList + | TABLE? privilegeLevel + | FOREIGN DATA WRAPPER nameList + | FOREIGN SERVER nameList + | ALL TABLES IN SCHEMA nameList + | ALL SEQUENCES IN SCHEMA nameList + | ALL FUNCTIONS IN SCHEMA nameList + | ALL PROCEDURES IN SCHEMA nameList + | ALL ROUTINES IN SCHEMA nameList + ; + +numericOnlyList + : numericOnly (COMMA_ numericOnly)* + ; + +privilegeLevel + : ASTERISK_ | ASTERISK_ DOT_ASTERISK_ | identifier DOT_ASTERISK_ | tableNames | schemaName DOT_ routineName + ; + +routineName + : identifier + ; + +privilegeType + : SELECT + | INSERT + | UPDATE + | DELETE + | TRUNCATE + | REFERENCES + | TRIGGER + | CREATE + | CONNECT + | TEMPORARY + | TEMP + | EXECUTE + | USAGE + | ALL PRIVILEGES? + ; alterSchema : ALTER SCHEMA name (RENAME TO name | OWNER TO roleSpec) diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4 index dae89e624354a..8d5830ccd4094 100644 --- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4 +++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DCLStatement.g4 @@ -29,73 +29,10 @@ revoke : REVOKE optionForClause? (privilegeClause | roleClause) (CASCADE | RESTRICT)? ; -privilegeClause - : privilegeTypes ON onObjectClause (FROM | TO) granteeList (WITH GRANT OPTION)? - ; - -roleClause - : privilegeList (FROM | TO) roleList (WITH ADMIN OPTION)? (GRANTED BY roleSpec)? - ; - optionForClause : (GRANT | ADMIN) OPTION FOR ; -privilegeTypes - : privilegeType columnNames? (COMMA_ privilegeType columnNames?)* - ; - -privilegeType - : SELECT - | INSERT - | UPDATE - | DELETE - | TRUNCATE - | REFERENCES - | TRIGGER - | CREATE - | CONNECT - | TEMPORARY - | TEMP - | EXECUTE - | USAGE - | ALL PRIVILEGES? - ; - -onObjectClause - : DATABASE nameList - | SCHEMA nameList - | DOMAIN anyNameList - | FUNCTION functionWithArgtypesList - | PROCEDURE functionWithArgtypesList - | ROUTINE functionWithArgtypesList - | LANGUAGE nameList - | LARGE OBJECT numericOnlyList - | TABLESPACE nameList - | TYPE anyNameList - | SEQUENCE qualifiedNameList - | TABLE? privilegeLevel - | FOREIGN DATA WRAPPER nameList - | FOREIGN SERVER nameList - | ALL TABLES IN SCHEMA nameList - | ALL SEQUENCES IN SCHEMA nameList - | ALL FUNCTIONS IN SCHEMA nameList - | ALL PROCEDURES IN SCHEMA nameList - | ALL ROUTINES IN SCHEMA nameList - ; - -privilegeLevel - : ASTERISK_ | ASTERISK_ DOT_ASTERISK_ | identifier DOT_ASTERISK_ | tableNames | schemaName DOT_ routineName - ; - -routineName - : identifier - ; - -numericOnlyList - : numericOnly (COMMA_ numericOnly)* - ; - createUser : CREATE USER roleSpec WITH? createOptRoleElem* ; diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4 index c5b713fb0e1fb..77d5825a2841c 100644 --- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4 +++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DDLStatement.g4 @@ -1883,6 +1883,73 @@ schemaStmt : createTable | createIndex | createSequence | createTrigger | grant | createView ; +grant + : GRANT (privilegeClause | roleClause) + ; + +privilegeClause + : privilegeTypes ON onObjectClause (FROM | TO) granteeList (WITH GRANT OPTION)? + ; + +roleClause + : privilegeList (FROM | TO) roleList (WITH ADMIN OPTION)? (GRANTED BY roleSpec)? + ; + +privilegeTypes + : privilegeType columnNames? (COMMA_ privilegeType columnNames?)* + ; + +onObjectClause + : DATABASE nameList + | SCHEMA nameList + | DOMAIN anyNameList + | FUNCTION functionWithArgtypesList + | PROCEDURE functionWithArgtypesList + | ROUTINE functionWithArgtypesList + | LANGUAGE nameList + | LARGE OBJECT numericOnlyList + | TABLESPACE nameList + | TYPE anyNameList + | SEQUENCE qualifiedNameList + | TABLE? privilegeLevel + | FOREIGN DATA WRAPPER nameList + | FOREIGN SERVER nameList + | ALL TABLES IN SCHEMA nameList + | ALL SEQUENCES IN SCHEMA nameList + | ALL FUNCTIONS IN SCHEMA nameList + | ALL PROCEDURES IN SCHEMA nameList + | ALL ROUTINES IN SCHEMA nameList + ; + +numericOnlyList + : numericOnly (COMMA_ numericOnly)* + ; + +privilegeLevel + : ASTERISK_ | ASTERISK_ DOT_ASTERISK_ | identifier DOT_ASTERISK_ | tableNames | schemaName DOT_ routineName + ; + +routineName + : identifier + ; + +privilegeType + : SELECT + | INSERT + | UPDATE + | DELETE + | TRUNCATE + | REFERENCES + | TRIGGER + | CREATE + | CONNECT + | TEMPORARY + | TEMP + | EXECUTE + | USAGE + | ALL PRIVILEGES? + ; + alterSchema : ALTER SCHEMA name (RENAME TO name | OWNER TO roleSpec) ; diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-schema.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-schema.xml index 2310e909cfa14..8f452d7393bd6 100644 --- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-schema.xml +++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-schema.xml @@ -17,6 +17,7 @@ --> - + + diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-schema.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-schema.xml index d635aa741b215..4ee3d2e9a61f0 100644 --- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-schema.xml +++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-schema.xml @@ -17,9 +17,10 @@ --> - + - +