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
60
61
62
63
64
65
66
67
68
//! Schema-expression evaluation context
//!
//! SQLite rejects non-deterministic uses of the date/time functions (a call
//! that resolves its time-value to the current time — `'now'` or a
//! zero-argument default like `date()` — or that applies a `'localtime'` /
//! `'utc'` modifier) when the call is evaluated inside a schema-attached
//! expression: a CHECK constraint, a generated column, or an index expression
//! (including a partial index's WHERE predicate).
//!
//! Crucially this is an EVALUATION-time check, not a DDL-time one:
//! `CREATE TABLE t(a CHECK(a < julianday('now')))` succeeds, and the error
//! fires when the expression is first evaluated (INSERT/UPDATE/CREATE INDEX
//! build). The trigger can come from row data (`date(x)` with `x = 'now'`),
//! which no static schema scan can detect.
//!
//! `SchemaExprContext` is carried by `ExpressionEvaluator` and threaded into
//! `eval_scalar_function`, where the date/time functions consult it.
//!
//! SQLite reference: date.c `setDateTimeToCurrent`/`toLocaltime` calling
//! `sqlite3NotPureFunc` for expressions compiled with `OP_PureFunc`
//! (`NC_IsCheck` / `NC_GenCol` / `NC_IdxExpr` / `NC_PartIdx`).
use crateExecutorError;
/// The schema-attached expression context an expression is being evaluated
/// in, if any. `None` (the default) means an ordinary query context where
/// non-deterministic date/time functions are allowed.