Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds parameter grant/revoke propagation support #7421

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

gurkanindibay
Copy link
Contributor

@gurkanindibay gurkanindibay commented Jan 15, 2024

DESCRIPTION: Adds parameter grant propagation support

Below commands are supported
GRANT { { SET | ALTER SYSTEM } [, ... ] | ALL [ PRIVILEGES ] }
ON PARAMETER configuration_parameter [, ...]
TO role_specification [, ...] [ WITH GRANT OPTION ]
[ GRANTED BY role_specification ]
REVOKE [ GRANT OPTION FOR ]
{ { SET | ALTER SYSTEM } [, ...] | ALL [ PRIVILEGES ] }
ON PARAMETER configuration_parameter [, ...]
FROM role_specification [, ...]
[ GRANTED BY role_specification ]
[ CASCADE | RESTRICT ]

@gurkanindibay gurkanindibay marked this pull request as draft January 15, 2024 08:37
@gurkanindibay gurkanindibay changed the title Adds parameter grant propagation support Adds parameter grant/revoke propagation support Jan 17, 2024
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Merging #7421 (c4c7194) into main (d59c93b) will decrease coverage by 0.03%.
The diff coverage is 91.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7421      +/-   ##
==========================================
- Coverage   89.71%   89.69%   -0.03%     
==========================================
  Files         282      284       +2     
  Lines       60581    60547      -34     
  Branches     7541     7537       -4     
==========================================
- Hits        54350    54306      -44     
- Misses       4076     4085       +9     
- Partials     2155     2156       +1     

@gurkanindibay gurkanindibay marked this pull request as ready for review January 17, 2024 12:48
(void *) command,
ENABLE_DDL_PROPAGATION);

return NontransactionalNodeDDLTaskList(REMOTE_NODES, commands);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why non-transactional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not required to be non-transactional. Changed it with NodeDDLTask

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you first perform a self-review on this PR because apparently there are some missing things in the PR that we've already discussed before in some other PRs: function comments, usual simplifications that can be made in code, style used in comments / name of the functions etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked on and added the missing things that I can see

Comment on lines 80 to 93
AclResult aclresult = pg_parameter_aclcheck(parameterName, granteeOid, mode);
if (aclresult == ACLCHECK_OK)
{
char *query = DeparseTreeNode((Node *) GenerateGrantStmtForRightsWithObjectName(
OBJECT_PARAMETER_ACL, granteeOid, parameterName,
modeStr,
HasAclGrantOption(aclItem, mode)));

/* remove the semicolon at the end of the query since it is already */
/* appended in metadata_sync phase */
query[strlen(query) - 1] = '\0';

*queries = lappend(*queries, query);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially cannot quite follow what's happening here, could you simplify GenerateGrantOnParameterFromAclItem & CheckAndAppendQuery a bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified and added comments renamed functions and added some additional functions.

Comment on lines +107 to +119
/*
* RemoveSemicolonFromEnd removes the semicolon at the end of the query if it exists.
*/
static void
RemoveSemicolonFromEnd(char *query)
{
/* remove the semicolon at the end of the query since it is already */
/* appended in metadata_sync phase */
if (query[strlen(query) - 1] == ';')
{
query[strlen(query) - 1] = '\0';
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's okay to have multiple ; at the end of the query, so maybe just remove this because we're anyway experiencing this in other code-paths too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants