Skip to content

Commit 4176b66

Browse files
authored
feat(ddl): add ForceRowLevelSecurity and NoForceRowLevelSecurity ALTER TABLE operations (#1)
PostgreSQL supports FORCE ROW LEVEL SECURITY and NO FORCE ROW LEVEL SECURITY as ALTER TABLE operations. Add parsing support for both variants.
1 parent 17910f2 commit 4176b66

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[package]
1919
name = "pgmold-sqlparser"
2020
description = "Fork of sqlparser with additional PostgreSQL features (PARTITION OF, SECURITY DEFINER/INVOKER, SET params)"
21-
version = "0.60.1"
21+
version = "0.60.2"
2222
authors = ["Filipe Guerreiro <filipe.m.guerreiro@gmail.com>"]
2323
homepage = "https://github.com/fmguerreiro/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/pgmold-sqlparser/"

src/ast/ddl.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ pub enum AlterTableOperation {
277277
///
278278
/// Note: this is a PostgreSQL-specific operation.
279279
EnableRowLevelSecurity,
280+
/// `FORCE ROW LEVEL SECURITY`
281+
///
282+
/// Note: this is a PostgreSQL-specific operation.
283+
ForceRowLevelSecurity,
284+
/// `NO FORCE ROW LEVEL SECURITY`
285+
///
286+
/// Note: this is a PostgreSQL-specific operation.
287+
NoForceRowLevelSecurity,
280288
/// `ENABLE RULE rewrite_rule_name`
281289
///
282290
/// Note: this is a PostgreSQL-specific operation.
@@ -757,6 +765,12 @@ impl fmt::Display for AlterTableOperation {
757765
AlterTableOperation::EnableRowLevelSecurity => {
758766
write!(f, "ENABLE ROW LEVEL SECURITY")
759767
}
768+
AlterTableOperation::ForceRowLevelSecurity => {
769+
write!(f, "FORCE ROW LEVEL SECURITY")
770+
}
771+
AlterTableOperation::NoForceRowLevelSecurity => {
772+
write!(f, "NO FORCE ROW LEVEL SECURITY")
773+
}
760774
AlterTableOperation::EnableRule { name } => {
761775
write!(f, "ENABLE RULE {name}")
762776
}

src/ast/spans.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,8 @@ impl Spanned for AlterTableOperation {
10811081
partition,
10821082
} => name.span.union_opt(&partition.as_ref().map(|i| i.span)),
10831083
AlterTableOperation::DisableRowLevelSecurity => Span::empty(),
1084+
AlterTableOperation::ForceRowLevelSecurity => Span::empty(),
1085+
AlterTableOperation::NoForceRowLevelSecurity => Span::empty(),
10841086
AlterTableOperation::DisableRule { name } => name.span,
10851087
AlterTableOperation::DisableTrigger { name } => name.span,
10861088
AlterTableOperation::DropConstraint {

src/parser/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9545,6 +9545,10 @@ impl<'a> Parser<'a> {
95459545
self.peek_token(),
95469546
);
95479547
}
9548+
} else if self.parse_keywords(&[Keyword::FORCE, Keyword::ROW, Keyword::LEVEL, Keyword::SECURITY]) {
9549+
AlterTableOperation::ForceRowLevelSecurity
9550+
} else if self.parse_keywords(&[Keyword::NO, Keyword::FORCE, Keyword::ROW, Keyword::LEVEL, Keyword::SECURITY]) {
9551+
AlterTableOperation::NoForceRowLevelSecurity
95489552
} else if self.parse_keywords(&[Keyword::CLEAR, Keyword::PROJECTION])
95499553
&& dialect_of!(self is ClickHouseDialect|GenericDialect)
95509554
{

0 commit comments

Comments
 (0)