Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30306

FR: sql_mode to throw errors instead of warnings on DECIMAL truncating rounding

Details

    • New Feature
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      When assigning a value with more decimals than a DECIMAL column was created for a

      1265 | Data truncated for column 'val' at row 1

      warning is raised.There has been a request whether an error could be raised instead.

      We looked into solving this using triggers or a check constraint, but apparently rounding already happens before trigger or check condition code is executed, so this approach does not seem to work.

      Hence this feature request for some sort of "NO_DECIMAL_TRUNCATION" sql_mode

      Attachments

        Activity

          I am interested on this feature request, any advice on which files I should look into?

          HHN Hari Hara Naveen S added a comment - I am interested on this feature request, any advice on which files I should look into?

          The current behavior is what the standard requires us to do:

          If an assignment of some number would result in a loss of its most significant digit, an exception condition is raised. If least significant digits are lost, implementation-defined rounding or truncating occurs, with no exception condition being raised.

          serg Sergei Golubchik added a comment - The current behavior is what the standard requires us to do: If an assignment of some number would result in a loss of its most significant digit, an exception condition is raised. If least significant digits are lost, implementation-defined rounding or truncating occurs, with no exception condition being raised.
          danblack Daniel Black added a comment -

          HHN, take a look at the WARN_DATA_TRUNCATED warning in sql/field.cc, sql/field_conv.cc and sql/sql_class.cc

          danblack Daniel Black added a comment - HHN , take a look at the WARN_DATA_TRUNCATED warning in sql/field.cc, sql/field_conv.cc and sql/sql_class.cc

          strict is basically "as strict as the standard", so it should be an error when truncating strings or truncating most significant digits from decimal. And no error when truncating least significant digits.

          serg Sergei Golubchik added a comment - strict is basically "as strict as the standard", so it should be an error when truncating strings or truncating most significant digits from decimal. And no error when truncating least significant digits.

          People

            ralf.gebhardt Ralf Gebhardt
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.