Backport #107407 to 26.5: Fix logical error in disjunction filter push-down through JOIN with type-changing USING key#108903
Conversation
…h-down through JOIN with type-changing USING key
…tiIf) The backport's regression test `04330_join_disjunctions_pushdown_using_type_mismatch` failed in the "distributed plan" stateless configs: the final "analyzer no crash" query returned an `UNKNOWN_IDENTIFIER` exception instead of the expected `1`. Root cause is version-specific, not a gap in the backported fix. The query phrases the statically-dead branch (referencing the unknown identifiers `t04330.x` and `r.s`) with `multiIf`. On master that dead branch is folded away at analysis time by the `multiIf` constant-branch special case in `resolveFunction.cpp` (`is_special_function_multi_if`), so the identifiers are never resolved and the query succeeds. That `multiIf` folding is not present in 26.5 — it was added later by an unrelated change and is out of scope for this bug-fix backport — so 26.5 resolves the dead branch and throws. The `if` constant-branch special case (`is_special_function_if`) is present in 26.5 and swallows the dead branch identically, exercising the same `scope.join_using_columns` dangling-pointer crash path that the `IdentifierResolver` `SCOPE_EXIT` fix in this backport guards. Since `multiIf(c, a, b)` with a single condition is equivalent to `if(c, a, b)`, the regression is expressed with `if` here. Verified on the 26.5 `amd_asan_ubsan`/`arm_release` build that the test matches the reference (including the final `1`) with `serialize_query_plan=1`, `serialize_query_plan=0`, and `optimize_multiif_to_if=1`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The only red was the PR's own test Root cause is version-specific, not a gap in the backported fix. Both source fixes ( Fix: express the dead branch with Verified on the 26.5 I also merged |
…sing it Supersedes the previous commit's `multiIf` -> `if` rewrite. Aligns this 26.5 backport with the 26.4 sibling (#108902, commit 06d2b2b), where the same situation was resolved by dropping the `--- analyzer no crash ---` query. The query reproduces the secondary analyzer fix in `IdentifierResolver.cpp` (a dangling pointer in `scope.join_using_columns` left behind when an `UNKNOWN_IDENTIFIER` thrown from a statically-dead branch is swallowed during resolution). That swallow, for a dead `multiIf` branch, only exists on branches that have the `multiIf` constant-folding path (`is_special_function_multi_if` in `resolveFunction.cpp`), which was added to master after 26.5 and is unrelated to this fix. 26.5 only swallows dead `if` branches; for `multiIf` the unknown identifier propagates, so the query errors (`UNKNOWN_IDENTIFIER` for `r.s`) instead of returning `1`. An `if`-based variant was considered, but it does not reproduce the crash on an unpatched 26.5 binary either (the dangling-pointer scenario is not reachable without the `multiIf` swallow), so it would be a query that passes regardless of the fix. The query is therefore omitted, with an explanatory note, and the `IdentifierResolver.cpp` change is kept for parity with master. The primary fix and its coverage (the disjunction push-down logical error `Unexpected return type from equals`) are unchanged and still exercised by the first part of the test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Original pull-request #107407
Cherry-pick pull-request #108756
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.
The PR source
The PR is created in the CI job
Version info
26.5.5.8