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 table sql parser. #150

Merged
merged 3 commits into from
Jun 29, 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 @@ -3103,3 +3103,9 @@ pub struct ShowTableDb {
pub from_or_in: FromOrIn,
pub db: String,
}

#[derive(Debug, Clone)]
pub struct ShowCreateTable {
pub span: Span,
pub table: 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 @@ -42,6 +42,7 @@ pub enum SqlStmt {
ShowDatabasesStmt(Box<ShowDatabasesStmt>),
ShowTablesStmt(Box<ShowTablesStmt>),
ShowColumnsStmt(Box<ShowColumnsStmt>),
ShowCreateTable(Box<ShowCreateTable>),
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 @@ -108,6 +108,7 @@ sql_stmt -> SqlStmt:
| show_databases_stmt { SqlStmt::ShowDatabasesStmt($1) }
| show_tables_stmt { SqlStmt::ShowTablesStmt($1) }
| show_columns_stmt { SqlStmt::ShowColumnsStmt($1) }
| show_create_table_stmt { SqlStmt::ShowCreateTable($1) }
| start { SqlStmt::Start($1) }
| create { SqlStmt::Create($1) }

Expand Down Expand Up @@ -5977,6 +5978,16 @@ from_or_in -> FromOrIn:
| 'IN' { FromOrIn::In }
;

show_create_table_stmt -> Box<ShowCreateTable>:
'SHOW' 'CREATE' 'TABLE' table_ident
{
Box::new(ShowCreateTable {
span: $span,
table: $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 @@ -128,6 +128,7 @@ mod test {
"select * from test.test limit 1",
"select * from test.1test limit 1",
"SHOW COLUMNS FROM t_order;",
"SHOW CREATE TABLE t_order;",
];

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