diff --git a/src/catalog/src/memory/manager.rs b/src/catalog/src/memory/manager.rs index 5d08c1162600..8c3048bac603 100644 --- a/src/catalog/src/memory/manager.rs +++ b/src/catalog/src/memory/manager.rs @@ -18,7 +18,9 @@ use std::collections::HashMap; use std::sync::{Arc, RwLock, Weak}; use common_catalog::build_db_string; -use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME}; +use common_catalog::consts::{ + DEFAULT_CATALOG_NAME, DEFAULT_PRIVATE_SCHEMA_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME, +}; use snafu::OptionExt; use table::TableRef; @@ -135,6 +137,12 @@ impl MemoryCatalogManager { schema: DEFAULT_SCHEMA_NAME.to_string(), }) .unwrap(); + manager + .register_schema_sync(RegisterSchemaRequest { + catalog: DEFAULT_CATALOG_NAME.to_string(), + schema: DEFAULT_PRIVATE_SCHEMA_NAME.to_string(), + }) + .unwrap(); manager } diff --git a/src/common/catalog/src/consts.rs b/src/common/catalog/src/consts.rs index 111ffb8a4d45..74becd8c91bf 100644 --- a/src/common/catalog/src/consts.rs +++ b/src/common/catalog/src/consts.rs @@ -17,6 +17,7 @@ pub const INFORMATION_SCHEMA_NAME: &str = "information_schema"; pub const SYSTEM_CATALOG_TABLE_NAME: &str = "system_catalog"; pub const DEFAULT_CATALOG_NAME: &str = "greptime"; pub const DEFAULT_SCHEMA_NAME: &str = "public"; +pub const DEFAULT_PRIVATE_SCHEMA_NAME: &str = "greptime_private"; /// Reserves [0,MIN_USER_TABLE_ID) for internal usage. /// User defined table id starts from this value. diff --git a/src/common/meta/src/key.rs b/src/common/meta/src/key.rs index c66ead5b8002..085716f82d6e 100644 --- a/src/common/meta/src/key.rs +++ b/src/common/meta/src/key.rs @@ -63,7 +63,9 @@ use std::ops::Deref; use std::sync::Arc; use bytes::Bytes; -use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME}; +use common_catalog::consts::{ + DEFAULT_CATALOG_NAME, DEFAULT_PRIVATE_SCHEMA_NAME, DEFAULT_SCHEMA_NAME, +}; use common_telemetry::warn; use datanode_table::{DatanodeTableKey, DatanodeTableManager, DatanodeTableValue}; use lazy_static::lazy_static; @@ -295,11 +297,16 @@ impl TableMetadataManager { pub async fn init(&self) -> Result<()> { let catalog_name = CatalogNameKey::new(DEFAULT_CATALOG_NAME); - let schema_name = SchemaNameKey::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME); + let public_schema_name = SchemaNameKey::new(DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME); + let private_schema_name = + SchemaNameKey::new(DEFAULT_CATALOG_NAME, DEFAULT_PRIVATE_SCHEMA_NAME); self.catalog_manager().create(catalog_name, true).await?; self.schema_manager() - .create(schema_name, None, true) + .create(public_schema_name, None, true) + .await?; + self.schema_manager() + .create(private_schema_name, None, true) .await?; Ok(()) diff --git a/tests-integration/src/tests/instance_test.rs b/tests-integration/src/tests/instance_test.rs index 5e0ecf62af44..d6ba55f2a077 100644 --- a/tests-integration/src/tests/instance_test.rs +++ b/tests-integration/src/tests/instance_test.rs @@ -443,11 +443,12 @@ async fn test_execute_show_databases_tables(instance: Arc) { Output::RecordBatches(databases) => { let databases = databases.take(); assert_eq!(1, databases[0].num_columns()); - assert_eq!(databases[0].column(0).len(), 2); + assert_eq!(databases[0].column(0).len(), 3); assert_eq!( *databases[0].column(0), Arc::new(StringVector::from(vec![ + Some("greptime_private"), Some("information_schema"), Some("public") ])) as VectorRef diff --git a/tests/cases/standalone/common/create/create_database.result b/tests/cases/standalone/common/create/create_database.result index c684869e9d24..e90fd42325bd 100644 --- a/tests/cases/standalone/common/create/create_database.result +++ b/tests/cases/standalone/common/create/create_database.result @@ -11,6 +11,7 @@ show databases; +--------------------+ | Schemas | +--------------------+ +| greptime_private | | illegal-database | | information_schema | | public | diff --git a/tests/cases/standalone/common/show/show_databases_tables.result b/tests/cases/standalone/common/show/show_databases_tables.result index c4e4f402603e..7e6329a8bb7a 100644 --- a/tests/cases/standalone/common/show/show_databases_tables.result +++ b/tests/cases/standalone/common/show/show_databases_tables.result @@ -3,6 +3,7 @@ show databases; +-----------------------+ | Schemas | +-----------------------+ +| greptime_private | | illegal-database | | information_schema | | public |