Bug #90161 decimal(M,D)
Submitted: 21 Mar 2018 11:43 Modified: 8 Apr 2018 19:00
Reporter: Dmitriy Kiselev Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[21 Mar 2018 11:43] Dmitriy Kiselev
When we open official docs here: https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html

we can see this two sentenses:
1) "DECIMAL columns do not store a leading + character or - character or leading 0 digits. If you insert +0003.1 into a DECIMAL(5,1) column, it is stored as 3.1. For negative numbers, a literal - character is not stored."

2) "DECIMAL columns do not permit values larger than the range implied by the column definition. For example, a DECIMAL(3,0) column supports a range of -999 to 999. ADECIMAL(M,D) column permits at most M - D digits to the left of the decimal point."

So, can we store -1.0 in DECIMAL(6.3) for example, or not?

How to repeat:
go here:
end read ;)
[22 Mar 2018 8:13] Umesh Shastry
Hello Dmitriy,

Thank you for the report.

[6 Apr 2018 15:35] Paul Dubois
Posted by developer:
"So, can we store -1.0 in DECIMAL(6.3) for example, or not?"

No, because DECIMAL(6.3) is not a valid definition.

Assuming that you meant DECIMAL(6,3), yes. From the quoted text:

"A DECIMAL(M,D) column permits at most M - D digits to the left of the decimal point."

For DECIMAL(6,3), at most M-D = 3 digits are permitted to the left of the decimal point. -1.0 has one digit: Permitted.

To verify, try this:

drop table if exists t;
create table t (d decimal(6,3));
insert into t (d) values(-1.0);
select * from t;
[8 Apr 2018 19:00] Dmitriy Kiselev
Thanks for your answer! But what does it mean:
"For negative numbers, a literal - character is not stored." I read it in documentation.
Is it old information from previous versions?