← Back to Pull requests

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

Open
unknown opened this pull request with 255 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 23, 2026 11:23 UTC
Author

  • The Jira issue number for this PR is: MDEV-42322
  • 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. The FORMAT_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 example FORMAT_BYTES(-1e125).

    How can this PR be tested?

    ./mtr main.func_format
    

    The new test checks that FORMAT_BYTES(-1e125) returns -8.67e+106 EiB with length 14.

    I ran these locally on an 11.8.11 Linux debug build (WSL): main.func_format and main.1st passed normally and with --ps-protocol, --view-protocol and --cursor-protocol. The bug was first reproduced on a 13.3 debug build, and 11.8 has the same FORMAT_BYTES() code.

    Basing the PR against the correct MariaDB version


  • This is a new feature and the PR is based against the latest MariaDB development branch.

  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.
  • PR quality check


  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.

  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.
  • Diff: 255 lines (+191 / -64) across 3 files Reviewer: gkodinov Review duration: 11213m
    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
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%
    Repository