Skip to content

Commit 40599f2

Browse files
parse VALIDATE CONSTRAINT
1 parent b9b6c42 commit 40599f2

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

src/ast/ddl.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ pub enum AlterTableOperation {
347347
equals: bool,
348348
value: ValueWithSpan,
349349
},
350+
/// `VALIDATE CONSTRAINT <name>`
351+
ValidateConstraint {
352+
name: Ident,
353+
},
350354
}
351355

352356
/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -784,6 +788,9 @@ impl fmt::Display for AlterTableOperation {
784788
AlterTableOperation::ReplicaIdentity { identity } => {
785789
write!(f, "REPLICA IDENTITY {identity}")
786790
}
791+
AlterTableOperation::ValidateConstraint { name } => {
792+
write!(f, "VALIDATE CONSTRAINT {name}")
793+
}
787794
}
788795
}
789796
}

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ impl Spanned for AlterTableOperation {
11981198
AlterTableOperation::AutoIncrement { value, .. } => value.span(),
11991199
AlterTableOperation::Lock { .. } => Span::empty(),
12001200
AlterTableOperation::ReplicaIdentity { .. } => Span::empty(),
1201+
AlterTableOperation::ValidateConstraint { name } => name.span,
12011202
}
12021203
}
12031204
}

src/dialect/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,14 +1035,14 @@ pub trait Dialect: Debug + Any {
10351035

10361036
/// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
10371037
///
1038-
/// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1038+
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
10391039
fn supports_constraint_not_valid(&self) -> bool {
10401040
false
10411041
}
10421042

10431043
/// Returns true if the dialect supports `VALIDATE CONSTRAINT <constraint_name>` in `ALTER TABLE` statements.
10441044
///
1045-
/// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1045+
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
10461046
fn supports_validate_constraint(&self) -> bool {
10471047
false
10481048
}

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ define_keywords!(
980980
UUID,
981981
VACUUM,
982982
VALID,
983+
VALIDATE,
983984
VALIDATION_MODE,
984985
VALUE,
985986
VALUES,

src/parser/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8899,6 +8899,11 @@ impl<'a> Parser<'a> {
88998899
};
89008900

89018901
AlterTableOperation::ReplicaIdentity { identity }
8902+
} else if self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT])
8903+
&& self.dialect.supports_validate_constraint()
8904+
{
8905+
let name = self.parse_identifier()?;
8906+
AlterTableOperation::ValidateConstraint { name }
89028907
} else {
89038908
let options: Vec<SqlOption> =
89048909
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;

0 commit comments

Comments
 (0)