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
// SPDX-License-Identifier: Apache-2.0
//! Materialization of declared column DEFAULTs into a parsed `VALUES` row set.
use crateSqlCatalog;
use crateResult;
use crateColumnDefaults;
use crate*;
/// Materialize declared DEFAULTs across a whole `VALUES` row set.
///
/// This is the one place a declared DEFAULT becomes a value, for every
/// engine. The plan an engine receives carries the materialized cell like a
/// supplied one, and nothing downstream reads the catalog's DEFAULT text
/// again, so one expression yields one value on every engine.
///
/// Two rules the ordering encodes:
///
/// - A column the statement SUPPLIED is never touched, and that includes an
/// explicit `NULL`. `NULL` is a value the author chose; overwriting it with
/// the default would make it impossible to store one.
/// - Materialized values are appended BEFORE the caller's declared-type
/// coercion and range checks, so a default is validated exactly like a
/// supplied literal. Filling them in afterwards would make `DEFAULT 999999`
/// on a `SMALLINT` column a way to store a value the same literal is
/// rejected for.
///
/// Every declaration compiles once, before the row loop, so a multi-row
/// `VALUES` clause parses each DEFAULT expression exactly once.
///
/// A DEFAULT the evaluator cannot resolve raises `SqlError::UnevaluableDefault`
/// rather than leaving the column out. `catalog` resolves `nextval` / `currval`.
///
/// Returns whether any materialized default was volatile, so the caller can
/// keep the plan out of the plan cache.
pub