From f86f78cf1294b7160d769f6a4bae23baa471ac8e Mon Sep 17 00:00:00 2001 From: Mike Roberts Date: Sat, 9 Jul 2022 15:08:16 +0100 Subject: [PATCH] Add support for mysql 'SHOW CREATE VIEW' statement --- src/ast/mod.rs | 2 ++ src/parser.rs | 2 ++ tests/sqlparser_mysql.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index c316aa6b3..fc779c79a 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -705,6 +705,7 @@ pub enum ShowCreateObject { Procedure, Table, Trigger, + View, } impl fmt::Display for ShowCreateObject { @@ -715,6 +716,7 @@ impl fmt::Display for ShowCreateObject { ShowCreateObject::Procedure => f.write_str("PROCEDURE"), ShowCreateObject::Table => f.write_str("TABLE"), ShowCreateObject::Trigger => f.write_str("TRIGGER"), + ShowCreateObject::View => f.write_str("VIEW"), } } } diff --git a/src/parser.rs b/src/parser.rs index 325d90c47..cee7be43b 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3601,12 +3601,14 @@ impl<'a> Parser<'a> { Keyword::FUNCTION, Keyword::PROCEDURE, Keyword::EVENT, + Keyword::VIEW, ])? { Keyword::TABLE => Ok(ShowCreateObject::Table), Keyword::TRIGGER => Ok(ShowCreateObject::Trigger), Keyword::FUNCTION => Ok(ShowCreateObject::Function), Keyword::PROCEDURE => Ok(ShowCreateObject::Procedure), Keyword::EVENT => Ok(ShowCreateObject::Event), + Keyword::VIEW => Ok(ShowCreateObject::View), keyword => Err(ParserError::ParserError(format!( "Unable to map keyword to ShowCreateObject: {:?}", keyword diff --git a/tests/sqlparser_mysql.rs b/tests/sqlparser_mysql.rs index 51ade0515..ff5020c34 100644 --- a/tests/sqlparser_mysql.rs +++ b/tests/sqlparser_mysql.rs @@ -128,6 +128,7 @@ fn parse_show_create() { ShowCreateObject::Event, ShowCreateObject::Function, ShowCreateObject::Procedure, + ShowCreateObject::View, ] { assert_eq!( mysql_and_generic().verified_stmt(format!("SHOW CREATE {} myident", obj_type).as_str()),