Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(parser): support show create view sql parser. #162

Merged
merged 2 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pisa-proxy/parser/mysql/src/ast/dml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3139,3 +3139,9 @@ pub enum ShowVariableType {
Global,
Session,
}

#[derive(Debug, Clone)]
pub struct ShowCreateViewStmt {
pub span: Span,
pub view_name: String,
}
1 change: 1 addition & 0 deletions pisa-proxy/parser/mysql/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub enum SqlStmt {
ShowCreateTableStmt(Box<ShowCreateTableStmt>),
ShowKeysStmt(Box<ShowKeysStmt>),
ShowVariablesStmt(Box<ShowVariablesStmt>),
ShowCreateViewStmt(Box<ShowCreateViewStmt>),
Start(Start),
Commit(Commit),
Rollback(Rollback),
Expand Down
11 changes: 11 additions & 0 deletions pisa-proxy/parser/mysql/src/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ sql_stmt -> SqlStmt:
| show_create_table_stmt { SqlStmt::ShowCreateTableStmt($1) }
| show_keys_stmt { SqlStmt::ShowKeysStmt($1) }
| show_variables_stmt { SqlStmt::ShowVariablesStmt($1) }
| show_create_view_stmt { SqlStmt::ShowCreateViewStmt($1) }
| start { SqlStmt::Start($1) }
| create { SqlStmt::Create($1) }

Expand Down Expand Up @@ -6033,6 +6034,16 @@ opt_var_type -> Option<ShowVariableType>:
| SESSION { Some(ShowVariableType::Session) }
;

show_create_view_stmt -> Box<ShowCreateViewStmt>:
'SHOW' 'CREATE' 'VIEW' table_ident
{
Box::new(ShowCreateViewStmt {
span: $span,
view_name: $4,
})
}
;

start -> Start:
START TRANSACTION opt_start_transaction_option_list
{
Expand Down
1 change: 1 addition & 0 deletions pisa-proxy/parser/mysql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ mod test {
"SHOW VARIABLES LIKE '%size%';",
"SHOW GLOBAL VARIABLES LIKE '%size%';",
"SHOW SESSION VARIABLES LIKE '%size%';",
"SHOW CREATE VIEW view_name;",
];

let p = Parser::new();
Expand Down