expression,json: make the behavior of JSON_VALID
consistent (#57496)
#57505
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.
This is an automated cherry-pick of #57496
What problem does this PR solve?
Issue Number: close #56293
Problem Summary:
The
JSON_VALID
function behavior is inconsistent between different types, between TiDB and TiKV.What changed and how does it work?
This PR changes the behavior of returning
0
directly for "other" types. With this modification, the behavior is consistent forJSON
,STRING
and all other types. Also, it's compatible between TiDB and TiKV.The strange behavior described in #56293 is caused by different behavior between the
SELECTION
pushed down to TiKV, and thePROJECTION
in TiDB. This PR should fix it.Please be careful that this behavior is not compatible with MySQL. Because the behavior of MySQL is not consistent to its document (https://dev.mysql.com/doc/refman/5.7/en/json-attribute-functions.html#function_json-valid) and is also not consistent between different types, columns and literals. I submitted a bug report to MySQL : https://bugs.mysql.com/bug.php?id=116703
Check List
Tests
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.