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

Implements CREATE POLICY syntax for PostgreSQL #1440

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

git-hulk
Copy link
Member

This PR implements part of the feature mentioned in #1404, and introduce two keywords:

  • PERMISSIVE
  • RESTRICTIVE

The following the syntax:

CREATE POLICY name ON table_name
    [ AS { PERMISSIVE | RESTRICTIVE } ]
    [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
    [ TO { role_name | PUBLIC | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] ]
    [ USING ( using_expression ) ]
    [ WITH CHECK ( check_expression ) ]

For the documentation, please refer:

https://www.postgresql.org/docs/current/sql-createpolicy.html

This PR implements part of feature mentioned in apache#1404.

The following the syntax:

```SQL
CREATE POLICY name ON table_name
    [ AS { PERMISSIVE | RESTRICTIVE } ]
    [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
    [ TO { role_name | PUBLIC | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] ]
    [ USING ( using_expression ) ]
    [ WITH CHECK ( check_expression ) ]
```

For the documentation, please refer:

https://www.postgresql.org/docs/current/sql-createpolicy.html
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11013369949

Details

  • 106 of 133 (79.7%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 89.312%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/mod.rs 21 28 75.0%
src/parser/mod.rs 55 65 84.62%
tests/sqlparser_common.rs 30 40 75.0%
Files with Coverage Reduction New Missed Lines %
src/ast/mod.rs 1 82.42%
Totals Coverage Status
Change from base Build 10980785660: -0.04%
Covered Lines: 29783
Relevant Lines: 33347

💛 - Coveralls

@git-hulk
Copy link
Member Author

cc @iffyio

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! cc @alamb

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @git-hulk and @iffyio

@alamb alamb merged commit 8a534c0 into apache:main Sep 25, 2024
10 checks passed
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.

4 participants