mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
parse VALIDATE CONSTRAINT
This commit is contained in:
parent
b3da639810
commit
7947c6a72e
5 changed files with 16 additions and 2 deletions
|
@ -347,6 +347,10 @@ pub enum AlterTableOperation {
|
|||
equals: bool,
|
||||
value: ValueWithSpan,
|
||||
},
|
||||
/// `VALIDATE CONSTRAINT <name>`
|
||||
ValidateConstraint {
|
||||
name: Ident,
|
||||
},
|
||||
}
|
||||
|
||||
/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
|
||||
|
@ -784,6 +788,9 @@ impl fmt::Display for AlterTableOperation {
|
|||
AlterTableOperation::ReplicaIdentity { identity } => {
|
||||
write!(f, "REPLICA IDENTITY {identity}")
|
||||
}
|
||||
AlterTableOperation::ValidateConstraint { name } => {
|
||||
write!(f, "VALIDATE CONSTRAINT {name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1198,6 +1198,7 @@ impl Spanned for AlterTableOperation {
|
|||
AlterTableOperation::AutoIncrement { value, .. } => value.span(),
|
||||
AlterTableOperation::Lock { .. } => Span::empty(),
|
||||
AlterTableOperation::ReplicaIdentity { .. } => Span::empty(),
|
||||
AlterTableOperation::ValidateConstraint { name } => name.span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1063,14 +1063,14 @@ pub trait Dialect: Debug + Any {
|
|||
|
||||
/// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
|
||||
///
|
||||
/// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
|
||||
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
|
||||
fn supports_constraint_not_valid(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns true if the dialect supports `VALIDATE CONSTRAINT <constraint_name>` in `ALTER TABLE` statements.
|
||||
///
|
||||
/// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
|
||||
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
|
||||
fn supports_validate_constraint(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -981,6 +981,7 @@ define_keywords!(
|
|||
UUID,
|
||||
VACUUM,
|
||||
VALID,
|
||||
VALIDATE,
|
||||
VALIDATION_MODE,
|
||||
VALUE,
|
||||
VALUES,
|
||||
|
|
|
@ -8899,6 +8899,11 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
|
||||
AlterTableOperation::ReplicaIdentity { identity }
|
||||
} else if self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT])
|
||||
&& self.dialect.supports_validate_constraint()
|
||||
{
|
||||
let name = self.parse_identifier()?;
|
||||
AlterTableOperation::ValidateConstraint { name }
|
||||
} else {
|
||||
let options: Vec<SqlOption> =
|
||||
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue