mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-25 17:30:41 +00:00
feat: add show search_path for pg (#5328)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
@@ -22,8 +22,8 @@ use crate::error::{
|
||||
use crate::parser::ParserContext;
|
||||
use crate::statements::show::{
|
||||
ShowColumns, ShowCreateDatabase, ShowCreateFlow, ShowCreateTable, ShowCreateTableVariant,
|
||||
ShowCreateView, ShowDatabases, ShowFlows, ShowIndex, ShowKind, ShowStatus, ShowTableStatus,
|
||||
ShowTables, ShowVariables, ShowViews,
|
||||
ShowCreateView, ShowDatabases, ShowFlows, ShowIndex, ShowKind, ShowSearchPath, ShowStatus,
|
||||
ShowTableStatus, ShowTables, ShowVariables, ShowViews,
|
||||
};
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
@@ -107,6 +107,8 @@ impl ParserContext<'_> {
|
||||
Ok(Statement::ShowVariables(ShowVariables { variable }))
|
||||
} else if self.consume_token("STATUS") {
|
||||
Ok(Statement::ShowStatus(ShowStatus {}))
|
||||
} else if self.consume_token("SEARCH_PATH") {
|
||||
Ok(Statement::ShowSearchPath(ShowSearchPath {}))
|
||||
} else {
|
||||
self.unsupported(self.peek_token_as_string())
|
||||
}
|
||||
|
||||
@@ -289,6 +289,16 @@ impl Display for ShowStatus {
|
||||
}
|
||||
}
|
||||
|
||||
/// SQL structure for "SHOW SEARCH_PATH" postgres only
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut, Serialize)]
|
||||
pub struct ShowSearchPath {}
|
||||
|
||||
impl Display for ShowSearchPath {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "SHOW SEARCH_PATH")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::assert_matches::assert_matches;
|
||||
|
||||
@@ -36,8 +36,8 @@ use crate::statements::query::Query;
|
||||
use crate::statements::set_variables::SetVariables;
|
||||
use crate::statements::show::{
|
||||
ShowColumns, ShowCreateDatabase, ShowCreateFlow, ShowCreateTable, ShowCreateView,
|
||||
ShowDatabases, ShowFlows, ShowIndex, ShowKind, ShowStatus, ShowTableStatus, ShowTables,
|
||||
ShowVariables, ShowViews,
|
||||
ShowDatabases, ShowFlows, ShowIndex, ShowKind, ShowSearchPath, ShowStatus, ShowTableStatus,
|
||||
ShowTables, ShowVariables, ShowViews,
|
||||
};
|
||||
use crate::statements::tql::Tql;
|
||||
use crate::statements::truncate::TruncateTable;
|
||||
@@ -102,6 +102,8 @@ pub enum Statement {
|
||||
ShowCreateView(ShowCreateView),
|
||||
// SHOW STATUS
|
||||
ShowStatus(ShowStatus),
|
||||
// SHOW SEARCH_PATH
|
||||
ShowSearchPath(ShowSearchPath),
|
||||
// SHOW VIEWS
|
||||
ShowViews(ShowViews),
|
||||
// DESCRIBE TABLE
|
||||
@@ -159,6 +161,7 @@ impl Display for Statement {
|
||||
Statement::ShowCreateView(s) => s.fmt(f),
|
||||
Statement::ShowViews(s) => s.fmt(f),
|
||||
Statement::ShowStatus(s) => s.fmt(f),
|
||||
Statement::ShowSearchPath(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