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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! The row-production classification — whether a concluding clause,
//! part or body projects statement rows of its own. The query-structure
//! levels — the FINAL-stage cursor, the any-arm fold, the
//! concluding-clause hand-off — are the one shared body-descent
//! skeleton in the IR (ADR-0740: `relate_ir::stage_projects_rows`,
//! `Query::final_stage_projects_rows`), into which this layer injects
//! its concluding-clause verdict ([`spills_concluding`]); this module
//! keeps the one concluding-clause decision ([`concluding`]) that verdict
//! and the NEXT-seeding one ([`unit_output_concluding`]) project, the
//! stage/body entries its consumers read, and the NEXT-seeding fold
//! ([`parts_have_unit_output`]), split out of the statement-driver root so
//! the classification lives beside its own vocabulary instead of inside
//! the drivers. The conditional's branch-set model is its own sibling
//! ([`super::conditional_branches`]); this verdict consumes it
//! downward.
use ;
use clause_projects_rows;
use ConditionalBranches;
/// Whether a `CALL { … }` / `WHEN` body projects a statement result of
/// its own — its FINAL stage's arms, through the one shared
/// body-descent skeleton (ADR-0740) under this layer's
/// [`spills_concluding`] verdict; a body that is itself a NEXT chain is
/// judged by its final stage, never its first, the exact wrong-cursor
/// drop fixed before the skeleton had one home. Read by every
/// body-level consumer: the CALL-subquery driver's merge policy
/// (`call::call_subquery_row`), the conditional driver's per-row branch
/// read (`call::conditional::exec_conditional`), the batch-pass
/// admission (`call::in_tx_strategy::batch_pass_admission`) and
/// [`spills_concluding`]'s own nested-body descent — this layer's
/// descent under the shared skeleton, where the naming layer's
/// (`relate_ir::Query::projects_columns`) is the twin verdict over the
/// same structure walk; the agreement test beside this module pins the
/// two verdicts' answers over the nested-body vocabulary.
pub
/// Whether any UNION arm of one stage projects a statement result of its
/// own — the stage-level entry of the shared body-descent skeleton
/// (ADR-0740) under [`spills_concluding`], over a stage's parts slice.
/// The slice is the type-level distinction: a whole NEXT-chained body is
/// not a stage, and only [`body_projects_rows`] — the FINAL-stage
/// cursor's one owner here — may hand one in.
/// `execute_query_seeded_in_scope` (in `call`) is the one stage-level
/// caller, naming the stage it runs; every other consumer reads
/// [`body_projects_rows`]. The privacy fence covers exec-level
/// consumers; `call`'s descendants stay on it by this doc, since an
/// item fenced to `crate::exec` remains nameable from them.
pub
/// The executor's one decision over the clause concluding an arm, under
/// the shared body-descent skeleton (ADR-0740): its two answers are the
/// two concluding-clause policies this layer reads, decided together per
/// clause so they cannot drift. Built by [`concluding`]; read through
/// its two projections, [`spills_concluding`] and
/// [`unit_output_concluding`].
/// The executor's concluding-clause decision, one exhaustive match: the
/// planner's published [`clause_projects_rows`] table — position-agnostic,
/// read once in the catch-all arm (a projecting clause spills rows and
/// is not unit output; a non-projecting one the reverse) — plus the
/// three position-specific refinements only this layer can make, each
/// arm spelling both answers together:
///
/// - a `WHEN`/`ELSE` conditional spills rows exactly when some branch
/// body does (a conditional whose branch bodies are all unit leaves
/// the per-row driver's buckets empty), and is unit output exactly
/// when it spills none;
/// - a `CALL { … }` spills its body's answer — except the batched form,
/// which keeps the table's unconditional answer: `CALL { … } IN
/// TRANSACTIONS` always spills rows (each batch's pass-through rows,
/// `REPORT STATUS` rows, `ON ERROR` pads), whatever its body, the one
/// arm the naming twin deliberately does not share (a unit batched
/// call stays columnless there: its rows are the outer pass-through,
/// not body columns). Either form is unit output: a data write in the
/// ADR-0287 vocabulary even when its merged rows are a statement
/// result of its own;
/// - a concluding procedure call spills no rows (as the naming twin
/// rules), and is unit output only when it is void.
///
/// `descend` is the skeleton's body descent under the spills answer —
/// [`body_projects_rows`] — for both projections: a unit conditional
/// body is a unit body everywhere, so its caller's outer rows pass
/// through, never drop, and its `IN TRANSACTIONS` iterations report
/// their status rows.
/// The spills answer of [`concluding`] — the executor's
/// [`relate_ir::ConcludingVerdict`] injected into the shared
/// body-descent skeleton (ADR-0740); the descent the skeleton hands back
/// is this same verdict's recursion.
/// The unit-output answer of [`concluding`] — the NEXT-seeding rule's
/// concluding-clause verdict (ADR-0287), riding the shared verdict
/// seam's shape (the clause, with the spills descent handed in) like the
/// two policies the seam exists for.
/// Whether a finished stage seeds the next `NEXT` stage with one unit row
/// when its own result is empty (ADR-0287). Data-write parts
/// (`CREATE`/`MERGE`/`DELETE`/`SET`/`REMOVE`/`FOREACH`/`CALL { … }`) and
/// `FINISH` count, and so do void procedure calls and schema/admin DDL
/// parts — the IR-native
/// index/constraint variants outright, and `Clause::Catalog` exactly when
/// the canonical `relate-front` predicate says the command is NOT
/// row-producing. Row-producing catalog commands (the SHOW family and
/// `TERMINATE TRANSACTIONS`) keep their row semantics: they seed the next
/// stage from their projected rows, never with a unit row.
///
/// The stage walk and its invariants are the skeleton's
/// ([`relate_ir::stage_concluding_clauses`] — the all-form enumeration,
/// with the non-empty-stage and non-empty-part invariants surfaced
/// there, once); this fold only supplies the seeding rule's own
/// verdict ([`unit_output_concluding`]).
pub