← Back to Pull requests

MDEV-39366 Preserve DOUBLE precision when caching subquery results #5768

Open
unknown opened this pull request with 136 lines diff across 1 files
View on GitHub
unknown unknown commented on Sep 28, 2026 05:59 UTC
Author

A correlated scalar subquery using STDDEV_POP() can return a full-precision value on a cache miss and a rounded value on cache hits. The temporary DOUBLE result field applies the expression's declared scale when storing the evaluated result.

Preserve the evaluated DOUBLE value in the subquery cache. Add one correlated query over the values 0, 0 and 1 to cover both cache misses and hits. Casting the result to DECIMAL(10,8) exposes the precision loss with stable expected output: 0.47140452 for all three rows.

Bug report: https://jira.mariadb.org/browse/MDEV-39366

Validation

On current 11.4 at f49e838d367f2154b3edb43effa99ff9eb0d8602:

  • The unmodified server fails the regression: the two cache hits return 0.47140000. All preceding results in main.subselect_cache match.

  • The expected result was independently calculated from population variance 2/9.

  • The patched Release build succeeds.

  • Native MTR passes: main.subselect_cache, main.select.

  • main.subselect_cache also passes with the prepared-statement protocol.

  • The full server test suite was not run.
  • Diff: 136 lines (+102 / -34) across 1 files Reviewer: gkodinov Review duration: 21004m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.32) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.32 · 136 lines diff across 1 files
    0.32
    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%
    42%
    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.294
    Real PR Conversation Timeline
    1 comments
    "Review active on #5768"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 32.4% (LOW) · Higher = larger blast radius
    32.4%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 18.5% · Safe to merge
    18.5%
    Repository