Commit a358e80
feat(eqp): flatten a bare-LIMIT derived/CTE body under a narrower projection or single-term ORDER BY (B9c-flatten)
Completes B9c. A bare-LIMIT body (no OFFSET) now flattens, not just under a
pure-wildcard outer, but also:
- a narrower projection with no outer WHERE — the outer projection is substituted
into the LIMIT body (`SELECT a FROM (SELECT * FROM t LIMIT 5)` -> `SCAN t USING
COVERING INDEX`), via a relaxed `inner_scan_flatten_ok` gate on the unified
merge branch;
- a single-term outer ORDER BY (no WHERE) — a dedicated branch pushes the
projection + ORDER BY into the body and recurses (`(… LIMIT 5) ORDER BY b` ->
`SCAN t USING INDEX tb`, or a full temp-b-tree when unindexed).
A multi-term outer ORDER BY still declines: SQLite full-sorts the materialized
LIMIT rows, whereas pushing it down would render a partial `LAST TERM` index walk
when the leading prefix is indexed. The merge branch now borrows `derived_map` so
it survives for the ORDER-BY branch. Existing flatten/co-routine taxonomy tests
green; new render cases added and the narrower-over-LIMIT decline replaced with
the multi-term-ORDER-BY decline.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 892ebe1 commit a358e80
3 files changed
Lines changed: 101 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1192 | 1192 | | |
1193 | 1193 | | |
1194 | 1194 | | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1205 | 1207 | | |
1206 | 1208 | | |
1207 | 1209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13861 | 13861 | | |
13862 | 13862 | | |
13863 | 13863 | | |
| 13864 | + | |
| 13865 | + | |
| 13866 | + | |
| 13867 | + | |
| 13868 | + | |
| 13869 | + | |
| 13870 | + | |
| 13871 | + | |
| 13872 | + | |
| 13873 | + | |
13864 | 13874 | | |
13865 | 13875 | | |
13866 | 13876 | | |
| |||
13969 | 13979 | | |
13970 | 13980 | | |
13971 | 13981 | | |
13972 | | - | |
| 13982 | + | |
13973 | 13983 | | |
13974 | | - | |
| 13984 | + | |
13975 | 13985 | | |
13976 | | - | |
| 13986 | + | |
13977 | 13987 | | |
13978 | 13988 | | |
13979 | 13989 | | |
13980 | 13990 | | |
13981 | 13991 | | |
13982 | | - | |
| 13992 | + | |
13983 | 13993 | | |
13984 | 13994 | | |
13985 | 13995 | | |
13986 | 13996 | | |
13987 | 13997 | | |
13988 | 13998 | | |
13989 | | - | |
| 13999 | + | |
13990 | 14000 | | |
13991 | 14001 | | |
13992 | 14002 | | |
| |||
13999 | 14009 | | |
14000 | 14010 | | |
14001 | 14011 | | |
| 14012 | + | |
| 14013 | + | |
| 14014 | + | |
| 14015 | + | |
| 14016 | + | |
| 14017 | + | |
| 14018 | + | |
| 14019 | + | |
| 14020 | + | |
| 14021 | + | |
| 14022 | + | |
| 14023 | + | |
| 14024 | + | |
| 14025 | + | |
| 14026 | + | |
| 14027 | + | |
| 14028 | + | |
| 14029 | + | |
| 14030 | + | |
| 14031 | + | |
| 14032 | + | |
| 14033 | + | |
| 14034 | + | |
| 14035 | + | |
| 14036 | + | |
| 14037 | + | |
| 14038 | + | |
| 14039 | + | |
| 14040 | + | |
| 14041 | + | |
| 14042 | + | |
| 14043 | + | |
| 14044 | + | |
| 14045 | + | |
| 14046 | + | |
| 14047 | + | |
| 14048 | + | |
| 14049 | + | |
| 14050 | + | |
| 14051 | + | |
| 14052 | + | |
| 14053 | + | |
| 14054 | + | |
| 14055 | + | |
| 14056 | + | |
| 14057 | + | |
| 14058 | + | |
| 14059 | + | |
| 14060 | + | |
| 14061 | + | |
| 14062 | + | |
| 14063 | + | |
| 14064 | + | |
| 14065 | + | |
| 14066 | + | |
| 14067 | + | |
| 14068 | + | |
| 14069 | + | |
| 14070 | + | |
| 14071 | + | |
| 14072 | + | |
14002 | 14073 | | |
14003 | 14074 | | |
14004 | 14075 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
160 | 168 | | |
161 | 169 | | |
162 | 170 | | |
| |||
187 | 195 | | |
188 | 196 | | |
189 | 197 | | |
190 | | - | |
191 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
192 | 203 | | |
193 | 204 | | |
194 | 205 | | |
| |||
0 commit comments