Visitar URL original
MDEV-42239 JSON_EQUALS() with a NULL argument is accepted by WHERE / IF / CASE although its value is NULL by mehul-raj5 · Pull Request #6143 · MariaDB/server · GitHub
Skip to content

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
MariaDB:10.11from
mehul-raj5:MDEV-42239
Open

mehul-raj5 wants to merge 1 commit into
MariaDB:10.11from
mehul-raj5:MDEV-42239

Conversation

@mehul-raj5

Copy link
Copy Markdown

Description

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.

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:

Query Before After
SELECT JSON_EQUALS(NULL, j) NULL NULL
WHERE JSON_EQUALS(NULL, j) 1, 2, 3 no rows
WHERE JSON_EQUALS(NULL, j) IS NULL 1, 2, 3 1, 2, 3
IF(JSON_EQUALS(NULL, j), 'T', 'F') T F
SELECT 'row' WHERE JSON_EQUALS(NULL, '{}') row no rows

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant