diff --git a/src/ast/mod.rs b/src/ast/mod.rs index d7a3679a4..bf279bbc6 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -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 { @@ -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, diff --git a/src/ast/spans.rs b/src/ast/spans.rs index d80a3f4d5..4b31935e7 100644 --- a/src/ast/spans.rs +++ b/src/ast/spans.rs @@ -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(), diff --git a/src/keywords.rs b/src/keywords.rs index f0f37b1c0..31c1b7c55 100644 --- a/src/keywords.rs +++ b/src/keywords.rs @@ -810,6 +810,7 @@ define_keywords!( PRIOR, PRIVILEGES, PROCEDURE, + PROCESSLIST, PROFILE, PROGRAM, PROJECTION, diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 6282ed3d7..aaafd52c8 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -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(), diff --git a/tests/sqlparser_mysql.rs b/tests/sqlparser_mysql.rs index 269787c29..6fcd3c81b 100644 --- a/tests/sqlparser_mysql.rs +++ b/tests/sqlparser_mysql.rs @@ -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!(