mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-16 13:00:40 +00:00
fix: duplicate information_schema (#2979)
* fix: duplicate information_schema * chore: style * fix: comment in sqlness
This commit is contained in:
@@ -127,13 +127,11 @@ impl CatalogManager for KvBackendCatalogManager {
|
||||
.try_collect::<BTreeSet<_>>()
|
||||
.await
|
||||
.map_err(BoxedError::new)
|
||||
.context(ListSchemasSnafu { catalog })?
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
.context(ListSchemasSnafu { catalog })?;
|
||||
|
||||
keys.extend_from_slice(&self.system_catalog.schema_names());
|
||||
keys.extend(self.system_catalog.schema_names());
|
||||
|
||||
Ok(keys)
|
||||
Ok(keys.into_iter().collect())
|
||||
}
|
||||
|
||||
async fn table_names(&self, catalog: &str, schema: &str) -> CatalogResult<Vec<String>> {
|
||||
|
||||
@@ -143,6 +143,12 @@ impl MemoryCatalogManager {
|
||||
schema: DEFAULT_PRIVATE_SCHEMA_NAME.to_string(),
|
||||
})
|
||||
.unwrap();
|
||||
manager
|
||||
.register_schema_sync(RegisterSchemaRequest {
|
||||
catalog: DEFAULT_CATALOG_NAME.to_string(),
|
||||
schema: INFORMATION_SCHEMA_NAME.to_string(),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
manager
|
||||
}
|
||||
@@ -256,6 +262,7 @@ impl MemoryCatalogManager {
|
||||
Arc::downgrade(self) as Weak<dyn CatalogManager>,
|
||||
);
|
||||
let information_schema = information_schema_provider.tables().clone();
|
||||
|
||||
let mut catalog = HashMap::new();
|
||||
catalog.insert(INFORMATION_SCHEMA_NAME.to_string(), information_schema);
|
||||
catalog
|
||||
|
||||
@@ -64,7 +64,7 @@ use std::sync::Arc;
|
||||
|
||||
use bytes::Bytes;
|
||||
use common_catalog::consts::{
|
||||
DEFAULT_CATALOG_NAME, DEFAULT_PRIVATE_SCHEMA_NAME, DEFAULT_SCHEMA_NAME,
|
||||
DEFAULT_CATALOG_NAME, DEFAULT_PRIVATE_SCHEMA_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME,
|
||||
};
|
||||
use common_telemetry::warn;
|
||||
use datanode_table::{DatanodeTableKey, DatanodeTableManager, DatanodeTableValue};
|
||||
@@ -297,17 +297,20 @@ impl TableMetadataManager {
|
||||
|
||||
pub async fn init(&self) -> Result<()> {
|
||||
let catalog_name = CatalogNameKey::new(DEFAULT_CATALOG_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(public_schema_name, None, true)
|
||||
.await?;
|
||||
self.schema_manager()
|
||||
.create(private_schema_name, None, true)
|
||||
.await?;
|
||||
|
||||
let internal_schemas = [
|
||||
DEFAULT_SCHEMA_NAME,
|
||||
INFORMATION_SCHEMA_NAME,
|
||||
DEFAULT_PRIVATE_SCHEMA_NAME,
|
||||
];
|
||||
|
||||
for schema_name in internal_schemas {
|
||||
let schema_key = SchemaNameKey::new(DEFAULT_CATALOG_NAME, schema_name);
|
||||
|
||||
self.schema_manager().create(schema_key, None, true).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
-- should not able to create information_schema
|
||||
create database information_schema;
|
||||
|
||||
Error: 1004(InvalidArguments), Schema information_schema already exists
|
||||
|
||||
-- scripts table has different table ids in different modes
|
||||
select *
|
||||
from information_schema.tables
|
||||
@@ -37,24 +42,24 @@ select * from information_schema.columns order by table_schema, table_name;
|
||||
| greptime | information_schema | column_statistics | column_name | String | FIELD |
|
||||
| greptime | information_schema | column_statistics | table_name | String | FIELD |
|
||||
| greptime | information_schema | column_statistics | schema_name | String | FIELD |
|
||||
| greptime | information_schema | columns | table_schema | String | FIELD |
|
||||
| greptime | information_schema | columns | table_name | String | FIELD |
|
||||
| greptime | information_schema | columns | semantic_type | String | FIELD |
|
||||
| greptime | information_schema | columns | data_type | String | FIELD |
|
||||
| greptime | information_schema | columns | column_name | String | FIELD |
|
||||
| greptime | information_schema | columns | table_name | String | FIELD |
|
||||
| greptime | information_schema | columns | table_schema | String | FIELD |
|
||||
| greptime | information_schema | columns | table_catalog | String | FIELD |
|
||||
| greptime | information_schema | engines | xa | String | FIELD |
|
||||
| greptime | information_schema | engines | savepoints | String | FIELD |
|
||||
| greptime | information_schema | engines | xa | String | FIELD |
|
||||
| greptime | information_schema | engines | transactions | String | FIELD |
|
||||
| greptime | information_schema | engines | comment | String | FIELD |
|
||||
| greptime | information_schema | engines | support | String | FIELD |
|
||||
| greptime | information_schema | engines | engine | String | FIELD |
|
||||
| greptime | information_schema | tables | table_schema | String | FIELD |
|
||||
| greptime | information_schema | tables | table_catalog | String | FIELD |
|
||||
| greptime | information_schema | tables | engine | String | FIELD |
|
||||
| greptime | information_schema | tables | table_id | UInt32 | FIELD |
|
||||
| greptime | information_schema | tables | table_type | String | FIELD |
|
||||
| greptime | information_schema | tables | table_name | String | FIELD |
|
||||
| greptime | information_schema | tables | table_schema | String | FIELD |
|
||||
| greptime | public | numbers | number | UInt32 | TAG |
|
||||
+---------------+--------------------+-------------------+------------------+-----------+---------------+
|
||||
|
||||
@@ -103,7 +108,7 @@ from information_schema.columns
|
||||
where table_catalog = 'greptime'
|
||||
and table_schema != 'public'
|
||||
and table_schema != 'information_schema'
|
||||
order by table_schema, table_name;
|
||||
order by table_schema, table_name, column_name;
|
||||
|
||||
+---------------+--------------+------------+-------------+----------------------+---------------+
|
||||
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
-- should not able to create information_schema
|
||||
create database information_schema;
|
||||
|
||||
-- scripts table has different table ids in different modes
|
||||
select *
|
||||
from information_schema.tables
|
||||
@@ -33,7 +36,7 @@ from information_schema.columns
|
||||
where table_catalog = 'greptime'
|
||||
and table_schema != 'public'
|
||||
and table_schema != 'information_schema'
|
||||
order by table_schema, table_name;
|
||||
order by table_schema, table_name, column_name;
|
||||
|
||||
use public;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user