Add LOCK operation for ALTER TABLE (#1768)

This commit is contained in:
Mohamed Abdeen 2025-03-18 08:22:37 +02:00 committed by GitHub
parent 10cf7c164e
commit da5892802f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 104 additions and 1 deletions

View file

@ -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)
}
}
}
}