Skip to content
Open
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
14 changes: 14 additions & 0 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ pub enum AlterTableOperation {
///
/// Note: this is a PostgreSQL-specific operation.
EnableRowLevelSecurity,
/// `FORCE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
ForceRowLevelSecurity,
/// `NO FORCE ROW LEVEL SECURITY`
///
/// Note: this is a PostgreSQL-specific operation.
NoForceRowLevelSecurity,
/// `ENABLE RULE rewrite_rule_name`
///
/// Note: this is a PostgreSQL-specific operation.
Expand Down Expand Up @@ -876,6 +884,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