MDEV-38873 json_extract returns NULL through derived table#4680
Draft
varundeepsaini wants to merge 1 commit intoMariaDB:mainfrom
Draft
MDEV-38873 json_extract returns NULL through derived table#4680varundeepsaini wants to merge 1 commit intoMariaDB:mainfrom
varundeepsaini wants to merge 1 commit intoMariaDB:mainfrom
Conversation
json_extract() passes its result through json_nice() with LOOSE format, which can expand the output by adding spaces after commas and colons. The max_length was not accounting for this expansion, causing derived tables to truncate the result and the outer json_extract() to fail with "Unexpected end of JSON text". Fix by multiplying max_length by 2 to match JSON_FORMAT(LOOSE). Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
95b0d9b to
8653482
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
json_extract()passes its result throughjson_nice()with LOOSE format, which expands the output by adding spaces after commas and colons (e.g.["a",1]→["a", 1]). Themax_lengthinItem_func_json_extract::fix_length_and_dec()was not accounting for this expansion. When the result passed through a derived table, the field was created with the underestimated length, truncating the JSON string and causing the outerjson_extract()to fail with "Unexpected end of JSON text".Fixed by multiplying
max_lengthby 2 to account for the LOOSE format expansion, matchingJSON_FORMAT(LOOSE)behavior.Release Notes
JSON_EXTRACT()no longer returns NULL with "Unexpected end of JSON text" when its result is used through a derived table.How can this PR be tested?
Basing the PR against the correct MariaDB version
mainbranch.PR quality check