Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax

Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
This commit is contained in:
Dmitry Patsura 2020-12-28 14:22:03 +03:00 committed by GitHub
parent cbd3c6b1a1
commit 17f2930885
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 156 additions and 11 deletions

View file

@ -131,6 +131,7 @@ impl<'a> Parser<'a> {
pub fn parse_statement(&mut self) -> Result<Statement, ParserError> {
match self.next_token() {
Token::Word(w) => match w.keyword {
Keyword::EXPLAIN => Ok(self.parse_explain()?),
Keyword::SELECT | Keyword::WITH | Keyword::VALUES => {
self.prev_token();
Ok(Statement::Query(Box::new(self.parse_query()?)))
@ -1790,6 +1791,19 @@ impl<'a> Parser<'a> {
})
}
pub fn parse_explain(&mut self) -> Result<Statement, ParserError> {
let analyze = self.parse_keyword(Keyword::ANALYZE);
let verbose = self.parse_keyword(Keyword::VERBOSE);
let statement = Box::new(self.parse_statement()?);
Ok(Statement::Explain {
analyze,
verbose,
statement,
})
}
/// Parse a query expression, i.e. a `SELECT` statement optionally
/// preceeded with some `WITH` CTE declarations and optionally followed
/// by `ORDER BY`. Unlike some other parse_... methods, this one doesn't