Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
Signed-off-by: P Aswini Kumar <[email protected]>
  • Loading branch information
P Aswini Kumar committed Sep 13, 2024
1 parent 1c4db0f commit 368e13c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
1 change: 0 additions & 1 deletion contrib/babelfishpg_tsql/src/pltsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,6 @@ extern void update_DropOwnedStmt(Node *n, List *role_list);
extern void update_DropRoleStmt(Node *n, const char *role);
extern void update_DropStmt(Node *n, const char *object);
extern void update_GrantRoleStmt(Node *n, List *privs, List *roles);
extern void update_RevokeRoleStmt(Node *n, List *privs, List *roles);
extern void update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee, const char *priv);
extern void update_RenameStmt(Node *n, const char *old_name, const char *new_name);
extern void update_ViewStmt(Node *n, const char *view_schema);
Expand Down
13 changes: 0 additions & 13 deletions contrib/babelfishpg_tsql/src/pltsql_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,19 +1079,6 @@ update_GrantRoleStmt(Node *n, List *privs, List *roles)
stmt->grantee_roles = roles;
}

void
update_RevokeRoleStmt(Node *n, List *privs, List *roles)
{
GrantRoleStmt *stmt = (GrantRoleStmt *) n;

if (!IsA(stmt, GrantRoleStmt))
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("query is not a RevokeRoleStmt")));

stmt->is_grant = false;
stmt->granted_roles = privs;
stmt->grantee_roles = roles;
}

void
update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee, const char *priv)
{
Expand Down
13 changes: 3 additions & 10 deletions contrib/babelfishpg_tsql/src/rolecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,7 @@ grant_dbo_to_login(const char* login, const char* db_name, bool is_grant)
tmp->location = -1;
tmp->rolename = pstrdup(login);

if (is_grant)
{
update_GrantRoleStmt(stmt, dbo, list_make1(tmp));
}
else
{
update_RevokeRoleStmt(stmt, dbo, list_make1(tmp));
}
update_GrantRoleStmt(stmt, dbo, list_make1(tmp));

/* Run the built query */
/* need to make a wrapper PlannedStmt */
Expand All @@ -643,11 +636,11 @@ grant_dbo_to_login(const char* login, const char* db_name, bool is_grant)
wrapper->canSetTag = false;
wrapper->utilityStmt = stmt;
wrapper->stmt_location = 0;
wrapper->stmt_len = 18;
wrapper->stmt_len = 23;

/* do this step */
ProcessUtility(wrapper,
"(CREATE DATABASE )",
"(ALTER DATABASE OWNER )",
false,
PROCESS_UTILITY_SUBCOMMAND,
NULL,
Expand Down

0 comments on commit 368e13c

Please sign in to comment.