common_function/system/pg_catalog/
version.rs1use std::sync::Arc;
16use std::{env, fmt};
17
18use common_query::error::Result;
19use common_query::prelude::{Signature, Volatility};
20use datatypes::data_type::ConcreteDataType;
21use datatypes::vectors::{StringVector, VectorRef};
22
23use crate::function::{Function, FunctionContext};
24
25#[derive(Clone, Debug, Default)]
26pub(crate) struct PGVersionFunction;
27
28impl fmt::Display for PGVersionFunction {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 write!(f, crate::pg_catalog_func_fullname!("VERSION"))
31 }
32}
33
34impl Function for PGVersionFunction {
35 fn name(&self) -> &str {
36 crate::pg_catalog_func_fullname!("version")
37 }
38
39 fn return_type(&self, _input_types: &[ConcreteDataType]) -> Result<ConcreteDataType> {
40 Ok(ConcreteDataType::string_datatype())
41 }
42
43 fn signature(&self) -> Signature {
44 Signature::exact(vec![], Volatility::Immutable)
45 }
46
47 fn eval(&self, _func_ctx: &FunctionContext, _columns: &[VectorRef]) -> Result<VectorRef> {
48 let result = StringVector::from(vec![format!(
49 "PostgreSQL 16.3 GreptimeDB {}",
50 env!("CARGO_PKG_VERSION")
51 )]);
52 Ok(Arc::new(result))
53 }
54}