nodedb_sql/ddl_ast/statement/collection.rs
1// SPDX-License-Identifier: Apache-2.0
2
3use nodedb_types::{AuditDmlMode, QuotaSpec};
4
5/// Temporal anchor for a `CLONE DATABASE` statement.
6///
7/// Every `match` on this enum must be exhaustive — no `_ =>` arms.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum CloneAsOf {
10 /// Use the source database's current commit LSN at clone time.
11 /// Corresponds to the bare `CLONE DATABASE … FROM …` form or the
12 /// explicit `… AS OF SYSTEM TIME LATEST` form.
13 Latest,
14 /// Use the LSN corresponding to the given milliseconds-since-epoch
15 /// timestamp, resolved via the `LsnMsAnchor` mechanism.
16 ///
17 /// Corresponds to `… AS OF SYSTEM TIME <ms>`.
18 SystemTimeMs(i64),
19}
20
21/// Operations available on `ALTER DATABASE <name> <operation>`.
22///
23/// Every variant must be matched exhaustively — no `_ =>` arms anywhere.
24#[derive(Debug, Clone, PartialEq, Eq)]
25pub enum AlterDatabaseOperation {
26 /// `ALTER DATABASE <name> RENAME TO <new_name>`
27 Rename { new_name: String },
28 /// `ALTER DATABASE <name> SET QUOTA (max_memory_bytes = ..., ...)`
29 ///
30 /// All fields in the spec are optional; absent fields leave the existing
31 /// quota value unchanged (merged at apply time with the stored record or
32 /// `QuotaRecord::DEFAULT`).
33 SetQuota(QuotaSpec),
34 /// `ALTER DATABASE <name> SET DEFAULT` — marks this database as the
35 /// per-user default for future sessions. Returns
36 /// `FEATURE_NOT_YET_IMPLEMENTED` until the per-user default-database
37 /// binding lands; the canonical path is
38 /// `ALTER USER <name> SET DEFAULT DATABASE <db>`.
39 SetDefault,
40 /// `ALTER DATABASE <name> MATERIALIZE` — triggers background materialization
41 /// of a cloned database. Returns `FEATURE_NOT_YET_IMPLEMENTED` until the
42 /// clone/mirror subsystem lands.
43 Materialize,
44 /// `ALTER DATABASE <name> PROMOTE` — promotes a mirror to writable primary.
45 /// Returns `FEATURE_NOT_YET_IMPLEMENTED` until the mirror subsystem lands.
46 Promote,
47 /// `ALTER DATABASE <name> SET AUDIT_DML = <mode>` — sets the DML audit level.
48 SetAuditDml(AuditDmlMode),
49 /// `ALTER DATABASE <name> SET IDLE_TIMEOUT = <secs>` — sets the idle session
50 /// timeout in seconds for sessions in this database. `0` disables the per-database
51 /// timeout (falls back to the global `idle_timeout_secs` setting).
52 SetIdleTimeout(u64),
53}
54
55/// Operations available on `ALTER TENANT <name> IN DATABASE <db> <operation>`.
56///
57/// Every variant must be matched exhaustively — no `_ =>` arms anywhere.
58#[derive(Debug, Clone, PartialEq, Eq)]
59pub enum AlterTenantOperation {
60 /// `ALTER TENANT <name> IN DATABASE <db> SET QUOTA (...)`
61 SetQuota(QuotaSpec),
62}