Skip to content

Commit f884da9

Browse files
committed
Postgres: support force row level security
1 parent 6060a11 commit f884da9

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/ast/ddl.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ pub enum AlterTableOperation {
319319
///
320320
/// Note: this is a PostgreSQL-specific operation.
321321
EnableRowLevelSecurity,
322+
/// `FORCE ROW LEVEL SECURITY`
323+
///
324+
/// Note: this is a PostgreSQL-specific operation.
325+
ForceRowLevelSecurity,
326+
/// `NO FORCE ROW LEVEL SECURITY`
327+
///
328+
/// Note: this is a PostgreSQL-specific operation.
329+
NoForceRowLevelSecurity,
322330
/// `ENABLE RULE rewrite_rule_name`
323331
///
324332
/// Note: this is a PostgreSQL-specific operation.
@@ -876,6 +884,12 @@ impl fmt::Display for AlterTableOperation {
876884
AlterTableOperation::EnableRowLevelSecurity => {
877885
write!(f, "ENABLE ROW LEVEL SECURITY")
878886
}
887+
AlterTableOperation::ForceRowLevelSecurity => {
888+
write!(f, "FORCE ROW LEVEL SECURITY")
889+
}
890+
AlterTableOperation::NoForceRowLevelSecurity => {
891+
write!(f, "NO FORCE ROW LEVEL SECURITY")
892+
}
879893
AlterTableOperation::EnableRule { name } => {
880894
write!(f, "ENABLE RULE {name}")
881895
}

src/ast/spans.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ impl Spanned for AlterTableOperation {
11211121
AlterTableOperation::EnableReplicaRule { name } => name.span,
11221122
AlterTableOperation::EnableReplicaTrigger { name } => name.span,
11231123
AlterTableOperation::EnableRowLevelSecurity => Span::empty(),
1124+
AlterTableOperation::ForceRowLevelSecurity => Span::empty(),
1125+
AlterTableOperation::NoForceRowLevelSecurity => Span::empty(),
11241126
AlterTableOperation::EnableRule { name } => name.span,
11251127
AlterTableOperation::EnableTrigger { name } => name.span,
11261128
AlterTableOperation::RenamePartitions {

src/parser/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9794,6 +9794,21 @@ impl<'a> Parser<'a> {
97949794
self.peek_token(),
97959795
);
97969796
}
9797+
} else if self.parse_keywords(&[
9798+
Keyword::FORCE,
9799+
Keyword::ROW,
9800+
Keyword::LEVEL,
9801+
Keyword::SECURITY,
9802+
]) {
9803+
AlterTableOperation::ForceRowLevelSecurity
9804+
} else if self.parse_keywords(&[
9805+
Keyword::NO,
9806+
Keyword::FORCE,
9807+
Keyword::ROW,
9808+
Keyword::LEVEL,
9809+
Keyword::SECURITY,
9810+
]) {
9811+
AlterTableOperation::NoForceRowLevelSecurity
97979812
} else if self.parse_keywords(&[Keyword::CLEAR, Keyword::PROJECTION])
97989813
&& dialect_of!(self is ClickHouseDialect|GenericDialect)
97999814
{

tests/sqlparser_postgres.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ fn parse_alter_table_enable() {
640640
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE REPLICA TRIGGER trigger_name");
641641
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE REPLICA RULE rule_name");
642642
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE ROW LEVEL SECURITY");
643+
pg_and_generic().verified_stmt("ALTER TABLE tab FORCE ROW LEVEL SECURITY");
644+
pg_and_generic().verified_stmt("ALTER TABLE tab NO FORCE ROW LEVEL SECURITY");
643645
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE RULE rule_name");
644646
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE TRIGGER ALL");
645647
pg_and_generic().verified_stmt("ALTER TABLE tab ENABLE TRIGGER USER");

0 commit comments

Comments
 (0)