Skip to content

Commit

Permalink
REVOKE ... ON ... SCHEMA ... TO ... throws syntax error (babelfish-fo…
Browse files Browse the repository at this point in the history
…r-postgresql#2341)

Co-authored-by: Shalini Lohia <[email protected]>
  • Loading branch information
shalinilohia50 and lohia-shalini authored Feb 6, 2024
1 parent ad90b5a commit 88ba869
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions contrib/babelfishpg_tsql/src/tsqlIface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ class tsqlBuilder : public tsqlCommonMutator
if (ctx->grant_statement())
{
auto grant = ctx->grant_statement();
if (grant->TO() && !grant->permission_object() && grant->permissions())
if (!grant->permission_object() && grant->permissions())
{
for (auto perm : grant->permissions()->permission())
{
Expand All @@ -1908,7 +1908,7 @@ class tsqlBuilder : public tsqlCommonMutator
}
else if (grant->ON() && grant->permission_object() && grant->permission_object()->object_type() && grant->permission_object()->object_type()->SCHEMA())
{
if (grant->TO() && grant->principals() && grant->permissions())
if (grant->principals() && grant->permissions())
{
for (auto perm: grant->permissions()->permission())
{
Expand All @@ -1930,7 +1930,7 @@ class tsqlBuilder : public tsqlCommonMutator
else if (ctx->revoke_statement())
{
auto revoke = ctx->revoke_statement();
if (revoke->FROM() && !revoke->permission_object() && revoke->permissions())
if (!revoke->permission_object() && revoke->permissions())
{
for (auto perm : revoke->permissions()->permission())
{
Expand All @@ -1945,7 +1945,7 @@ class tsqlBuilder : public tsqlCommonMutator

else if (revoke->ON() && revoke->permission_object() && revoke->permission_object()->object_type() && revoke->permission_object()->object_type()->SCHEMA())
{
if (revoke->FROM() && revoke->principals() && revoke->permissions())
if (revoke->principals() && revoke->permissions())
{
for (auto perm: revoke->permissions()->permission())
{
Expand Down Expand Up @@ -5771,7 +5771,7 @@ makeGrantdbStatement(TSqlParser::Security_statementContext *ctx)
if (ctx->grant_statement())
{
auto grant = ctx->grant_statement();
if (grant->TO() && !grant->permission_object() && grant->permissions())
if (!grant->permission_object() && grant->permissions())
{
for (auto perm : grant->permissions()->permission())
{
Expand Down Expand Up @@ -5804,7 +5804,7 @@ makeGrantdbStatement(TSqlParser::Security_statementContext *ctx)
}
else if (grant->ON() && grant->permission_object() && grant->permission_object()->object_type() && grant->permission_object()->object_type()->SCHEMA())
{
if (grant->TO() && grant->principals() && grant->permissions())
if (grant->principals() && grant->permissions())
{
PLtsql_stmt_grantschema *result = (PLtsql_stmt_grantschema *) palloc0(sizeof(PLtsql_stmt_grantschema));
result->cmd_type = PLTSQL_STMT_GRANTSCHEMA;
Expand Down Expand Up @@ -5864,7 +5864,7 @@ makeGrantdbStatement(TSqlParser::Security_statementContext *ctx)
else if (ctx->revoke_statement())
{
auto revoke = ctx->revoke_statement();
if (revoke->FROM() && !revoke->permission_object() && revoke->permissions())
if (!revoke->permission_object() && revoke->permissions())
{
for (auto perm : revoke->permissions()->permission())
{
Expand Down Expand Up @@ -5899,7 +5899,7 @@ makeGrantdbStatement(TSqlParser::Security_statementContext *ctx)

else if (revoke->ON() && revoke->permission_object() && revoke->permission_object()->object_type() && revoke->permission_object()->object_type()->SCHEMA())
{
if (revoke->FROM() && revoke->principals() && revoke->permissions())
if (revoke->principals() && revoke->permissions())
{
PLtsql_stmt_grantschema *result = (PLtsql_stmt_grantschema *) palloc0(sizeof(PLtsql_stmt_grantschema));
result->cmd_type = PLTSQL_STMT_GRANTSCHEMA;
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/expected/GRANT_SCHEMA.out
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ go
grant select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
go

revoke select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz from babel_4344_u1;
revoke select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
go

grant select on abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/input/GRANT_SCHEMA.mix
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ go
grant select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
go

revoke select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz from babel_4344_u1;
revoke select on schema::abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
go

grant select on abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwzyzabcdefghijklmnopqrstuvwzyz to babel_4344_u1;
Expand Down

0 comments on commit 88ba869

Please sign in to comment.