mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-02 21:22:15 +00:00
Add LOCK operation for ALTER TABLE (#1768)
This commit is contained in:
parent
10cf7c164e
commit
da5892802f
6 changed files with 104 additions and 1 deletions
|
@ -288,6 +288,16 @@ pub enum AlterTableOperation {
|
|||
equals: bool,
|
||||
algorithm: AlterTableAlgorithm,
|
||||
},
|
||||
|
||||
/// `LOCK [=] { DEFAULT | NONE | SHARED | EXCLUSIVE }`
|
||||
///
|
||||
/// [MySQL]-specific table alter lock.
|
||||
///
|
||||
/// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html
|
||||
Lock {
|
||||
equals: bool,
|
||||
lock: AlterTableLock,
|
||||
},
|
||||
/// `AUTO_INCREMENT [=] <value>`
|
||||
///
|
||||
/// [MySQL]-specific table option for raising current auto increment value.
|
||||
|
@ -366,6 +376,30 @@ impl fmt::Display for AlterTableAlgorithm {
|
|||
}
|
||||
}
|
||||
|
||||
/// [MySQL] `ALTER TABLE` lock.
|
||||
///
|
||||
/// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum AlterTableLock {
|
||||
Default,
|
||||
None,
|
||||
Shared,
|
||||
Exclusive,
|
||||
}
|
||||
|
||||
impl fmt::Display for AlterTableLock {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Default => "DEFAULT",
|
||||
Self::None => "NONE",
|
||||
Self::Shared => "SHARED",
|
||||
Self::Exclusive => "EXCLUSIVE",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
|
@ -692,6 +726,9 @@ impl fmt::Display for AlterTableOperation {
|
|||
value
|
||||
)
|
||||
}
|
||||
AlterTableOperation::Lock { equals, lock } => {
|
||||
write!(f, "LOCK {}{}", if *equals { "= " } else { "" }, lock)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue