[MDEV-30306] FR: sql_mode to throw errors instead of warnings on DECIMAL truncating rounding Created: 2022-12-27  Updated: 2023-11-30

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Hartmut Holzgraefe Assignee: Ralf Gebhardt
Resolution: Unresolved Votes: 0
Labels: 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



 Comments   
Comment by Hari Hara Naveen S [ 2022-12-30 ]

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

Comment by Sergei Golubchik [ 2023-01-04 ]

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.

Comment by Daniel Black [ 2023-07-06 ]

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

Generated at Thu Feb 08 10:15:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.