Repository navigation
MDEV-42239 JSON_EQUALS() with a NULL argument is accepted by WHERE / IF / CASE although its value is NULL - #6143
Open
mehul-raj5 wants to merge 1 commit into
Open
mehul-raj5 wants to merge 1 commit into
mehul-raj5 wants to merge 1 commit into
Conversation
…IF / CASE although its value is NULL Item::val_bool() must return FALSE when the value is NULL, and report NULL through null_value. Item_func_json_equals::val_bool() set null_value but returned 1 when an argument was NULL, and on the two out-of-memory paths. The select list checks null_value and showed NULL, but WHERE, HAVING, IF and CASE use only the return value and treated the NULL as TRUE. Return 0 on these paths, as the function already does for invalid JSON, and as the other JSON boolean functions do.
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
Item::val_bool()must return FALSE when the value is NULL, and report NULL throughnull_value.Item_func_json_equals::val_bool()setnull_valuebut returned 1 when an argument was NULL, and on the two out-of-memory paths. The select list checksnull_valueand showed NULL, but WHERE, HAVING, IF and CASE use only the return value and treated the NULL as TRUE.This patch returns 0 on these paths, as the function already does for invalid JSON, and as the other JSON boolean functions do (
JSON_VALID,JSON_EXISTS,JSON_CONTAINS,JSON_CONTAINS_PATH,JSON_OVERLAPS).Before and after, with
t1(id, j)holding rows 1, 2, 3:SELECT JSON_EQUALS(NULL, j)WHERE JSON_EQUALS(NULL, j)WHERE JSON_EQUALS(NULL, j) IS NULLIF(JSON_EQUALS(NULL, j), 'T', 'F')SELECT 'row' WHERE JSON_EQUALS(NULL, '{}')