Add support for mysql 'SHOW CREATE VIEW' statement (#536)

This commit is contained in:
Mike Roberts 2022-07-18 11:10:09 +01:00 committed by GitHub
parent dea7666086
commit 93e16e9864
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View file

@ -705,6 +705,7 @@ pub enum ShowCreateObject {
Procedure, Procedure,
Table, Table,
Trigger, Trigger,
View,
} }
impl fmt::Display for ShowCreateObject { impl fmt::Display for ShowCreateObject {
@ -715,6 +716,7 @@ impl fmt::Display for ShowCreateObject {
ShowCreateObject::Procedure => f.write_str("PROCEDURE"), ShowCreateObject::Procedure => f.write_str("PROCEDURE"),
ShowCreateObject::Table => f.write_str("TABLE"), ShowCreateObject::Table => f.write_str("TABLE"),
ShowCreateObject::Trigger => f.write_str("TRIGGER"), ShowCreateObject::Trigger => f.write_str("TRIGGER"),
ShowCreateObject::View => f.write_str("VIEW"),
} }
} }
} }

View file

@ -3610,12 +3610,14 @@ impl<'a> Parser<'a> {
Keyword::FUNCTION, Keyword::FUNCTION,
Keyword::PROCEDURE, Keyword::PROCEDURE,
Keyword::EVENT, Keyword::EVENT,
Keyword::VIEW,
])? { ])? {
Keyword::TABLE => Ok(ShowCreateObject::Table), Keyword::TABLE => Ok(ShowCreateObject::Table),
Keyword::TRIGGER => Ok(ShowCreateObject::Trigger), Keyword::TRIGGER => Ok(ShowCreateObject::Trigger),
Keyword::FUNCTION => Ok(ShowCreateObject::Function), Keyword::FUNCTION => Ok(ShowCreateObject::Function),
Keyword::PROCEDURE => Ok(ShowCreateObject::Procedure), Keyword::PROCEDURE => Ok(ShowCreateObject::Procedure),
Keyword::EVENT => Ok(ShowCreateObject::Event), Keyword::EVENT => Ok(ShowCreateObject::Event),
Keyword::VIEW => Ok(ShowCreateObject::View),
keyword => Err(ParserError::ParserError(format!( keyword => Err(ParserError::ParserError(format!(
"Unable to map keyword to ShowCreateObject: {:?}", "Unable to map keyword to ShowCreateObject: {:?}",
keyword keyword

View file

@ -128,6 +128,7 @@ fn parse_show_create() {
ShowCreateObject::Event, ShowCreateObject::Event,
ShowCreateObject::Function, ShowCreateObject::Function,
ShowCreateObject::Procedure, ShowCreateObject::Procedure,
ShowCreateObject::View,
] { ] {
assert_eq!( assert_eq!(
mysql_and_generic().verified_stmt(format!("SHOW CREATE {} myident", obj_type).as_str()), mysql_and_generic().verified_stmt(format!("SHOW CREATE {} myident", obj_type).as_str()),