Skip to content

Bug#121574: Wrong result for subquery on constant column of merged derived table - #865

Open
ToKliar wants to merge 1 commit into
mysql:trunkfrom
ToKliar:bug121574
Open

ToKliar wants to merge 1 commit into
mysql:trunkfrom
ToKliar:bug121574

Conversation

@ToKliar

@ToKliar ToKliar commented Oct 22, 2026

Copy link
Copy Markdown

What does this change do?

Fixes BUG#121574 (https://bugs.mysql.com/bug.php?id=121574): a subquery that
refers to a constant column of a merged derived table on the inner side of an
outer join returns wrong results for NULL-complemented rows.

Why is it needed?

The constant column depends on the derived table's first inner table, but
used_tables_for_level() only reports Item_field columns, so the containing
subquery did not depend on that table. The fix adds it to the subquery's used
tables when resolving the outer reference and after semi-join pullout.

How was it tested?

  • Added/updated MTR tests under mysql-test/
  • scripts/ci/mtr.sh passes locally
  • Ran the relevant full suite (name it): main.derived, also with --hypergraph

Contributor checklist

  • Code is formatted (scripts/ci/format.sh)
  • Commits are focused with descriptive messages

AI assistance

  • I did not use AI assistance for this contribution
  • I used AI assistance for this contribution

Areas touched

optimizer

…rived table

A constant column of a merged derived table on the inner side of an
outer join depends on its first inner table, but the subquery that
refers to it did not, because used_tables_for_level() only reports
Item_field columns. The subquery then returned wrong results for
NULL-complemented rows.

Also add the first inner table of such view references to the
subquery's used tables, both when resolving the outer reference and
after semi-join pullout.
@ToKliar
ToKliar requested a review from a team October 22, 2026 07:26
@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Oct 22, 2026
@github-actions github-actions Bot added the Tests Changes touching test code or test data label Oct 22, 2026
@ogrovlen ogrovlen added the Optimizer Changes touching optimizer code label Oct 22, 2026
@github-actions github-actions Bot added the Build Failed PR build failed label Oct 22, 2026
@ToKliar

ToKliar commented Oct 22, 2026

Copy link
Copy Markdown
Author

The Debug build and MTR failures are unrelated to this change: CMake fails at
configure time because libudev-dev is missing on the runner
("-DWITH_AUTHENTICATION_WEBAUTHN=ON, but missing required libraries").
scripts/ci/bootstrap.sh does not install libudev-dev, and the same failure
appears on other recent PRs (e.g. #862, #864), possibly since ubuntu-latest
moved to Ubuntu 26. The change builds locally and main.derived passes,
including with --hypergraph.

@RidhaOracle

Copy link
Copy Markdown
Member

Yes you are right @ToKliar I am looking into it

@ToKliar

ToKliar commented Oct 23, 2026

Copy link
Copy Markdown
Author

Note: Bug#121574 was closed as a duplicate of Bug#121454, but they are
separate problems. This PR fixes Bug#121574 only; the test case in
Bug#121454 still fails with this patch. Details:
https://bugs.mysql.com/bug.php?id=121454

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build Failed PR build failed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. Optimizer Changes touching optimizer code Tests Changes touching test code or test data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants