Skip to main content

safe_migrate/model/
function.rs

1use crate::ast::identifiers::ObjectId;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub enum Volatility {
6    Volatile,
7    Stable,
8    Immutable,
9}
10
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub enum SecurityMode {
13    Invoker,
14    Definer,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub struct FunctionState {
19    pub id: ObjectId,
20    pub arg_types: Vec<String>,
21    /// Derived from `arg_types` when a cache enters analysis. Keeping it out
22    /// of the cache preserves the V5 binary format.
23    #[serde(skip)]
24    pub arg_type_ids: Vec<Option<ObjectId>>,
25    pub return_type: String,
26    /// Derived from `return_type` when a cache enters analysis. Keeping it out
27    /// of the cache preserves the V5 binary format.
28    #[serde(skip)]
29    pub return_type_id: Option<ObjectId>,
30    pub volatility: Volatility,
31    pub language: String,
32    pub security: SecurityMode,
33}
34
35#[derive(Debug, Clone, PartialEq)]
36#[allow(clippy::large_enum_variant)] // Overlay transitions stay allocation-free in the hot state path.
37pub enum FunctionOverlay {
38    Present(FunctionState),
39    Dropped,
40}