Bug#119727: Fix wrong result for 'value BETWEEN a AND NULL' with temporal types #644
+129
−1
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
'2019-12-25' BETWEEN '2017-05-24' AND NULLwas returning0instead ofNULLRoot Cause
When YEAR is mixed with DATE/TIMESTAMP in BETWEEN, type aggregation returns
REAL_RESULT. This bypassed temporal comparison, causing incompatibleval_real()formats to be compared:20191225.020170524000000.0Since
20191225.0 < 20170524000000.0, the value appeared less than the lower bound, returning FALSE before checking the NULL upper bound.Solution
Added
all_temporalcheck inItem_func_between::resolve_type()to force temporal comparison when all three arguments are temporal types, regardless of the aggregatedcmp_type.Plan
func_between_temporal.testwith 8 test cases