mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
Compare commits
2 Commits
c112cdf241
...
8f9674440f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f9674440f | ||
|
|
a29681eb12 |
@@ -29,6 +29,7 @@ use crate::information_schema::{InformationExtensionRef, InformationSchemaProvid
|
|||||||
use crate::kvbackend::manager::{SystemCatalog, CATALOG_CACHE_MAX_CAPACITY};
|
use crate::kvbackend::manager::{SystemCatalog, CATALOG_CACHE_MAX_CAPACITY};
|
||||||
use crate::kvbackend::KvBackendCatalogManager;
|
use crate::kvbackend::KvBackendCatalogManager;
|
||||||
use crate::process_manager::ProcessManagerRef;
|
use crate::process_manager::ProcessManagerRef;
|
||||||
|
use crate::system_schema::numbers_table_provider::NumbersTableProvider;
|
||||||
use crate::system_schema::pg_catalog::PGCatalogProvider;
|
use crate::system_schema::pg_catalog::PGCatalogProvider;
|
||||||
|
|
||||||
pub struct KvBackendCatalogManagerBuilder {
|
pub struct KvBackendCatalogManagerBuilder {
|
||||||
@@ -119,6 +120,7 @@ impl KvBackendCatalogManagerBuilder {
|
|||||||
DEFAULT_CATALOG_NAME.to_string(),
|
DEFAULT_CATALOG_NAME.to_string(),
|
||||||
me.clone(),
|
me.clone(),
|
||||||
)),
|
)),
|
||||||
|
numbers_table_provider: NumbersTableProvider,
|
||||||
backend,
|
backend,
|
||||||
process_manager,
|
process_manager,
|
||||||
#[cfg(feature = "enterprise")]
|
#[cfg(feature = "enterprise")]
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ use std::sync::{Arc, Weak};
|
|||||||
|
|
||||||
use async_stream::try_stream;
|
use async_stream::try_stream;
|
||||||
use common_catalog::consts::{
|
use common_catalog::consts::{
|
||||||
DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME, NUMBERS_TABLE_ID,
|
DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME, PG_CATALOG_NAME,
|
||||||
PG_CATALOG_NAME,
|
|
||||||
};
|
};
|
||||||
use common_error::ext::BoxedError;
|
use common_error::ext::BoxedError;
|
||||||
use common_meta::cache::{
|
use common_meta::cache::{
|
||||||
@@ -43,7 +42,6 @@ use snafu::prelude::*;
|
|||||||
use store_api::metric_engine_consts::METRIC_ENGINE_NAME;
|
use store_api::metric_engine_consts::METRIC_ENGINE_NAME;
|
||||||
use table::dist_table::DistTable;
|
use table::dist_table::DistTable;
|
||||||
use table::metadata::{TableId, TableInfoRef};
|
use table::metadata::{TableId, TableInfoRef};
|
||||||
use table::table::numbers::{NumbersTable, NUMBERS_TABLE_NAME};
|
|
||||||
use table::table_name::TableName;
|
use table::table_name::TableName;
|
||||||
use table::TableRef;
|
use table::TableRef;
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
@@ -58,6 +56,7 @@ use crate::information_schema::InformationSchemaTableFactoryRef;
|
|||||||
use crate::information_schema::{InformationExtensionRef, InformationSchemaProvider};
|
use crate::information_schema::{InformationExtensionRef, InformationSchemaProvider};
|
||||||
use crate::kvbackend::TableCacheRef;
|
use crate::kvbackend::TableCacheRef;
|
||||||
use crate::process_manager::ProcessManagerRef;
|
use crate::process_manager::ProcessManagerRef;
|
||||||
|
use crate::system_schema::numbers_table_provider::NumbersTableProvider;
|
||||||
use crate::system_schema::pg_catalog::PGCatalogProvider;
|
use crate::system_schema::pg_catalog::PGCatalogProvider;
|
||||||
use crate::system_schema::SystemSchemaProvider;
|
use crate::system_schema::SystemSchemaProvider;
|
||||||
use crate::CatalogManager;
|
use crate::CatalogManager;
|
||||||
@@ -537,6 +536,7 @@ pub(super) struct SystemCatalog {
|
|||||||
// system_schema_provider for default catalog
|
// system_schema_provider for default catalog
|
||||||
pub(super) information_schema_provider: Arc<InformationSchemaProvider>,
|
pub(super) information_schema_provider: Arc<InformationSchemaProvider>,
|
||||||
pub(super) pg_catalog_provider: Arc<PGCatalogProvider>,
|
pub(super) pg_catalog_provider: Arc<PGCatalogProvider>,
|
||||||
|
pub(super) numbers_table_provider: NumbersTableProvider,
|
||||||
pub(super) backend: KvBackendRef,
|
pub(super) backend: KvBackendRef,
|
||||||
pub(super) process_manager: Option<ProcessManagerRef>,
|
pub(super) process_manager: Option<ProcessManagerRef>,
|
||||||
#[cfg(feature = "enterprise")]
|
#[cfg(feature = "enterprise")]
|
||||||
@@ -566,9 +566,7 @@ impl SystemCatalog {
|
|||||||
PG_CATALOG_NAME if channel == Channel::Postgres => {
|
PG_CATALOG_NAME if channel == Channel::Postgres => {
|
||||||
self.pg_catalog_provider.table_names()
|
self.pg_catalog_provider.table_names()
|
||||||
}
|
}
|
||||||
DEFAULT_SCHEMA_NAME => {
|
DEFAULT_SCHEMA_NAME => self.numbers_table_provider.table_names(),
|
||||||
vec![NUMBERS_TABLE_NAME.to_string()]
|
|
||||||
}
|
|
||||||
_ => vec![],
|
_ => vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,7 +584,7 @@ impl SystemCatalog {
|
|||||||
if schema == INFORMATION_SCHEMA_NAME {
|
if schema == INFORMATION_SCHEMA_NAME {
|
||||||
self.information_schema_provider.table(table).is_some()
|
self.information_schema_provider.table(table).is_some()
|
||||||
} else if schema == DEFAULT_SCHEMA_NAME {
|
} else if schema == DEFAULT_SCHEMA_NAME {
|
||||||
table == NUMBERS_TABLE_NAME
|
self.numbers_table_provider.table_exists(table)
|
||||||
} else if schema == PG_CATALOG_NAME && channel == Channel::Postgres {
|
} else if schema == PG_CATALOG_NAME && channel == Channel::Postgres {
|
||||||
self.pg_catalog_provider.table(table).is_some()
|
self.pg_catalog_provider.table(table).is_some()
|
||||||
} else {
|
} else {
|
||||||
@@ -631,8 +629,8 @@ impl SystemCatalog {
|
|||||||
});
|
});
|
||||||
pg_catalog_provider.table(table_name)
|
pg_catalog_provider.table(table_name)
|
||||||
}
|
}
|
||||||
} else if schema == DEFAULT_SCHEMA_NAME && table_name == NUMBERS_TABLE_NAME {
|
} else if schema == DEFAULT_SCHEMA_NAME {
|
||||||
Some(NumbersTable::table(NUMBERS_TABLE_ID))
|
self.numbers_table_provider.table(table_name)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
pub mod information_schema;
|
pub mod information_schema;
|
||||||
mod memory_table;
|
mod memory_table;
|
||||||
|
pub mod numbers_table_provider;
|
||||||
pub mod pg_catalog;
|
pub mod pg_catalog;
|
||||||
pub mod predicate;
|
pub mod predicate;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|||||||
59
src/catalog/src/system_schema/numbers_table_provider.rs
Normal file
59
src/catalog/src/system_schema/numbers_table_provider.rs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2023 Greptime Team
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "testing", debug_assertions))]
|
||||||
|
use common_catalog::consts::NUMBERS_TABLE_ID;
|
||||||
|
#[cfg(any(test, feature = "testing", debug_assertions))]
|
||||||
|
use table::table::numbers::NumbersTable;
|
||||||
|
#[cfg(any(test, feature = "testing", debug_assertions))]
|
||||||
|
use table::table::numbers::NUMBERS_TABLE_NAME;
|
||||||
|
use table::TableRef;
|
||||||
|
|
||||||
|
// NumbersTableProvider is a dedicated provider for feature-gating the numbers table.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct NumbersTableProvider;
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "testing", debug_assertions))]
|
||||||
|
impl NumbersTableProvider {
|
||||||
|
pub(crate) fn table_exists(&self, name: &str) -> bool {
|
||||||
|
name == NUMBERS_TABLE_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn table_names(&self) -> Vec<String> {
|
||||||
|
vec![NUMBERS_TABLE_NAME.to_string()]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn table(&self, name: &str) -> Option<TableRef> {
|
||||||
|
if name == NUMBERS_TABLE_NAME {
|
||||||
|
Some(NumbersTable::table(NUMBERS_TABLE_ID))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(test, feature = "testing", debug_assertions)))]
|
||||||
|
impl NumbersTableProvider {
|
||||||
|
pub(crate) fn table_exists(&self, _name: &str) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn table_names(&self) -> Vec<String> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn table(&self, _name: &str) -> Option<TableRef> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1066,7 +1066,7 @@ impl HttpServer {
|
|||||||
/// Route Prometheus [HTTP API].
|
/// Route Prometheus [HTTP API].
|
||||||
///
|
///
|
||||||
/// [HTTP API]: https://prometheus.io/docs/prometheus/latest/querying/api/
|
/// [HTTP API]: https://prometheus.io/docs/prometheus/latest/querying/api/
|
||||||
fn route_prometheus<S>(prometheus_handler: PrometheusHandlerRef) -> Router<S> {
|
pub fn route_prometheus<S>(prometheus_handler: PrometheusHandlerRef) -> Router<S> {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route(
|
.route(
|
||||||
"/format_query",
|
"/format_query",
|
||||||
|
|||||||
Reference in New Issue
Block a user