From 780217fa53dff04380be45dc0766a04d939b991f Mon Sep 17 00:00:00 2001 From: test Date: Mon, 1 Jan 2024 00:47:20 +0800 Subject: [PATCH] feat: add information_schema.session_status --- src/catalog/src/information_schema.rs | 2 ++ src/catalog/src/information_schema/memory_table/tables.rs | 8 ++++++++ src/catalog/src/information_schema/table_names.rs | 3 ++- src/common/catalog/src/consts.rs | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/catalog/src/information_schema.rs b/src/catalog/src/information_schema.rs index 7b29acc0f243..7dbc71f6f465 100644 --- a/src/catalog/src/information_schema.rs +++ b/src/catalog/src/information_schema.rs @@ -70,6 +70,7 @@ lazy_static! { TABLE_PRIVILEGES, TRIGGERS, GLOBAL_STATUS, + SESSION_STATUS, ]; } @@ -197,6 +198,7 @@ impl InformationSchemaProvider { TABLE_PRIVILEGES => setup_memory_table!(TABLE_PRIVILEGES), TRIGGERS => setup_memory_table!(TRIGGERS), GLOBAL_STATUS => setup_memory_table!(GLOBAL_STATUS), + SESSION_STATUS => setup_memory_table!(SESSION_STATUS), KEY_COLUMN_USAGE => Some(Arc::new(InformationSchemaKeyColumnUsage::new( self.catalog_name.clone(), self.catalog_manager.clone(), diff --git a/src/catalog/src/information_schema/memory_table/tables.rs b/src/catalog/src/information_schema/memory_table/tables.rs index 705a598d2873..7598bca7a23a 100644 --- a/src/catalog/src/information_schema/memory_table/tables.rs +++ b/src/catalog/src/information_schema/memory_table/tables.rs @@ -400,6 +400,14 @@ pub fn get_schema_columns(table_name: &str) -> (SchemaRef, Vec) { vec![], ), + SESSION_STATUS => ( + vec![ + string_column("VARIABLE_NAME"), + string_column("VARIABLE_VALUE"), + ], + vec![], + ), + _ => unreachable!("Unknown table in information_schema: {}", table_name), }; diff --git a/src/catalog/src/information_schema/table_names.rs b/src/catalog/src/information_schema/table_names.rs index 482ee0e8847d..ce252e2e47dd 100644 --- a/src/catalog/src/information_schema/table_names.rs +++ b/src/catalog/src/information_schema/table_names.rs @@ -35,5 +35,6 @@ pub const REFERENTIAL_CONSTRAINTS: &str = "referential_constraints"; pub const ROUTINES: &str = "routines"; pub const SCHEMA_PRIVILEGES: &str = "schema_privileges"; pub const TABLE_PRIVILEGES: &str = "table_privileges"; -pub const GLOBAL_STATUS: &str = "global_status"; pub const TRIGGERS: &str = "triggers"; +pub const GLOBAL_STATUS: &str = "global_status"; +pub const SESSION_STATUS: &str = "session_status"; diff --git a/src/common/catalog/src/consts.rs b/src/common/catalog/src/consts.rs index c3ace8acd534..3e0510cd9215 100644 --- a/src/common/catalog/src/consts.rs +++ b/src/common/catalog/src/consts.rs @@ -78,6 +78,8 @@ pub const INFORMATION_SCHEMA_TABLE_PRIVILEGES_TABLE_ID: u32 = 23; pub const INFORMATION_SCHEMA_TRIGGERS_TABLE_ID: u32 = 24; /// id for information_schema.GLOBAL_STATUS pub const INFORMATION_SCHEMA_GLOBAL_STATUS_TABLE_ID: u32 = 25; +/// id for information_schema.SESSION_STATUS +pub const INFORMATION_SCHEMA_SESSION_STATUS_TABLE_ID: u32 = 26; /// ----- End of information_schema tables ----- pub const MITO_ENGINE: &str = "mito";