[#6931] Added parser support for GRANT OPTION FOR clause

This commit is contained in:
Timur Shaidullin 2017-12-20 17:55:27 +03:00
parent 12a9c0e696
commit c19ab98047
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')
;
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

@ -1318,6 +1318,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;
@ -1334,7 +1335,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);