Commit 774e996
fix(exec): eagerly reject a bad column in a window OVER PARTITION BY / ORDER BY
A bad column reference in a window `OVER` clause's `PARTITION BY` / `ORDER BY`
(or a named `WINDOW …` definition) is a prepare-time `no such column` in SQLite,
raised even over an empty or fully-filtered table. graphite's eager column
validators bailed on any window query, and the VDBE window execution path
bypasses them too, so this was resolved only lazily, per row — missed when no
row is reached.
A window partition/order term binds strictly to a base column of the `FROM`
(never an output alias — `PARTITION BY <alias>` is `no such column` in SQLite),
so the new `validate_window_over_columns` resolves each term against the source
schema (metadata only, no row scan) with no alias-scope subtlety. It gathers
every window spec — the `WINDOW`-clause definitions plus each window function's
inline `OVER` spec in the projection and top-level `ORDER BY` — and is wired into
both `run_core`'s validator block and the `run_select_vdbe` window path (which
otherwise bypasses it). Conservatively limited to plain base-table / view
sources. Verified vs sqlite3 3.50.4 (`tests/eager_window_over_columns.rs`).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 692b0e2 commit 774e996
3 files changed
Lines changed: 171 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1518 | 1518 | | |
1519 | 1519 | | |
1520 | 1520 | | |
1521 | | - | |
1522 | | - | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
1523 | 1524 | | |
1524 | 1525 | | |
1525 | 1526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1434 | 1434 | | |
1435 | 1435 | | |
1436 | 1436 | | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
1437 | 1442 | | |
1438 | 1443 | | |
1439 | 1444 | | |
| |||
20014 | 20019 | | |
20015 | 20020 | | |
20016 | 20021 | | |
| 20022 | + | |
20017 | 20023 | | |
20018 | 20024 | | |
20019 | 20025 | | |
| |||
21023 | 21029 | | |
21024 | 21030 | | |
21025 | 21031 | | |
| 21032 | + | |
| 21033 | + | |
| 21034 | + | |
| 21035 | + | |
| 21036 | + | |
| 21037 | + | |
| 21038 | + | |
| 21039 | + | |
| 21040 | + | |
| 21041 | + | |
| 21042 | + | |
| 21043 | + | |
| 21044 | + | |
| 21045 | + | |
| 21046 | + | |
| 21047 | + | |
| 21048 | + | |
| 21049 | + | |
| 21050 | + | |
| 21051 | + | |
| 21052 | + | |
| 21053 | + | |
| 21054 | + | |
| 21055 | + | |
| 21056 | + | |
| 21057 | + | |
| 21058 | + | |
| 21059 | + | |
| 21060 | + | |
| 21061 | + | |
| 21062 | + | |
| 21063 | + | |
| 21064 | + | |
| 21065 | + | |
| 21066 | + | |
| 21067 | + | |
| 21068 | + | |
| 21069 | + | |
| 21070 | + | |
| 21071 | + | |
| 21072 | + | |
| 21073 | + | |
| 21074 | + | |
| 21075 | + | |
| 21076 | + | |
| 21077 | + | |
| 21078 | + | |
| 21079 | + | |
| 21080 | + | |
| 21081 | + | |
| 21082 | + | |
| 21083 | + | |
| 21084 | + | |
| 21085 | + | |
| 21086 | + | |
| 21087 | + | |
| 21088 | + | |
| 21089 | + | |
| 21090 | + | |
| 21091 | + | |
| 21092 | + | |
| 21093 | + | |
| 21094 | + | |
| 21095 | + | |
| 21096 | + | |
| 21097 | + | |
| 21098 | + | |
| 21099 | + | |
| 21100 | + | |
| 21101 | + | |
| 21102 | + | |
| 21103 | + | |
| 21104 | + | |
| 21105 | + | |
| 21106 | + | |
| 21107 | + | |
| 21108 | + | |
| 21109 | + | |
| 21110 | + | |
| 21111 | + | |
| 21112 | + | |
| 21113 | + | |
| 21114 | + | |
| 21115 | + | |
| 21116 | + | |
| 21117 | + | |
| 21118 | + | |
| 21119 | + | |
| 21120 | + | |
| 21121 | + | |
| 21122 | + | |
| 21123 | + | |
| 21124 | + | |
| 21125 | + | |
| 21126 | + | |
| 21127 | + | |
21026 | 21128 | | |
21027 | 21129 | | |
21028 | 21130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments