Repository navigation
Commit dfd4332
committed
Phase 21c: correlated subqueries — subquery story complete
- Binder: innermost-first outer-scope resolution; subplans carry their
correlation set (bound outer identities); nested/grandparent
correlation supported in binding and oracle. Structural dispatch on
empty correlation set keeps all uncorrelated behavior byte-identical.
- Oracle spec: correlated subqueries evaluate per outer row with
substituted correlation values — scalar per-row cardinality rules
(0=NULL/1=value/>1=loud error at the offending row, oracle order
defining timing), IN/EXISTS per-row 3VL matrices.
- Decorrelation (the payoff): CorrelatedExistsToSemiJoin /
CorrelatedNotExistsToAntiJoin / CorrelatedInToSemiJoin fire when
correlation appears only as top-level equality conjuncts in the
subquery WHERE — correlation conjuncts become join equi-keys via a
synthesized key projection. Proofs cover the 3VL corners (NULL
correlation values never match == per-row UNKNOWN rejection).
Blocked shapes each negative-tested: non-equality correlation,
OR/AND-embedded, correlation in projections/aggregates/HAVING/ON,
result-shaping nodes above WHERE, depth>1 rewrites, scalar, NOT IN.
- Cost: materialized correlated evaluation = subplan cost x outer rows
(documented) — extract_best genuinely chooses the semi join; EXPLAIN
golden pins the decorrelated winner.
- Vectorized: decorrelated plans run natively; residual correlated
plans throw one recognizable guard, harness asserts it and verifies
those queries oracle-side (399 guard paths per fuzzer run).
- Fuzzer: 320 queries, 12348 execution paths, 5343 alternatives; 32
firings per correlated rule; prior uncorrelated firings unchanged.
Implemented in one pass; reviewed, gate-verified,
merged by lead.1 parent ca1188f commit dfd4332
18 files changed
Lines changed: 1358 additions & 124 deletions
File tree
- docs
- include
- optimizer
- plan
- src
- execution
- optimizer
- plan
- sql
- tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
203 | 250 | | |
204 | 251 | | |
205 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| |||
0 commit comments