Skip to main content

surrealdb_expr/expr/statements/alter/
system.rs

1use surrealdb_types::{SqlFormat, ToSql};
2
3use crate::expr::Expr;
4use crate::expr::statements::alter::AlterKind;
5
6#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
7/// Alters system-wide settings and maintenance operations.
8///
9/// Supported operations:
10/// - `query_timeout`: set/drop a global query timeout which is enforced across queries. The value
11///   is evaluated as a `Duration` expression at runtime.
12/// - `compact`: runs a storage compaction across the entire datastore.
13pub struct AlterSystemStatement {
14	/// Global query timeout alteration. `Set` evaluates an expression to a
15	/// `Duration`; `Drop` clears the timeout; `None` leaves it unchanged.
16	pub query_timeout: AlterKind<Expr>,
17	/// When true, triggers a datastore-wide compaction.
18	pub compact: bool,
19}
20
21impl ToSql for AlterSystemStatement {
22	fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
23		let stmt: crate::sql::statements::alter::AlterSystemStatement = self.clone().into();
24		stmt.fmt_sql(f, fmt);
25	}
26}