PARSER: Move show tables parser to parse_show_tables function
@@ -200,25 +200,7 @@ impl<'a> DfParser<'a> {
Keyword::SHOW => {
self.parser.next_token();
if self.consume_token("TABLES") {
- let tok = self.parser.next_token();
- match &tok {
- Token::EOF | Token::SemiColon => {
- Ok(DfStatement::ShowTables(DfShowTables::All))
- }
- Token::Word(w) => match w.keyword {
- Keyword::LIKE => Ok(DfStatement::ShowTables(
- DfShowTables::Like(self.parser.parse_identifier()?),
- )),
- Keyword::WHERE => Ok(DfStatement::ShowTables(
- DfShowTables::Where(self.parser.parse_expr()?),
- )),
- Keyword::FROM | Keyword::IN => Ok(DfStatement::ShowTables(
- DfShowTables::FromOrIn(self.parser.parse_object_name()?),
- )),
- _ => self.expected("like or where", tok),
- },
- _ => self.expected("like or where", tok),
- }
+ self.parse_show_tables()
} else if self.consume_token("DATABASES") {
self.parse_show_databases()
} else if self.consume_token("SETTINGS") {
@@ -345,6 +327,27 @@ impl<'a> DfParser<'a> {
Ok(DfStatement::Explain(DfExplain { typ, statement }))
}
+ // parse show tables.
+ fn parse_show_tables(&mut self) -> Result<DfStatement, ParserError> {
+ let tok = self.parser.next_token();
+ match &tok {
+ Token::EOF | Token::SemiColon => Ok(DfStatement::ShowTables(DfShowTables::All)),
+ Token::Word(w) => match w.keyword {
+ Keyword::LIKE => Ok(DfStatement::ShowTables(DfShowTables::Like(
+ self.parser.parse_identifier()?,
+ ))),
+ Keyword::WHERE => Ok(DfStatement::ShowTables(DfShowTables::Where(
+ self.parser.parse_expr()?,
+ ))),
+ Keyword::FROM | Keyword::IN => Ok(DfStatement::ShowTables(DfShowTables::FromOrIn(
+ self.parser.parse_object_name()?,
+ ))),
+ _ => self.expected("like or where", tok),
+ },
+ _ => self.expected("like or where", tok),
+ }
+ }
+
// parse show databases where database = xxx or where database
fn parse_show_databases(&mut self) -> Result<DfStatement, ParserError> {
if self.parser.parse_keyword(Keyword::WHERE) {
