mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-20 06:50:37 +00:00
feat: Implement SHOW STATUS (#4050)
* show status returning empty contents * return an empty set instead of affected rows * chore: Update src/query/src/sql.rs --------- Co-authored-by: Yingwen <realevenyag@gmail.com>
This commit is contained in:
@@ -19,7 +19,8 @@ use sqlparser::tokenizer::Token;
|
||||
use crate::error::{self, InvalidDatabaseNameSnafu, InvalidTableNameSnafu, Result};
|
||||
use crate::parser::ParserContext;
|
||||
use crate::statements::show::{
|
||||
ShowColumns, ShowCreateTable, ShowDatabases, ShowIndex, ShowKind, ShowTables, ShowVariables,
|
||||
ShowColumns, ShowCreateTable, ShowDatabases, ShowIndex, ShowKind, ShowStatus, ShowTables,
|
||||
ShowVariables,
|
||||
};
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
@@ -82,6 +83,8 @@ impl<'a> ParserContext<'a> {
|
||||
actual: self.peek_token_as_string(),
|
||||
})?;
|
||||
Ok(Statement::ShowVariables(ShowVariables { variable }))
|
||||
} else if self.consume_token("STATUS") {
|
||||
Ok(Statement::ShowStatus(ShowStatus {}))
|
||||
} else {
|
||||
self.unsupported(self.peek_token_as_string())
|
||||
}
|
||||
|
||||
@@ -145,6 +145,16 @@ impl Display for ShowVariables {
|
||||
}
|
||||
}
|
||||
|
||||
/// SQL structure for "SHOW STATUS"
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)]
|
||||
pub struct ShowStatus {}
|
||||
|
||||
impl Display for ShowStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "SHOW STATUS")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::assert_matches::assert_matches;
|
||||
|
||||
@@ -31,7 +31,8 @@ use crate::statements::insert::Insert;
|
||||
use crate::statements::query::Query;
|
||||
use crate::statements::set_variables::SetVariables;
|
||||
use crate::statements::show::{
|
||||
ShowColumns, ShowCreateTable, ShowDatabases, ShowIndex, ShowKind, ShowTables, ShowVariables,
|
||||
ShowColumns, ShowCreateTable, ShowDatabases, ShowIndex, ShowKind, ShowStatus, ShowTables,
|
||||
ShowVariables,
|
||||
};
|
||||
use crate::statements::tql::Tql;
|
||||
use crate::statements::truncate::TruncateTable;
|
||||
@@ -80,6 +81,8 @@ pub enum Statement {
|
||||
ShowIndex(ShowIndex),
|
||||
// SHOW CREATE TABLE
|
||||
ShowCreateTable(ShowCreateTable),
|
||||
// SHOW STATUS
|
||||
ShowStatus(ShowStatus),
|
||||
// DESCRIBE TABLE
|
||||
DescribeTable(DescribeTable),
|
||||
// EXPLAIN QUERY
|
||||
@@ -115,6 +118,7 @@ impl Display for Statement {
|
||||
Statement::ShowColumns(s) => s.fmt(f),
|
||||
Statement::ShowIndex(s) => s.fmt(f),
|
||||
Statement::ShowCreateTable(s) => s.fmt(f),
|
||||
Statement::ShowStatus(s) => s.fmt(f),
|
||||
Statement::DescribeTable(s) => s.fmt(f),
|
||||
Statement::Explain(s) => s.fmt(f),
|
||||
Statement::Copy(s) => s.fmt(f),
|
||||
|
||||
Reference in New Issue
Block a user