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
//! The logical operator: what an operator is once names are resolved and OIDs
//! are gone.
//!
//! Loading lives in `catalog::raw::operator`.
use super::id::{DbObjectId, DependsOn};
/// A user-defined PostgreSQL operator (`CREATE OPERATOR`).
///
/// An operator is identified by its schema, symbol, and the types of its two
/// operands. Prefix operators have no left operand; their left operand type is
/// recorded as `NONE` (matching the `DROP`/`COMMENT` `(left, right)` syntax).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Operator {
pub schema: String,
/// The operator symbol, e.g. `===` or `@>`.
pub name: String,
/// Canonical `"left, right"` operand-type string, with `NONE` for an absent
/// operand (prefix operators). Matches the `(left, right)` form that
/// `DROP OPERATOR` and `COMMENT ON OPERATOR` require.
pub arguments: String,
/// The full reconstructed `CREATE OPERATOR` statement (no trailing `;`).
pub definition: String,
pub comment: Option<String>,
pub depends_on: Vec<DbObjectId>,
}
impl Operator {
pub fn id(&self) -> DbObjectId {
DbObjectId::Operator {
schema: self.schema.clone(),
name: self.name.clone(),
arguments: self.arguments.clone(),
}
}
}
impl DependsOn for Operator {
fn id(&self) -> DbObjectId {
DbObjectId::Operator {
schema: self.schema.clone(),
name: self.name.clone(),
arguments: self.arguments.clone(),
}
}
fn depends_on(&self) -> &[DbObjectId] {
&self.depends_on
}
}