MDEV-40180 Cache constant args in JSON_EQUALS and JSON_OVERLAPS#5455
Open
VasuBhakt wants to merge 1 commit into
Open
MDEV-40180 Cache constant args in JSON_EQUALS and JSON_OVERLAPS#5455VasuBhakt wants to merge 1 commit into
VasuBhakt wants to merge 1 commit into
Conversation
* Optimize JSON_EQUALS by caching the normalized DYNAMIC_STRING of constant arguments within val_bool(), preventing redundant re-parsing. * Fix JSON_OVERLAPS constant caching, which was improperly cached in fix_length_and_dec (causing --ps-protocol failures), by moving it to val_bool(). * Ensure cleanup() correctly resets caching state for both functions for prepared statements. * Note: This commit intentionally skips the nested objects short-circuit logic, which will be implemented incrementally in a future update. Signed-off-by: VasuBhakt <cpswastik31@gmail.com>
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Fixes MDEV-40180
Problem
JSON_EQUALSevaluates and parses constant arguments per-row.JSON_OVERLAPScaches constant arguments infix_length_and_dec, which fails to recalculate during--ps-protocolexecutions with changing bound parameters.Solution
Migrated constant argument caching logic to
::val_bool()for both functions:Item_func_json_equals: Added deep-copy caching of the normalizedDYNAMIC_STRINGupon first evaluation of a constant argument. Subsequent evaluations bypassjson_normalize_engineand reuse the cached string.Item_func_json_overlaps: Removed flaweda2_constantcaching fromfix_length_and_decand implemented per-execution caching of the evaluated string insideval_bool().cleanup()in both classes to reset boolean caching flags, ensuring correct cache invalidation between executions.(Note: The nested object short-circuit evaluation will be addressed in a follow-up incremental PR).
Tests
Executed the
json,json_equals, andjson_normalizeMTR suites (both standard and--ps-protocol) to verify behavior preservation and resolution of the prepared statement cache bug.Version
The change is directed at versions
10.11,11.4,11.8, and12.3. The PR is based on branch10.11, being the lowest affected branch.