1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The logical aggregate: what an aggregate is once names are resolved and
//! OIDs are gone.
//!
//! Loading lives in `catalog::raw::aggregate`.
use super::id::{DbObjectId, DependsOn};
/// Represents a PostgreSQL aggregate function
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Aggregate {
pub schema: String,
pub name: String,
/// Formatted argument types (e.g., "integer, text")
pub arguments: String,
/// State type element name for dependency tracking (arrays resolve to base type)
pub state_type: String,
pub state_type_schema: String,
/// Full formatted state type for SQL rendering (preserves array brackets)
pub state_type_formatted: String,
/// State transition function (SFUNC)
pub state_func: String,
pub state_func_schema: String,
/// Final function (FINALFUNC), optional
pub final_func: Option<String>,
pub final_func_schema: Option<String>,
/// Combine function for parallel aggregation (COMBINEFUNC), optional
pub combine_func: Option<String>,
pub combine_func_schema: Option<String>,
/// Initial state value (INITCOND), optional
pub initial_value: Option<String>,
/// Complete CREATE AGGREGATE statement (reconstructed)
pub definition: String,
pub comment: Option<String>,
pub depends_on: Vec<DbObjectId>,
}
impl Aggregate {
pub fn id(&self) -> DbObjectId {
DbObjectId::Aggregate {
schema: self.schema.clone(),
name: self.name.clone(),
arguments: self.arguments.clone(),
}
}
}
impl DependsOn for Aggregate {
fn id(&self) -> DbObjectId {
DbObjectId::Aggregate {
schema: self.schema.clone(),
name: self.name.clone(),
arguments: self.arguments.clone(),
}
}
fn depends_on(&self) -> &[DbObjectId] {
&self.depends_on
}
}