MDEV-39972 Preserve negative indexes when reusing constant JSON paths #5770
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.25) × (1 − Review Confidence (0.91)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.25 · 25 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.93 · 4 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.195
Real PR Conversation Timeline
7 items
please avoid extra SET and CREATE DATABASE unless they contribute to coverage.
avoid anything that doesn't contribute to coverage. Note that mtr already runs tests with view and prepared statement protocols.
avoid redundant test case that do not contribute to test coverage.
You're changing JSON_EXTRACT but there's not a single word about this in the commit message.
Commit messages usually follow this pattern:
1. what was wrong
2. how it was fixed
3. how is the fix tested.
Changes Requested
Thank you for your contribution! This is a preliminary review.
Approved
LGTM. Thanks! Please stand by for the final review.
gkodinov
DerZc
JSON_EXTRACT() and JSON_SEARCH() detect negative indexes only when a path is first parsed, so later rows using a cached constant path do not recompute array lengths. JSON_SEARCH() also clears flags from cached paths.
Read the negative-index flag for every path, including cached constants, and reset JSON_SEARCH() path flags only when parsing.
Regression coverage
Add one query to
main.func_jsonthat calls both functions on two arrays of different lengths. It checks the last value and its path on both rows. The seven-line test reuses the existing test setup and MTR protocol support, with no extra SET, database creation, manual prepared statements or duplicate queries.Validation
On current
11.4atf49e838d367f2154b3edb43effa99ff9eb0d8602:main.func_jsononly on the new second-row results:0andNULLinstead of"x"and"$[1]".main.func_jsonandmain.selectpass.main.func_jsonpasses.main.func_jsonpasses.Bug report: https://jira.mariadb.org/browse/MDEV-39972