Support parsing multiple show variables. (#290)

* feat: support parsing multiple show variables.

* fix: fix fmt error
This commit is contained in:
Francis Du 2021-02-10 04:03:49 +08:00 committed by GitHub
parent f40955ee82
commit 07342d5853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 7 deletions

View file

@ -2043,6 +2043,19 @@ impl<'a> Parser<'a> {
Ok(ObjectName(idents))
}
/// Parse identifiers
pub fn parse_identifiers(&mut self) -> Result<Vec<Ident>, ParserError> {
let mut idents = vec![];
loop {
match self.next_token() {
Token::Word(w) => idents.push(w.to_ident()),
Token::EOF => break,
_ => {}
}
}
Ok(idents)
}
/// Parse a simple one-word identifier (possibly quoted, possibly a keyword)
pub fn parse_identifier(&mut self) -> Result<Ident, ParserError> {
match self.next_token() {
@ -2439,7 +2452,7 @@ impl<'a> Parser<'a> {
self.parse_show_columns()
} else {
Ok(Statement::ShowVariable {
variable: self.parse_identifier()?,
variable: self.parse_identifiers()?,
})
}
}