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

Fix bugs for GRANT/REVOKE on SCHEMA #2031

Merged

Conversation

shalinilohia50
Copy link
Contributor

@shalinilohia50 shalinilohia50 commented Nov 17, 2023

Description

Bug fixes for GRANT/REVOKE .. ON SCHEMA

  1. Server crash when using empty bracketed name. schema::[]
  2. Server crash when using empty quoted identifier. schema::""
  3. When granting permission to yourself, we need a different error message.
  4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
  5. Not-supported object type in error message should be in uppercase
  6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
  7. Specified collation for column names using NAME datatype

Issues Resolved

JIRA: BABEL-4344
Signed-off-by: Shalini Lohia [email protected]

Test Scenarios Covered

  • Use case based - Added

  • Boundary conditions -

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@shalinilohia50 shalinilohia50 requested review from Deepesh125, kuntalghosh and xhfanhe and removed request for Deepesh125 November 17, 2023 08:37
xhfanhe
xhfanhe previously approved these changes Nov 17, 2023
xhfanhe
xhfanhe previously approved these changes Nov 17, 2023
Deepesh125
Deepesh125 previously approved these changes Nov 20, 2023
Copy link
Contributor

@Deepesh125 Deepesh125 left a comment

Choose a reason for hiding this comment

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

Collations changes looks okay to me!

contrib/babelfishpg_tsql/src/catalog.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_exec-2.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_exec-2.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_exec-2.c Show resolved Hide resolved
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("Cannot find the principal '%s', because it does not exist or you do not have permission.", grantee_name)));

if (pg_namespace_ownercheck(schemaOid, role_oid) || is_member_of_role(role_oid, datdba) || grantee_is_db_owner)
if ((strcmp(rolname, user) == 0) || pg_namespace_ownercheck(schemaOid, role_oid) || is_member_of_role(role_oid, get_sysadmin_oid()) || grantee_is_db_owner)
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this work for multi-db?
(strcmp(rolname, user) == 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you suggest a case which might fail?
I have ran the test framework in both single-db and multi-db mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

How is user = public ever possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is not possible. User will not be public.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rolname can be public, but not user.

contrib/babelfishpg_tsql/src/tsqlIface.cpp Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_handler.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_handler.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Outdated Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/catalog.c Show resolved Hide resolved
contrib/babelfishpg_tsql/src/pl_handler.c Outdated Show resolved Hide resolved
kuntalghosh
kuntalghosh previously approved these changes Nov 21, 2023
contrib/babelfishpg_tsql/src/catalog.h Outdated Show resolved Hide resolved
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("Cannot find the principal '%s', because it does not exist or you do not have permission.", grantee_name)));

if (pg_namespace_ownercheck(schemaOid, role_oid) || is_member_of_role(role_oid, datdba) || grantee_is_db_owner)
if ((strcmp(rolname, user) == 0) || pg_namespace_ownercheck(schemaOid, role_oid) || is_member_of_role(role_oid, get_sysadmin_oid()) || grantee_is_db_owner)
Copy link
Contributor

Choose a reason for hiding this comment

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

How is user = public ever possible?

@shardgupta shardgupta merged commit dd23da9 into babelfish-for-postgresql:BABEL_3_X_DEV Nov 21, 2023
29 checks passed
@shardgupta shardgupta deleted the fix-bugs-4344 branch November 21, 2023 11:15
shalinilohia50 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Nov 21, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
shalinilohia50 pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Nov 22, 2023
forestkeeper pushed a commit that referenced this pull request Nov 22, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 21, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 21, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 24, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 28, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 28, 2023
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 28, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
Sairakan pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 28, 2023
priyansx pushed a commit that referenced this pull request Dec 29, 2023
Bug fixes  for GRANT/REVOKE .. ON SCHEMA

1. Server crash when using empty bracketed name.  `schema::[]`
2. Server crash when using empty quoted identifier. `schema::""`
3. When granting permission to yourself, we need a different error message.
4. Error message in not-supported multi-keyword permission should (i) be in uppercase (ii) have a space between keywords
5. Not-supported object type in error message should be in uppercase
6. GRANT ON SCHEMA:: TO PUBLIC does not take effect
7. Specified collation for column names using NAME datatype

Issues Resolved : BABEL-4344

Signed-off-by: Shalini Lohia <[email protected]>
priyansx pushed a commit that referenced this pull request Dec 29, 2023
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.

7 participants