Skip to content

Commit f3c332f

Browse files
committed
MySQL: Support SHOW FULL PROCESSLIST syntax
1 parent 6f8e7b8 commit f3c332f

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

src/ast/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,6 +4098,15 @@ pub enum Statement {
40984098
show_options: ShowStatementOptions,
40994099
},
41004100
/// ```sql
4101+
/// SHOW [FULL] PROCESSLIST
4102+
/// ```
4103+
///
4104+
/// Note: this is a MySQL-specific statement.
4105+
ShowProcessList {
4106+
/// `true` when full process information was requested.
4107+
full: bool,
4108+
},
4109+
/// ```sql
41014110
/// SHOW SCHEMAS
41024111
/// ```
41034112
ShowSchemas {
@@ -5710,6 +5719,14 @@ impl fmt::Display for Statement {
57105719
)?;
57115720
Ok(())
57125721
}
5722+
Statement::ShowProcessList { full } => {
5723+
write!(
5724+
f,
5725+
"SHOW {full}PROCESSLIST",
5726+
full = if *full { "FULL " } else { "" },
5727+
)?;
5728+
Ok(())
5729+
}
57135730
Statement::ShowSchemas {
57145731
terse,
57155732
history,

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ impl Spanned for Statement {
474474
Statement::DropPolicy { .. } => Span::empty(),
475475
Statement::DropConnector { .. } => Span::empty(),
476476
Statement::ShowDatabases { .. } => Span::empty(),
477+
Statement::ShowProcessList { .. } => Span::empty(),
477478
Statement::ShowSchemas { .. } => Span::empty(),
478479
Statement::ShowObjects { .. } => Span::empty(),
479480
Statement::ShowViews { .. } => Span::empty(),

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ define_keywords!(
810810
PRIOR,
811811
PRIVILEGES,
812812
PROCEDURE,
813+
PROCESSLIST,
813814
PROFILE,
814815
PROGRAM,
815816
PROJECTION,

src/parser/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15047,6 +15047,10 @@ impl<'a> Parser<'a> {
1504715047
Ok(self.parse_show_views(terse, false)?)
1504815048
} else if self.parse_keyword(Keyword::FUNCTIONS) {
1504915049
Ok(self.parse_show_functions()?)
15050+
} else if self.parse_keyword(Keyword::PROCESSLIST)
15051+
&& dialect_of!(self is MySqlDialect | GenericDialect)
15052+
{
15053+
Ok(Statement::ShowProcessList { full })
1505015054
} else if extended || full {
1505115055
Err(ParserError::ParserError(
1505215056
"EXTENDED/FULL are not supported with this type of SHOW query".to_string(),

tests/sqlparser_mysql.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,18 @@ fn parse_show_columns() {
369369
);
370370
}
371371

372+
#[test]
373+
fn parse_show_process_list() {
374+
assert_eq!(
375+
mysql_and_generic().verified_stmt("SHOW PROCESSLIST"),
376+
Statement::ShowProcessList { full: false }
377+
);
378+
assert_eq!(
379+
mysql_and_generic().verified_stmt("SHOW FULL PROCESSLIST"),
380+
Statement::ShowProcessList { full: true }
381+
);
382+
}
383+
372384
#[test]
373385
fn parse_show_status() {
374386
assert_eq!(

0 commit comments

Comments
 (0)