MDEV-40165 10.11 JSON functions don't respect KILL QUERY#5117
MDEV-40165 10.11 JSON functions don't respect KILL QUERY#5117grooverdan wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to make JSON processing interruptible by checking a killed_ptr within the JSON engine and returning a new JE_KILLED error code. While the changes integrate this check into several JSON functions and update error reporting, the review identifies a critical risk of NULL pointer dereference in json_scan_next if the pointer is not initialized. Additionally, feedback points out that some functions incorrectly assume they are not interruptible or have lost interruptibility due to the removal of manual check_killed() calls without proper pointer initialization.
f80774b to
6dee764
Compare
|
Replaced with 10.6 version - #5045 There's still a need to correct the killabilty of JSON_OVERLAPs and maybe JSON_NORMALIZE in 10.11, so moving to a draft for now. |
Or max_statement_time limit. Implement interuptability of: * JSON_OVERLAPS * JSON_LENGTH * JSON_DEPTH As json_report_error now processes the killed there's no need of thd->check_killed(). Removed this from a few locations. Verified that the path after every json_scan_next, the location of checking the killed_ptr, reports errors correctly.
Or max_statement_time limit. JSON_EQUAL/JSON_NORMALIZE also didn't report warnings on invalid JSON inputs. Change the json_normalize function to take a json_engine_t as a argument and implement the sql/item_jsonfunc.cc calls to have a json_engine_t. To the JSON_EQUALS and JSON_NORMALIZE, add error handling to produce an error when there was one. compare_nested_object, part of JSON_OVERLAPS, uses a new json_engine and copies the error/position to the returning function. json_normalize expects the incoming je structure to have a valid, or nullptr, killed_ptr, as json_start will reset this.
Or max_statement_time limit. Change the json_valid to take a json_engine_t argument. Adjust the Item_json_valid to have a json_engine_t and to report an error. Note this means that invalid json syntax now has a note on any json error. Raising this to a warning can cause check constraints of JSON_VALID() to result in ER_JSON_SYNTAX rather than ER_CONSTRAINT_FAILED (valided in main.type_json test). Consequential changes in debug build to json acl testing validation and unit test having a dummy json_engine_t. json_normalize also uses the same engine that was passed as its argument to test json_valid. Because the character set may have changed, if there's an error adjust the je->s.c_str pointer. Its only the offset that is currently used in the error messages anyway so there may be offset errors depending on the original character set.
Or max_statement_time limit.
Implement interuptability of:
* JSON_OVERLAPS
* JSON_LENGTH
* JSON_DEPTH