MDEV-42361 Assertion `0' failed in Item_param::can_return_value() on PREPARE of JSON_ARRAY_INTERSECT(?, 1) or JSON_OBJECT_FILTER_KEYS(1, ?) (the defect of MDEV-31599, fixed there for JSON_SCHEMA_VALID only) #6195
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.33) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 157 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.303
Real PR Conversation Timeline
1 comments
"Review active on #6195"
general
weight: 0.35
gkodinov
MDEV-42361: https://jira.mariadb.org/browse/MDEV-42361
Problem:
Item_func_json_object_filter_keys::fix_length_and_dec()was accessingargs[1]unconditionally to build the hash of the keys. DuringPREPARE, a parameter has no value yet (NO_VALUE), causingItem_param::can_return_value()to hitDBUG_ASSERT(0)in debug builds.The fix is to parse the keys in
fix_length_and_dec()only whenargs[1]is a constant. A parameter is not considered constant duringPREPARE, but becomes constant when the statement is executed andfix_length_and_dec()runs again. This ensures that the hash is built once per execution.For keys that change between rows, such as a column,
val_str()parses them for each row throughcreate_keys_hash(), which frees the hash from the previous call before creating a new one.JSON_ARRAY_INTERSECT(?, 1)already works in 11.4 and 11.8 due to itsconst_item()check. However, it still asserts in 12.3 and main, where the function was rewritten. This will be addressed in a separate PR.Test: Added a single
PREPAREofJSON_OBJECT_FILTER_KEYS(1, ?)tomain.func_json. Without the fix, the server aborts duringPREPARE; with the fix, the test passes, including with--ps-protocol.