Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub enum AlterTableOperation {
/// `DISABLE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
/// Please refer to [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-altertable.html)
DisableRowLevelSecurity,
/// `DISABLE RULE rewrite_rule_name`
///
Expand Down Expand Up @@ -318,7 +319,18 @@ pub enum AlterTableOperation {
/// `ENABLE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
/// Please refer to [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-altertable.html)
EnableRowLevelSecurity,
/// `FORCE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
/// Please refer to [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-altertable.html)
ForceRowLevelSecurity,
/// `NO FORCE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
/// Please refer to [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-altertable.html)
NoForceRowLevelSecurity,
Comment on lines +326 to +333
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we add a link to the postgres documentation for the new options?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, added comments identical to the existing one for REPLICA IDENTITY.

/// `ENABLE RULE rewrite_rule_name`
///
/// Note: this is a PostgreSQL-specific operation.
Expand Down Expand Up @@ -876,6 +888,12 @@ impl fmt::Display for AlterTableOperation {
AlterTableOperation::EnableRowLevelSecurity => {
write!(f, "ENABLE ROW LEVEL SECURITY")
}
AlterTableOperation::ForceRowLevelSecurity => {
write!(f, "FORCE ROW LEVEL SECURITY")
}
AlterTableOperation::NoForceRowLevelSecurity => {
write!(f, "NO FORCE ROW LEVEL SECURITY")
}
AlterTableOperation::EnableRule { name } => {
write!(f, "ENABLE RULE {name}")
}
Expand Down
2 changes: 2 additions & 0 deletions src/ast/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,8 @@ impl Spanned for AlterTableOperation {
AlterTableOperation::EnableReplicaRule { name } => name.span,
AlterTableOperation::EnableReplicaTrigger { name } => name.span,
AlterTableOperation::EnableRowLevelSecurity => Span::empty(),
AlterTableOperation::ForceRowLevelSecurity => Span::empty(),
AlterTableOperation::NoForceRowLevelSecurity => Span::empty(),
AlterTableOperation::EnableRule { name } => name.span,
AlterTableOperation::EnableTrigger { name } => name.span,
AlterTableOperation::RenamePartitions {
Expand Down
15 changes: 15 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9794,6 +9794,21 @@ impl<'a> Parser<'a> {
self.peek_token(),
);
}
} else if self.parse_keywords(&[
Keyword::FORCE,
Keyword::ROW,
Keyword::LEVEL,
Keyword::SECURITY,
]) {
AlterTableOperation::ForceRowLevelSecurity
} else if self.parse_keywords(&[
Keyword::NO,
Keyword::FORCE,
Keyword::ROW,
Keyword::LEVEL,
Keyword::SECURITY,
]) {
AlterTableOperation::NoForceRowLevelSecurity
} else if self.parse_keywords(&[Keyword::CLEAR, Keyword::PROJECTION])
&& dialect_of!(self is ClickHouseDialect|GenericDialect)
{
Expand Down
2 changes: 2 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ fn parse_alter_table_enable() {
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE REPLICA TRIGGER trigger_name");
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE REPLICA RULE rule_name");
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE ROW LEVEL SECURITY");
pg_and_generic().verified_stmt("ALTER TABLE tab FORCE ROW LEVEL SECURITY");
pg_and_generic().verified_stmt("ALTER TABLE tab NO FORCE ROW LEVEL SECURITY");
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE RULE rule_name");
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE TRIGGER ALL");
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE TRIGGER USER");
Expand Down
Loading