Merge pull request #6941 from timur-sh/6931

[#6931] Added parser support for GRANT OPTION FOR clause
This commit is contained in:
Lukas Eder 2017-12-21 10:57:15 +01:00 committed by GitHub
commit 53ba0efb38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -151,7 +151,16 @@ truncateStatement = 'TRUNCATE TABLE' tableName [ 'CONTINUE IDENTITY' | 'RESTART
grantStatement = 'GRANT' ( 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' ) 'ON' tableName 'TO' ( userName | roleName | 'PUBLIC') [ 'WITH GRANT OPTION' ]
;
revokeStatement = 'REVOKE' ( 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' ) 'ON' tableName 'FROM' ( userName | roleName | 'PUBLIC')
revokeStatement = 'REVOKE'
[ 'GRANT OPTION FOR' ]
(
'SELECT'
| 'INSERT'
| 'UPDATE'
| 'DELETE'
)
'ON' tableName
'FROM' ( userName | roleName | 'PUBLIC')
;
selectStatement = select | values [ correlationName ]

View File

@ -1323,6 +1323,7 @@ class ParserImpl implements Parser {
private static final DDLQuery parseRevoke(ParserContext ctx) {
parseKeyword(ctx, "REVOKE");
boolean grantOptionFor = parseKeywordIf(ctx, "GRANT OPTION FOR");
Privilege privilege = parsePrivilege(ctx);
List<Privilege> privileges = null;
@ -1339,7 +1340,12 @@ class ParserImpl implements Parser {
parseKeywordIf(ctx, "TABLE");
Table<?> table = parseTableName(ctx);
RevokeOnStep s1 = privileges == null ? ctx.dsl.revoke(privilege) : ctx.dsl.revoke(privileges);
RevokeOnStep s1 = null;
if (grantOptionFor)
s1 = privileges == null ? ctx.dsl.revokeGrantOptionFor(privilege) : ctx.dsl.revokeGrantOptionFor(privileges);
else
s1 = privileges == null ? ctx.dsl.revoke(privilege) : ctx.dsl.revoke(privileges);
parseKeyword(ctx, "FROM");
User user = parseKeywordIf(ctx, "PUBLIC") ? null : parseUser(ctx);