Skip to content

Filter a table by any single-table condition before a comma join to close #2916 - #2918

Merged
mathiasrw merged 20 commits into
feature/rollupfrom
fix/2916
Nov 19, 2026
Merged

mathiasrw merged 20 commits into
feature/rollupfrom
fix/2916

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Closes #2916. A condition in WHERE that reads one table alone now filters that table before a comma join, whatever its operator (IN, OR, LIKE, BETWEEN, NOT, a comparison, a function of that table's columns, t1.a = t1.b). Before, only column = constant did (#2279), so a table filtered by IN or OR went into the join in full and the final WHERE ran on every combination of rows.

Seeded tables of 100 rows, each query capped at 60 seconds.

before after
no join condition, IN and OR filters on six tables not finished 14 ms, 6,300 rows
the same with each filter in a subquery in FROM 13 ms 11 ms
one link and five filters, FROM t3 first 8,492 ms 7 ms
one link and five filters, FROM t9 first 9,309 ms 8 ms

A join index is now cached on the table only when the table has no filter, because the cache key held the filter's code but not the parameter values, so a second run with other values reused the first run's index (already wrong for = ? in 4.22.0).

Found on the way and filed separately are #2917, #2919 and #2922.

Checks on 39f04ad. yarn test, 2531 pass, 213 skip, 0 fail. Parity against feature/rollup, 77,000 statements, 0 result differences apart from test2916's own second-run case and the fixed clock of test815, 12 generated-code differences where single-table conditions now compile to filters (test118-B, test128-B, test2916), API identical. test-perf-mini 98 against 4.22.0, nothing marked.

…lose #2877 and close #2791 (#2683)

Since DEFAULT can be used as a name, `UPDATE t SET a = DEFAULT` and
`INSERT INTO t VALUES (DEFAULT, ...)` read it as a column named
`default`. UPDATE wrote undefined and INSERT threw a TypeError.

The grammar now reads DEFAULT on its own in SET and in VALUES as a
DefaultValue node. UPDATE writes the column default (NULL when the column
has none), and INSERT leaves the column out so the table default fills it.
A quoted [default] is still a column.
@mathiasrw
mathiasrw added this pull request to stack #2927 October 29, 2026 09:31
mathiasrw and others added 7 commits October 29, 2026 20:43
A correlated IN, NOT IN, ALL/ANY/SOME or EXISTS subquery in HAVING got the
group row as its outer scope, so t1.a read from an undefined t1 and threw.
These subqueries now get the group's source row, keyed by table alias, the
same way a scalar subquery in HAVING already does. WHERE is unchanged.
Add INSERT ... SET, expression default, IDENTITY and NOT NULL test case as suggested in #2921.
@mathiasrw mathiasrw added this to the v4.x Focus milestone Nov 9, 2026
@mathiasrw
mathiasrw merged commit 8b003d2 into main Nov 19, 2026
19 checks passed
An error occurred while trying to automatically change base from feature/rollup to main November 19, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants