Skip to content

Commit

Permalink
Grant update on objects created on older version
Browse files Browse the repository at this point in the history
  • Loading branch information
lohia-shalini committed Dec 5, 2024
1 parent 5146d8b commit d8edc4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contrib/babelfishpg_tsql/src/dbcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ grant_perms_to_dbreader_dbwriter_ddladmin(const uint16 dbid,
initStringInfo(&query);
appendStringInfo(&query, "GRANT SELECT ON ALL TABLES IN SCHEMA dummy TO dummy; ");
appendStringInfo(&query, "GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA dummy TO dummy; ");
appendStringInfo(&query, "GRANT UPDATE ON ALL SEQUENCES IN SCHEMA dummy TO dummy; ");
appendStringInfo(&query, "GRANT TRUNCATE ON ALL TABLES IN SCHEMA dummy TO dummy; ");
appendStringInfo(&query, "GRANT CREATE ON SCHEMA dummy TO dummy ; ");

Expand All @@ -1414,7 +1415,7 @@ grant_perms_to_dbreader_dbwriter_ddladmin(const uint16 dbid,

stmt_list = raw_parser(query.data, RAW_PARSE_DEFAULT);

Assert(list_length(stmt_list) == 8);
Assert(list_length(stmt_list) == 9);

ScanKeyInit(&key,
Anum_namespace_ext_dbid,
Expand Down Expand Up @@ -1445,6 +1446,8 @@ grant_perms_to_dbreader_dbwriter_ddladmin(const uint16 dbid,
stmts = parsetree_nth_stmt(stmt_list, i++);
update_GrantStmt(stmts, schema_name, NULL, db_datawriter, NULL);
stmts = parsetree_nth_stmt(stmt_list, i++);
update_GrantStmt(stmts, schema_name, NULL, db_datawriter, NULL);
stmts = parsetree_nth_stmt(stmt_list, i++);
update_GrantStmt(stmts, schema_name, NULL, db_ddladmin, NULL);
stmts = parsetree_nth_stmt(stmt_list, i++);
update_GrantStmt(stmts, schema_name, NULL, db_ddladmin, NULL);
Expand Down
8 changes: 8 additions & 0 deletions test/JDBC/expected/datareader_datawriter-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ int
~~END~~


SELECT NEXT VALUE FOR db_roles_schema_1.before_sq1; -- allowed
go
~~START~~
bigint
1
~~END~~


insert into db_roles_schema_1.before_t1 values(1); -- allowed
go
~~ROW COUNT: 1~~
Expand Down
3 changes: 3 additions & 0 deletions test/JDBC/input/datareader_datawriter-vu-verify.mix
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ go
select * from db_roles_schema_1.after_v2; -- allowed
go

SELECT NEXT VALUE FOR db_roles_schema_1.before_sq1; -- allowed
go

insert into db_roles_schema_1.before_t1 values(1); -- allowed
go

Expand Down

0 comments on commit d8edc4f

Please sign in to comment.