pub const DEPTH_CEILING: usize = 8;Expand description
How deep a record’s aliases are minted where its declaration names no number, and therefore how deep a relation over such a record may nest before the engine refuses.
§A DEFAULT rather than a wall, and the array is what the refusal reads
The aliases are emitted as a SLICE beside the row’s address, so the length is a fact about one
(record, database) pair rather than part of a trait item’s type — and ingraph’s
RelationDepthError carries that slice’s own length. So a declaration whose filters nest deeper
writes <db>(alias(depth = 16)) and gets sixteen, refusing at sixteen and saying so,
with no engine holding a second copy of the number.
Eight is chosen against what a relation predicate actually nests: each level is a subquery inside
a subquery over the same statement, and a filter written by hand or generated from a wire query
reaches two or three. The cost of the unused tail is eight &'static str per record per
database, which is a pointer pair each in the binary’s read-only data and nothing at all at
runtime.
Past whatever was minted the lowering REFUSES, naming the table and both numbers — see
ingraph’s SqlLoweringError::RelationDepth. Refusing is the whole point of having a number at
all: the alternative to a depth is not “no limit” but a name reused at some depth nobody chose,
which SQL resolves to the inner scope without complaining.