Conversation
…query NOT IN can return a row that should be excluded when a materialized subquery contains NULL and the outer value cannot be represented by the subquery's index key type. For example, outer INT value 9999 compared with a TINYINT subquery containing 21 and NULL must not pass the predicate. A failed conversion of the outer value into an exact-lookup key immediately returns FALSE for IN. This bypasses the NULL-aware partial-match phase, although failure of an exact lookup does not rule out an UNKNOWN result caused by NULL in the subquery. Skip the exact index lookup when key conversion fails. Continue through the existing NULL-aware partial-match handling instead of returning FALSE early. Preserve successful exact lookups and the materialized-subquery execution strategy. The regression compares INT values, including 9999, with a materialized TINYINT subquery containing NULL and expects no rows from NOT IN. Bug report: https://jira.mariadb.org/browse/MDEV-40877
DerZc
force-pushed
the
fix-mdev-40877
branch
from
September 21, 2026 06:03
f6de3d7 to
e9453b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOT IN can return a row that should be excluded when a materialized subquery contains NULL and the outer value cannot be represented by the subquery's index key type. For example, outer INT value 9999 compared with a TINYINT subquery containing 21 and NULL must not pass the predicate.
Bug report: https://jira.mariadb.org/browse/MDEV-40877
Root cause
A failed conversion of the outer value into an exact-lookup key immediately returns FALSE for IN. This bypasses the NULL-aware partial-match phase, although failure of an exact lookup does not rule out an UNKNOWN result caused by NULL in the subquery.
Changes
Regression coverage
The regression compares INT values, including 9999, with a materialized TINYINT subquery containing NULL and expects no rows from NOT IN.
mysql-test/main/not_in_materialized_null.resultmysql-test/main/not_in_materialized_null.testValidation
On
11.4atd10e5d726799b1cd57cc866f40aad68c720803da:main.not_in_materialized_nullfailed on the unchanged target branch and passed with this fix.main.select,main.subselect.