common_function/
system.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15mod build;
16mod database;
17mod pg_catalog;
18mod procedure_state;
19mod timezone;
20mod version;
21
22use std::sync::Arc;
23
24use build::BuildFunction;
25use database::{
26    ConnectionIdFunction, CurrentSchemaFunction, DatabaseFunction, PgBackendPidFunction,
27    ReadPreferenceFunction, SessionUserFunction,
28};
29use pg_catalog::PGCatalogFunction;
30use procedure_state::ProcedureStateFunction;
31use timezone::TimezoneFunction;
32use version::VersionFunction;
33
34use crate::function_registry::FunctionRegistry;
35
36pub(crate) struct SystemFunction;
37
38impl SystemFunction {
39    pub fn register(registry: &FunctionRegistry) {
40        registry.register_scalar(BuildFunction);
41        registry.register_scalar(VersionFunction);
42        registry.register_scalar(CurrentSchemaFunction);
43        registry.register_scalar(DatabaseFunction);
44        registry.register_scalar(SessionUserFunction);
45        registry.register_scalar(ReadPreferenceFunction);
46        registry.register_scalar(PgBackendPidFunction);
47        registry.register_scalar(ConnectionIdFunction);
48        registry.register_scalar(TimezoneFunction);
49        registry.register_async(Arc::new(ProcedureStateFunction));
50        PGCatalogFunction::register(registry);
51    }
52}