← 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' #6191

Open
unknown opened this pull request with 290 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 21, 2026 17:03 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_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 the FORMAT_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 example FORMAT_PICO_TIME(-1e126). FORMAT_BYTES() is fixed in a separate pull request for 11.8.

    How can this PR be tested?

    ./mtr main.func_format
    

    The new test checks that FORMAT_PICO_TIME(-1e126) returns -1.16e+109 d with length 12.

    I ran these locally on an 11.4.15 Linux debug build (WSL):

  • Before the fix: HEX(FORMAT_PICO_TIME(-1e126)) returned 2D312E3136652B3130392000, which ends in a NUL byte.

  • After the fix: main.func_format, main.1st and main.alias passed.
  • 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


  • 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: 290 lines (+217 / -73) across 3 files Reviewer: gkodinov Review duration: 13753m
    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
    0.40
    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.339
    Real PR Conversation Timeline
    1 comments
    "Review active on #6191"
    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.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    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: 21.2% · Safe to merge
    21.2%
    Repository