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' #6191
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 290 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.339
Real PR Conversation Timeline
1 comments
"Review active on #6191"
general
weight: 0.35
gkodinov
Description
For a negative value with a three-digit exponent, the formatted text
of FORMAT_PICO_TIME() filled the whole result buffer. snprintf()
wrote its terminating NUL over the final unit character, and the SQL
result included that NUL: FORMAT_PICO_TIME(-1e126) returned
'-1.16e+109 \0' instead of '-1.16e+109 d'.
Allow room for the terminating NUL. Keep the declared result width
at 12 characters.
FORMAT_BYTES() has the same problem but does not exist in 11.4.
It is fixed in a separate pull request for 11.8.
Add a regression test that checks the complete unit.
Why the base changed
This PR first targeted 11.8.
FORMAT_PICO_TIME()already has this bug in 11.4, which is the oldest maintained branch that reproduces it. So the PR now targets 11.4 and contains only theFORMAT_PICO_TIME()part.FORMAT_BYTES()gets its own pull request against 11.8, the oldest branch that has it.Release Notes
FORMAT_PICO_TIME()no longer returns a NUL byte in place of the unit for negative values with a three-digit exponent, for exampleFORMAT_PICO_TIME(-1e126).FORMAT_BYTES()is fixed in a separate pull request for 11.8.How can this PR be tested?
The new test checks that
FORMAT_PICO_TIME(-1e126)returns-1.16e+109 dwith length 12.I ran these locally on an 11.4.15 Linux debug build (WSL):
HEX(FORMAT_PICO_TIME(-1e126))returned2D312E3136652B3130392000, which ends in a NUL byte.main.func_format,main.1standmain.aliaspassed.The earlier 11.8 version of this patch, which also covered
FORMAT_BYTES(), was tested on a 13.3 debug build.Basing the PR against the correct MariaDB version
PR quality check