← Back to Pull requests

MDEV-41877 Partition function error still writes the row on MyISAM #6243

Open
unknown opened this pull request with 405 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 26, 2026 18:36 UTC
Author

Description

An integer overflow in a partition function, for example HASH (-a) with a = -9223372036854775808, raises ER_DATA_OUT_OF_RANGE but does not set null_value. part_val_int() checked thd->is_error() only when null_value was set, so it returned 0 as a valid value. The row went to the partition for 0 and the statement ended with the error already in the diagnostics area. MyISAM kept the row, or the new value on UPDATE. On a debug build my_ok() hit the assertion !is_set() || (m_status == DA_OK_BULK && is_bulk_op()) in Diagnostics_area::set_ok_status().

Check thd->is_error() in part_val_int() regardless of null_value, so the row is not written. In ha_partition::is_fatal_error(), do not treat HA_ERR_NO_PARTITION_FOUND as ignorable when an error is already set, so INSERT IGNORE fails instead of skipping the row and sending OK. In ha_partition::print_error(), do not add "Table has no partition for value" on top of the existing error.

Add a test to main.partition.

Release Notes

N/A

How can this PR be tested?

Execute main.partition in mysql-test-run, with and without --ps-protocol.

This commit adds a test to main.partition that runs INSERT, multi-row INSERT, INSERT IGNORE, REPLACE and UPDATE on MyISAM tables whose partition function overflows.

  • It covers HASH, RANGE and LIST partitioning and subpartitions.

  • It checks that each statement fails with ER_DATA_OUT_OF_RANGE, that no row or new value is stored, and that SHOW WARNINGS lists only that error.
  • Before the fix

    On a debug build, running main.partition fails as below:

    main.partition                           [ fail ]
            Test ended at 2026-11-26 18:01:41
    
    CURRENT_TEST: main.partition
    mysqltest: At line 3168: query 'INSERT INTO t1 VALUES (-9223372036854775808)' failed with wrong errno <Unknown> (2013): 'Lost connection to server during query', instead of ER_DATA_OUT_OF_RANGE (1690)...
    
    mariadbd: sql/sql_error.cc:344: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
    
    #8  Diagnostics_area::set_ok_status (affected_rows=1, last_insert_id=0, message=0x0) at sql/sql_error.cc:344
    #9  my_ok (affected_rows_arg=1, id=0, message=0x0) at sql/sql_class.h:6036
    #10 mysql_insert (..., duplic=DUP_ERROR, ignore=false, result=0x0) at sql/sql_insert.cc:1428
    #11 mysql_execute_command (is_called_from_prepared_stmt=false) at sql/sql_parse.cc:4664
    #12 mysql_parse (rawbuf="INSERT INTO t1 VALUES (-9223372036854775808)", ...) at sql/sql_parse.cc:8219
    

    After the fix

    Running main.partition succeeds:

    main.partition                           [ pass ]   2813
    

    With --ps-protocol:

    main.partition                           [ pass ]   4102
    

    Basing the PR against the correct MariaDB version

  • This is a bug fix, and the PR is based against the earliest maintained branch on which the bug can be reproduced: 10.11.
  • Copyright

    All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

    Diff: 405 lines (+303 / -102) across 5 files Reviewer: gkodinov Review duration: 6460m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 405 lines diff across 5 files
    0.45
    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
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6243"
    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: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    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: 23.9% · Safe to merge
    23.9%
    Repository