mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-19 05:30:19 +00:00
feat: Support KILL statement (#479)
This commit is contained in:
parent
7732c34b19
commit
f5980cd30f
5 changed files with 109 additions and 0 deletions
|
@ -154,6 +154,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::KILL => Ok(self.parse_kill()?),
|
||||
Keyword::DESCRIBE => Ok(self.parse_explain(true)?),
|
||||
Keyword::EXPLAIN => Ok(self.parse_explain(false)?),
|
||||
Keyword::ANALYZE => Ok(self.parse_analyze()?),
|
||||
|
@ -2878,6 +2879,32 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
// KILL [CONNECTION | QUERY] processlist_id
|
||||
pub fn parse_kill(&mut self) -> Result<Statement, ParserError> {
|
||||
let modifier_keyword =
|
||||
self.parse_one_of_keywords(&[Keyword::CONNECTION, Keyword::QUERY, Keyword::MUTATION]);
|
||||
|
||||
let id = self.parse_literal_uint()?;
|
||||
|
||||
let modifier = match modifier_keyword {
|
||||
Some(Keyword::CONNECTION) => Some(KillType::Connection),
|
||||
Some(Keyword::QUERY) => Some(KillType::Query),
|
||||
Some(Keyword::MUTATION) => {
|
||||
if dialect_of!(self is ClickHouseDialect | GenericDialect) {
|
||||
Some(KillType::Mutation)
|
||||
} else {
|
||||
self.expected(
|
||||
"Unsupported type for KILL, allowed: CONNECTION | QUERY",
|
||||
self.peek_token(),
|
||||
)?
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
Ok(Statement::Kill { modifier, id })
|
||||
}
|
||||
|
||||
pub fn parse_explain(&mut self, describe_alias: bool) -> Result<Statement, ParserError> {
|
||||
let analyze = self.parse_keyword(Keyword::ANALYZE);
|
||||
let verbose = self.parse_keyword(Keyword::VERBOSE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue