MDEV-42322 FORMAT_BYTES() and FORMAT_PICO_TIME() return a NUL byte instead of the last character for a negative value with a three-digit exponent: FORMAT_BYTES(-1e125) = '-8.67e+106 Ei\0' #6198
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 255 lines diff across 3 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.332
Real PR Conversation Timeline
1 comments
"Review active on #6198"
general
weight: 0.35
gkodinov
Description
For a negative value with a three-digit exponent, the formatted text
of FORMAT_BYTES() filled the whole result buffer. snprintf() wrote
its terminating NUL over the final unit character, and the SQL
result included that NUL: FORMAT_BYTES(-1e125) returned
'-8.67e+106 Ei\0' instead of '-8.67e+106 EiB'.
Allow room for the terminating NUL. Keep the declared result width
at 14 characters.
FORMAT_PICO_TIME() has the same problem. It exists in 11.4 and is
fixed there in a separate pull request. This commit fixes only
FORMAT_BYTES(), which was added in 11.8.
Add a regression test that checks the complete unit.
This is the
FORMAT_BYTES()part of MDEV-42322. TheFORMAT_PICO_TIME()part is #6191 against 11.4, split out as requested in that PR's review.Release Notes
FORMAT_BYTES()no longer returns a NUL byte in place of the last unit character for negative values with a three-digit exponent, for exampleFORMAT_BYTES(-1e125).How can this PR be tested?
The new test checks that
FORMAT_BYTES(-1e125)returns-8.67e+106 EiBwith length 14.I ran these locally on an 11.8.11 Linux debug build (WSL):
main.func_formatandmain.1stpassed normally and with--ps-protocol,--view-protocoland--cursor-protocol. The bug was first reproduced on a 13.3 debug build, and 11.8 has the sameFORMAT_BYTES()code.Basing the PR against the correct MariaDB version
PR quality check