You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Planner: one exhaustive answer to "which variables does this pattern read" #2458
The planner builds several sets of "variables a later operator reads", each by hand: collect_var_stats (which variables are join variables), the live set a join step trims its output to (where_plan.rs), and the range-semijoin fold's "read elsewhere" test. When one of them misses a reader, the column that reader needs is trimmed, or the variable isn't treated as a join variable, and a join silently becomes a cartesian product. The query returns wrong rows with no error.
This has happened four times, each fixed at the one site that missed a reader:
016131db4: a list-view (and search) pattern's variables were not counted as join variables.
f3003506e: the quoted-triple variables the chain elision needs were not kept.
1a0bd7509: the sunk filter's dependency on collect_var_stats.
One exhaustive method that answers which variables a pattern, or a pending filter or bind, reads, and have collect_var_stats, the live set and the fold's read_elsewhere all call it, instead of each enumerating pattern kinds. A new pattern kind then has one place to declare its readers, and a match over all pattern kinds there (no _ arm) makes a new kind a compile error until it does.
Done when
The three sites derive their reader sets from the one method.
Adding a pattern kind fails to compile until the method handles it.
The existing regressions for the four instances above still pass.
Activity