Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,15 @@ pub enum Statement {
show_options: ShowStatementOptions,
},
/// ```sql
/// SHOW [FULL] PROCESSLIST
/// ```
///
/// Note: this is a MySQL-specific statement.
ShowProcessList {
/// `true` when full process information was requested.
full: bool,
},
/// ```sql
/// SHOW SCHEMAS
/// ```
ShowSchemas {
Expand Down Expand Up @@ -5710,6 +5719,14 @@ impl fmt::Display for Statement {
)?;
Ok(())
}
Statement::ShowProcessList { full } => {
write!(
f,
"SHOW {full}PROCESSLIST",
full = if *full { "FULL " } else { "" },
)?;
Ok(())
}
Statement::ShowSchemas {
terse,
history,
Expand Down
1 change: 1 addition & 0 deletions src/ast/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ impl Spanned for Statement {
Statement::DropPolicy { .. } => Span::empty(),
Statement::DropConnector { .. } => Span::empty(),
Statement::ShowDatabases { .. } => Span::empty(),
Statement::ShowProcessList { .. } => Span::empty(),
Statement::ShowSchemas { .. } => Span::empty(),
Statement::ShowObjects { .. } => Span::empty(),
Statement::ShowViews { .. } => Span::empty(),
Expand Down
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ define_keywords!(
PRIOR,
PRIVILEGES,
PROCEDURE,
PROCESSLIST,
PROFILE,
PROGRAM,
PROJECTION,
Expand Down
4 changes: 4 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15047,6 +15047,10 @@ impl<'a> Parser<'a> {
Ok(self.parse_show_views(terse, false)?)
} else if self.parse_keyword(Keyword::FUNCTIONS) {
Ok(self.parse_show_functions()?)
} else if self.parse_keyword(Keyword::PROCESSLIST)
&& dialect_of!(self is MySqlDialect | GenericDialect)
{
Ok(Statement::ShowProcessList { full })
} else if extended || full {
Err(ParserError::ParserError(
"EXTENDED/FULL are not supported with this type of SHOW query".to_string(),
Expand Down
12 changes: 12 additions & 0 deletions tests/sqlparser_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,18 @@ fn parse_show_columns() {
);
}

#[test]
fn parse_show_process_list() {
assert_eq!(
mysql_and_generic().verified_stmt("SHOW PROCESSLIST"),
Statement::ShowProcessList { full: false }
);
assert_eq!(
mysql_and_generic().verified_stmt("SHOW FULL PROCESSLIST"),
Statement::ShowProcessList { full: true }
);
}

#[test]
fn parse_show_status() {
assert_eq!(
Expand Down