MDEV-39199: Fix incorrect LEFT JOIN result with INT UNIQUE key and DOUBLE literal#4878
Open
itzanway wants to merge 1 commit intoMariaDB:mainfrom
Open
MDEV-39199: Fix incorrect LEFT JOIN result with INT UNIQUE key and DOUBLE literal#4878itzanway wants to merge 1 commit intoMariaDB:mainfrom
itzanway wants to merge 1 commit intoMariaDB:mainfrom
Conversation
c963806 to
d8dcc60
Compare
d8dcc60 to
3ae93c5
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.
Description
Fixes an optimizer bug where a
LEFT JOINwith anONpredicate comparing anINT UNIQUEcolumn to aDOUBLEliteral (e.g.,0.1) incorrectly matches the row where the integer is0.Root Cause
The optimizer was coercing the double literal
0.1into the integer type for the index lookup (0). Because it matched theUNIQUEindex viaeq_ref/refaccess, it optimized away the originalONcondition. Since the strict float-to-int comparison was truncated without flagging the condition as impossible, it returned the0row incorrectly.Fix
Modified
[insert function name here, e.g., add_key_field]to detect lossy type conversions when building key fields from constants. If the literal cannot be stored in the field without truncation, the equality is marked as impossible, preventing the false positive index lookup.Testing
Added MTR test
left_join_type_coercion.testwhich asserts the correctNULLpropagation on the right side of the join.